zeevallin / arcane

Rails strong parameters, made object oriented.
MIT License
50 stars 4 forks source link

#current_params_user should raise NoMethodError when there's no #current_user #12

Closed zeevallin closed 9 years ago

zeevallin commented 9 years ago

I'd rather have it blow up than having to deal with a bunch of nils. #BadDecisions

ngw commented 9 years ago

Having pretty much the same problem here, I mock authentication like this:

  user = User.where(email: 'test@example.com').first
  allow(request.env['warden']).to receive(:authenticate!) { user }
  allow(controller).to receive(:current_user) { user }

The exception raised is:

 Failure/Error: Unable to find matching line from backtrace
 NoMethodError:
   undefined method `authenticate' for nil:NilClass
 # /Users/ngw/.rvm/gems/ruby-2.2.0@conversation_flow_v2_0/gems/devise-3.4.1/lib/devise/controllers/helpers.rb:120:in `current_user'
 # /Users/ngw/.rvm/gems/ruby-2.2.0@conversation_flow_v2_0/gems/arcane-1.1.1/lib/arcane.rb:35:in `current_params_user'
 # /Users/ngw/.rvm/gems/ruby-2.2.0@conversation_flow_v2_0/gems/arcane-1.1.1/lib/arcane.rb:44:in `params='
 # /Users/ngw/.rvm/gems/ruby-2.2.0@conversation_flow_v2_0/gems/actionpack-4.2.0/lib/action_controller/test_case.rb:671:in `setup_controller_request_and_response'

You have an ETA for this? As things stand it appears to me that everything touched by arcane is "unspecable"

zeevallin commented 9 years ago

Closing this in favour of #14