Skip to content

controller specs: params hash does not contain :action or :controller #25

@krisb

Description

@krisb

I'm using CanCan for authorisation and it relies on params[:action] and params[:controller] to determine what resource to load for authorisation checks in a before filter. The specs work when CanCan is disabled so the routing etc is all correct.

The spec is:

describe "GET 'new'" do
  it "should be successful" do
    get 'new'
    response.should be_success
  end
end

I can see that the params hash is empty within the action method which is wrong as it should have the action and controller entries. I can work around this by modifying the spec for now, i.e.:
describe "GET 'new'" do
it "should be successful" do
get 'new', { :action => :new, :controller => :users }
response.should be_success
end
end

I suspect this is due to the usage of ActionDispatch::Integration as you mention on similar issues (http://rspec.lighthouseapp.com/projects/5645/tickets/963-request-is-nil and http://github.com/rspec/rspec-rails/issues#issue/10).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions