From 34cb23ed9c57471e61f57a2497832306171e9ca1 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 10 Oct 2023 11:29:27 -0300 Subject: [PATCH] Fix mocha warnings with hash vs kwargs --- test/controllers/helpers_test.rb | 20 ++++++++++---------- test/controllers/internal_helpers_test.rb | 4 ++-- test/integration/authenticatable_test.rb | 2 +- test/models/authenticatable_test.rb | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/controllers/helpers_test.rb b/test/controllers/helpers_test.rb index abe0f648..655a1fb6 100644 --- a/test/controllers/helpers_test.rb +++ b/test/controllers/helpers_test.rb @@ -64,30 +64,30 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase end test 'proxy authenticate_user! to authenticate with user scope' do - @mock_warden.expects(:authenticate!).with(scope: :user) + @mock_warden.expects(:authenticate!).with({ scope: :user }) @controller.authenticate_user! end test 'proxy authenticate_user! options to authenticate with user scope' do - @mock_warden.expects(:authenticate!).with(scope: :user, recall: "foo") + @mock_warden.expects(:authenticate!).with({ scope: :user, recall: "foo" }) @controller.authenticate_user!(recall: "foo") end test 'proxy authenticate_admin! to authenticate with admin scope' do - @mock_warden.expects(:authenticate!).with(scope: :admin) + @mock_warden.expects(:authenticate!).with({ scope: :admin }) @controller.authenticate_admin! end test 'proxy authenticate_[group]! to authenticate!? with each scope' do [:user, :admin].each do |scope| - @mock_warden.expects(:authenticate!).with(scope: scope) + @mock_warden.expects(:authenticate!).with({ scope: scope }) @mock_warden.expects(:authenticate?).with(scope: scope).returns(false) end @controller.authenticate_commenter! end test 'proxy authenticate_publisher_account! to authenticate with namespaced publisher account scope' do - @mock_warden.expects(:authenticate!).with(scope: :publisher_account) + @mock_warden.expects(:authenticate!).with({ scope: :publisher_account }) @controller.authenticate_publisher_account! end @@ -127,14 +127,14 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase test 'sign in proxy to set_user on warden' do user = User.new @mock_warden.expects(:user).returns(nil) - @mock_warden.expects(:set_user).with(user, scope: :user).returns(true) + @mock_warden.expects(:set_user).with(user, { scope: :user }).returns(true) @controller.sign_in(:user, user) end test 'sign in accepts a resource as argument' do user = User.new @mock_warden.expects(:user).returns(nil) - @mock_warden.expects(:set_user).with(user, scope: :user).returns(true) + @mock_warden.expects(:set_user).with(user, { scope: :user }).returns(true) @controller.sign_in(user) end @@ -148,7 +148,7 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase test 'sign in again when the user is already in only if force is given' do user = User.new @mock_warden.expects(:user).returns(user) - @mock_warden.expects(:set_user).with(user, scope: :user).returns(true) + @mock_warden.expects(:set_user).with(user, { scope: :user }).returns(true) @controller.sign_in(user, force: true) end @@ -269,7 +269,7 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase user = User.new @controller.session[:user_return_to] = "/foo.bar" @mock_warden.expects(:user).with(:user).returns(nil) - @mock_warden.expects(:set_user).with(user, scope: :user).returns(true) + @mock_warden.expects(:set_user).with(user, { scope: :user }).returns(true) @controller.expects(:redirect_to).with("/foo.bar") @controller.sign_in_and_redirect(user) end @@ -277,7 +277,7 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase test 'sign in and redirect uses the configured after sign in path' do admin = Admin.new @mock_warden.expects(:user).with(:admin).returns(nil) - @mock_warden.expects(:set_user).with(admin, scope: :admin).returns(true) + @mock_warden.expects(:set_user).with(admin, { scope: :admin }).returns(true) @controller.expects(:redirect_to).with(admin_root_path) @controller.sign_in_and_redirect(admin) end diff --git a/test/controllers/internal_helpers_test.rb b/test/controllers/internal_helpers_test.rb index af49c130..124c8df0 100644 --- a/test/controllers/internal_helpers_test.rb +++ b/test/controllers/internal_helpers_test.rb @@ -55,7 +55,7 @@ class HelpersTest < Devise::ControllerTestCase end test 'require no authentication tests current mapping' do - @mock_warden.expects(:authenticate?).with(:rememberable, scope: :user).returns(true) + @mock_warden.expects(:authenticate?).with(:rememberable, { scope: :user }).returns(true) @mock_warden.expects(:user).with(:user).returns(User.new) @controller.expects(:redirect_to).with(root_path) @controller.send :require_no_authentication @@ -71,7 +71,7 @@ class HelpersTest < Devise::ControllerTestCase end test 'require no authentication sets a flash message' do - @mock_warden.expects(:authenticate?).with(:rememberable, scope: :user).returns(true) + @mock_warden.expects(:authenticate?).with(:rememberable, { scope: :user }).returns(true) @mock_warden.expects(:user).with(:user).returns(User.new) @controller.expects(:redirect_to).with(root_path) @controller.send :require_no_authentication diff --git a/test/integration/authenticatable_test.rb b/test/integration/authenticatable_test.rb index b8d1be8e..5c56ca58 100644 --- a/test/integration/authenticatable_test.rb +++ b/test/integration/authenticatable_test.rb @@ -572,7 +572,7 @@ class AuthenticationRequestKeysTest < Devise::IntegrationTest host! 'foo.bar.baz' swap Devise, request_keys: [:subdomain] do - User.expects(:find_for_authentication).with(subdomain: 'foo', email: 'user@test.com').returns(create_user) + User.expects(:find_for_authentication).with({ subdomain: 'foo', email: 'user@test.com' }).returns(create_user) sign_in_as_user assert warden.authenticated?(:user) end diff --git a/test/models/authenticatable_test.rb b/test/models/authenticatable_test.rb index fa31f6a8..4d58b1e4 100644 --- a/test/models/authenticatable_test.rb +++ b/test/models/authenticatable_test.rb @@ -43,7 +43,7 @@ class AuthenticatableTest < ActiveSupport::TestCase user = create_user(email: 'example@example.com') attributes = ActionController::Parameters.new(email: 'example@example.com') - User.expects(:find_first_by_auth_conditions).with('email' => 'example@example.com').returns(user) + User.expects(:find_first_by_auth_conditions).with({ 'email' => 'example@example.com' }).returns(user) User.find_or_initialize_with_errors([:email], attributes) end end