Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPRECATION WARNING: request methods will accept only keyword arguments in future Rails versions. #867

Closed
stephannv opened this issue Dec 22, 2015 · 5 comments
Milestone

Comments

@stephannv
Copy link
Contributor

DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only
keyword arguments in future Rails versions.

examples:

get :show, params: { id: 1 }, session: { user_id: 1 }
process :update, method: :post, params: { id: 1 }

I'm using Rails 5 alpha.
Instead of:

post :create, my_model: { some_attribute: 'some attribute' }

Rails 5 will accept only:

post :create, params: { my_model: { some_attribute: 'some attribute' } }

Warning called from:

shoulda-matchers-3.0.1/lib/shoulda/matchers/action_controller/permit_matcher.rb:250)

My spec:

it "permit only whitelisted params" do
    params = { my_model: valid_attributes }

    is_expected.to permit(
        :name, 
        :release_date, 
        :description
    ).for(:create, params: params).on(:my_model)
end

My "solution" for now is
change:

.for(:create, params:  params )

to:

.for(:create, params:  { params: params } )
@mcmire
Copy link
Collaborator

mcmire commented Dec 23, 2015

Okay! Thanks for the report. I've got a backlog right now of stuff to work through right now, but hopefully I can get to this before Rails 5 ships. PR appreciated. :)

@JeremyEllingham
Copy link

JeremyEllingham commented Jul 24, 2016

So I don't need to make any changes to my RSpec, I can wait for the patch and it will fix all these deprecation warnings and save myself a bunch of trouble?

@mcmire
Copy link
Collaborator

mcmire commented Jul 24, 2016

If you're still using Rails 4, yeah -- I know the warnings are annoying, but it's okay for right now. If you're using Rails 5 then there isn't a fix for this yet, unfortunately.

@JeremyEllingham
Copy link

No worries. Is there going to be eventually? I'll keep an eye on this and leave it be if it will be fixed eventually, it's not actually causing a failed case yet.

melissawahnish added a commit to melissawahnish/ruby-thursday that referenced this issue Aug 17, 2016
leaving in a depreciation notice from shoulda matchers that should be fixed
soon per issue thoughtbot/shoulda-matchers#867
@mcmire mcmire mentioned this issue Sep 4, 2016
9 tasks
mygulamali added a commit that referenced this issue Sep 23, 2016
Rails 5 has deprecated the keywords arguments for #permit. This patch
scopes the request params according to the version of Rails.

Fixes #867.  Supercedes #917 with passing tests.

Thank you to @freesteph for helpin' out!
mygulamali added a commit that referenced this issue Sep 23, 2016
Rails 5 has deprecated the keywords arguments for #permit. This patch
scopes the request params according to the ActionPack version.

Fixes #867.  Supercedes #917 with passing tests.

Thank you to @freesteph for helpin' out!
@mcmire mcmire removed the Annoyance label Jul 25, 2017
@mcmire
Copy link
Collaborator

mcmire commented Jul 25, 2017

This will be fixed by #964, so I'm going to go ahead and close this to clean things up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants