From c64468e13d1370f153ce463b875d294415974bda Mon Sep 17 00:00:00 2001 From: Murtaza Gulamali Date: Fri, 23 Sep 2016 12:32:44 +0100 Subject: [PATCH] Scope parameters according to Rails version 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! --- lib/shoulda/matchers/action_controller/permit_matcher.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/shoulda/matchers/action_controller/permit_matcher.rb b/lib/shoulda/matchers/action_controller/permit_matcher.rb index 5cdbb5c36..9c90dccca 100644 --- a/lib/shoulda/matchers/action_controller/permit_matcher.rb +++ b/lib/shoulda/matchers/action_controller/permit_matcher.rb @@ -250,7 +250,10 @@ def matches?(controller) parameters_double_registry.register Doublespeak.with_doubles_activated do - context.__send__(verb, action, request_params) + scoped = ::ActionPack::VERSION::MAJOR >= 5 + params = scoped ? { params: request_params } : request_params + + context.__send__(verb, action, params) end unpermitted_parameter_names.empty?