Skip to content

Create action does not exist using load and authorize #948

Open
jleecbd opened this Issue Oct 1, 2013 · 1 comment

2 participants

@jleecbd
jleecbd commented Oct 1, 2013

I've got two controllers that only have load_and_authorize_resource (no other actions defined). These were working a while back, but I've been rebuilding the app (switching to factories from fixtures among other things). These two controllers haven't been touched in this process, but now I get the following error message:

1) Error:
IndustriesControllerTest#test_should_create_industry:
AbstractController::ActionNotFound: The action 'create' could not be found for IndustriesController
/Users/jlee/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.14/lib/abstract_controller/base.rb:116:in process'
/Users/jlee/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.14/lib/abstract_controller/rendering.rb:45:in
process'
/Users/jlee/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.14/lib/action_controller/metal/testing.rb:17:in process_with_new_base_test'
/Users/jlee/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.14/lib/action_controller/test_case.rb:490:in
process'
/Users/jlee/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.14/lib/action_controller/test_case.rb:54:in process'
/Users/jlee/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.14/lib/action_controller/test_case.rb:412:in
post'
/Users/jlee/Documents/Work/InfoSynergetics/limspec/test/functional/industries_controller_test.rb:27:in block (2 levels) in <class:IndustriesControllerTest>'
/Users/jlee/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.14/lib/active_support/testing/assertions.rb:55:in
assert_difference'
/Users/jlee/Documents/Work/InfoSynergetics/limspec/test/functional/industries_controller_test.rb:26:in `block in class:IndustriesControllerTest'

The test that is triggering this is:

test "should create industry" do
assert_difference('Industry.count') do
post :create, industry: { indName: 'Test Industry' }
end

assert_redirected_to industry_path(assigns(:industry))

end

I have the exact same issue with another controller (I'm still cleaning up tests so I haven't been through all of the controllers yet). I realize that I arguably shouldn't be testing standard REST actions, but I since this used to work, I'd like to figure out why it isn't...

CanCan version is 1.6.10

@bertBruynooghe

Same problem over here. Tested with a blank Rails 3.2.16 project with a blank controller, and no create action found.
Tried to revert cancan versions all the way down to 1.4.0, but the problem persisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.