SHARE
TWEET

Untitled

a guest Aug 20th, 2012 130 Never
  1. #And here is my test:
  2.  
  3.     it "passes the token" do
  4.       get :new, nil,
  5.         :authorization => ActionController::HttpAuthentication::Token.encode_credentials("test_access1")
  6.  
  7.       assigns(:token).should be "test_access1"
  8.     end
  9.  
  10. #Here's my before filter:
  11.  
  12.     def restrict_access
  13.       authenticate_or_request_with_http_token do |token, options|
  14.         api_key = ApiKey.find_by_access_token(token)
  15.         @user = api_key.user unless api_key.nil?
  16.         @token = token #set just for the sake of testing
  17.         !api_key.nil?
  18.       end
  19.     end
RAW Paste Data
Top