Rails token authentication and testing it -
i'm trying pass token rails , validate it, getting strange "render" error. additionally, i'm not sure how pass "authentication: token token=" header through rspec controller test.
here's relevant code:
/app/controllers/api_base_controller.rb
# authentication method in i'm trying set @current_user class apibasecontroller < rocketpants::base private def authenticate_social ## line 7 of error below authenticate_or_request_with_http_token |token, options| @current_customer = customer.where(token: token).first end end end
/app/controllers/api/v1/customers_controller.rb
# simple method "expose" (rocketpants' way of respond_with) @current_customer above class api::v1::customerscontroller < apibasecontroller before_action :authenticate_social def fetch expose @current_customer end end
/spec/controllers/api/v1/customers_controller_spec.rb
rspec.describe api::v1::customerscontroller, type: :controller describe 'get #fetch' context '[customer token exists]' 'returns customer object' @customer = factorygirl.create(:facebook_customer) :fetch, version: 1 ## line 81 of error below. not sure how pass token header expect(response).to be_singular_resource end end end end
the rspec error
3) api::v1::customerscontroller #fetch [customer token exists] returns customer object failure/error: :fetch, version: 1 nomethoderror: undefined method `render' #<api::v1::customerscontroller:0x007f9b20c39430> # ./app/controllers/api_base_controller.rb:7:in `authenticate_social' # ./spec/controllers/api/v1/customers_controller_spec.rb:81:in `block (4 levels) in <top (required)>'
i've searched high , low, still, nothing. thoughts?
Comments
Post a Comment