From c4c8fad66c1bace811fefa98008a95f972c0bb54 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 10 Oct 2023 09:55:31 -0300 Subject: [PATCH 01/16] Use Rails 7.1 on main Gemfile and create a new one for 7.0 --- .github/workflows/test.yml | 15 +++ Gemfile | 2 +- Gemfile.lock | 229 +++++++++++++++++++++---------------- gemfiles/Gemfile-rails-7-0 | 38 ++++++ 4 files changed, 183 insertions(+), 101 deletions(-) create mode 100644 gemfiles/Gemfile-rails-7-0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 207f5703..851bc6a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,7 @@ jobs: gemfile: - Gemfile - gemfiles/Gemfile-rails-main + - gemfiles/Gemfile-rails-7-0 - gemfiles/Gemfile-rails-6-1 - gemfiles/Gemfile-rails-6-0 - gemfiles/Gemfile-rails-5-2 @@ -58,6 +59,20 @@ jobs: ruby: '2.1' - gemfile: gemfiles/Gemfile-rails-main env: DEVISE_ORM=mongoid + - gemfile: gemfiles/Gemfile-rails-7-0 + ruby: '2.6' + - gemfile: gemfiles/Gemfile-rails-7-0 + ruby: '2.5' + - gemfile: gemfiles/Gemfile-rails-7-0 + ruby: '2.4' + - gemfile: gemfiles/Gemfile-rails-7-0 + ruby: '2.3' + - gemfile: gemfiles/Gemfile-rails-7-0 + ruby: '2.2' + - gemfile: gemfiles/Gemfile-rails-7-0 + ruby: '2.1' + - gemfile: gemfiles/Gemfile-rails-7-0 + env: DEVISE_ORM=mongoid - gemfile: gemfiles/Gemfile-rails-6-1 ruby: '2.4' - gemfile: gemfiles/Gemfile-rails-6-1 diff --git a/Gemfile b/Gemfile index 1a4ec823..b975b7de 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source "https://rubygems.org" gemspec -gem "rails", "~> 7.0.0" +gem "rails", "~> 7.1.0" gem "omniauth" gem "omniauth-oauth2" gem "rdoc" diff --git a/Gemfile.lock b/Gemfile.lock index 23005760..12ea9b80 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/rails/rails-controller-testing.git - revision: 351c0162df0771c0c48e6a5a886c4c2f0a5d1a74 + revision: c203673f8011a7cdc2a8edf995ae6b3eec3417ca specs: rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -20,114 +20,132 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) + actioncable (7.1.0) + actionpack (= 7.1.0) + activesupport (= 7.1.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + zeitwerk (~> 2.6) + actionmailbox (7.1.0) + actionpack (= 7.1.0) + activejob (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4.3) - actionpack (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activesupport (= 7.0.4.3) + actionmailer (7.1.0) + actionpack (= 7.1.0) + actionview (= 7.1.0) + activejob (= 7.1.0) + activesupport (= 7.1.0) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.4.3) - actionview (= 7.0.4.3) - activesupport (= 7.0.4.3) - rack (~> 2.0, >= 2.2.0) + rails-dom-testing (~> 2.2) + actionpack (7.1.0) + actionview (= 7.1.0) + activesupport (= 7.1.0) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4.3) - actionpack (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.0) + actionpack (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4.3) - activesupport (= 7.0.4.3) + actionview (7.1.0) + activesupport (= 7.1.0) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4.3) - activesupport (= 7.0.4.3) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.0) + activesupport (= 7.1.0) globalid (>= 0.3.6) - activemodel (7.0.4.3) - activesupport (= 7.0.4.3) - activerecord (7.0.4.3) - activemodel (= 7.0.4.3) - activesupport (= 7.0.4.3) - activestorage (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activesupport (= 7.0.4.3) + activemodel (7.1.0) + activesupport (= 7.1.0) + activerecord (7.1.0) + activemodel (= 7.1.0) + activesupport (= 7.1.0) + timeout (>= 0.4.0) + activestorage (7.1.0) + actionpack (= 7.1.0) + activejob (= 7.1.0) + activerecord (= 7.1.0) + activesupport (= 7.1.0) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.4.3) + activesupport (7.1.0) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) - bcrypt (3.1.18) + base64 (0.1.1) + bcrypt (3.1.19) + bigdecimal (3.1.4) builder (3.2.4) concurrent-ruby (1.2.2) + connection_pool (2.4.1) crass (1.0.6) date (3.3.3) + drb (2.1.1) + ruby2_keywords erubi (1.12.0) - faraday (2.7.4) + faraday (2.7.11) + base64 faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) faraday-net_http (3.0.2) - globalid (1.1.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) hashie (5.0.0) - i18n (1.12.0) + i18n (1.14.1) concurrent-ruby (~> 1.0) - jwt (2.7.0) - loofah (2.19.1) + io-console (0.6.0) + irb (1.8.1) + rdoc + reline (>= 0.3.8) + jwt (2.7.1) + loofah (2.21.3) crass (~> 1.0.2) - nokogiri (>= 1.5.9) + nokogiri (>= 1.12.0) mail (2.8.1) mini_mime (>= 0.1.1) net-imap net-pop net-smtp marcel (1.0.2) - method_source (1.0.0) - mini_mime (1.1.2) - mini_portile2 (2.8.1) - minitest (5.18.0) + mini_mime (1.1.5) + mini_portile2 (2.8.4) + minitest (5.20.0) mocha (1.16.1) multi_xml (0.6.0) - net-imap (0.3.4) + mutex_m (0.1.2) + net-imap (0.4.1) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.1) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol - nio4r (2.5.8) - nokogiri (1.14.2) - mini_portile2 (~> 2.8.0) + nio4r (2.5.9) + nokogiri (1.15.4) + mini_portile2 (~> 2.8.2) racc (~> 1.4) oauth2 (2.0.9) faraday (>= 0.17.3, < 3.0) @@ -151,72 +169,83 @@ GEM orm_adapter (0.5.0) psych (5.1.0) stringio - racc (1.6.2) - rack (2.2.6.4) + racc (1.7.1) + rack (2.2.8) rack-openid (1.4.2) rack (>= 1.1.0) ruby-openid (>= 2.1.8) - rack-protection (3.0.5) - rack + rack-protection (3.1.0) + rack (~> 2.2, >= 2.2.4) + rack-session (1.0.1) + rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.4.3) - actioncable (= 7.0.4.3) - actionmailbox (= 7.0.4.3) - actionmailer (= 7.0.4.3) - actionpack (= 7.0.4.3) - actiontext (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activemodel (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + rackup (1.0.0) + rack (< 3) + webrick + rails (7.1.0) + actioncable (= 7.1.0) + actionmailbox (= 7.1.0) + actionmailer (= 7.1.0) + actionpack (= 7.1.0) + actiontext (= 7.1.0) + actionview (= 7.1.0) + activejob (= 7.1.0) + activemodel (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) bundler (>= 1.15.0) - railties (= 7.0.4.3) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + railties (= 7.1.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.5.0) - loofah (~> 2.19, >= 2.19.1) - railties (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) - method_source + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.0) + actionpack (= 7.1.0) + activesupport (= 7.1.0) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rake (13.0.6) rdoc (6.5.0) psych (>= 4.0.0) + reline (0.3.9) + io-console (~> 0.5) responders (3.1.0) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.2.5) + rexml (3.2.6) ruby-openid (2.9.2) ruby2_keywords (0.0.5) snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) - sqlite3 (1.6.1) + sqlite3 (1.6.6) mini_portile2 (~> 2.8.0) - stringio (3.0.5) - thor (1.2.1) - timecop (0.9.6) - timeout (0.3.2) + stringio (3.0.8) + thor (1.2.2) + timecop (0.9.8) + timeout (0.4.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - version_gem (1.1.2) + version_gem (1.1.3) warden (1.2.9) rack (>= 2.0.9) webrat (0.7.3) nokogiri (>= 1.2.0) rack (>= 1.0) rack-test (>= 0.5.3) - websocket-driver (0.7.5) + webrick (1.8.1) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.7) + zeitwerk (2.6.12) PLATFORMS ruby @@ -228,7 +257,7 @@ DEPENDENCIES omniauth-facebook omniauth-oauth2 omniauth-openid - rails (~> 7.0.0) + rails (~> 7.1.0) rails-controller-testing! rdoc responders (~> 3.1) diff --git a/gemfiles/Gemfile-rails-7-0 b/gemfiles/Gemfile-rails-7-0 new file mode 100644 index 00000000..91c8061c --- /dev/null +++ b/gemfiles/Gemfile-rails-7-0 @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gemspec path: ".." + +gem "rails", "~> 7.0.0" +gem "omniauth" +gem "omniauth-oauth2" +gem "rdoc" + +gem "rails-controller-testing", github: "rails/rails-controller-testing" + +gem "responders", "~> 3.1" + +group :test do + gem "omniauth-facebook" + gem "omniauth-openid" + gem "rexml" + gem "timecop" + gem "webrat", "0.7.3", require: false + gem "mocha", "~> 1.1", require: false +end + +platforms :ruby do + gem "sqlite3", "~> 1.4" +end + +# platforms :jruby do +# gem "activerecord-jdbc-adapter" +# gem "activerecord-jdbcsqlite3-adapter" +# gem "jruby-openssl" +# end + +# TODO: +# group :mongoid do +# gem "mongoid", "~> 4.0.0" +# end From 14aa380d80f5003e147b06c376a2ace52d24f8db Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 17 Aug 2023 10:13:16 -0300 Subject: [PATCH 02/16] Update mocha to fix issue with Minitest compatibility layer There's a number of deprecation warnings to work through related to mocha updates in v2+, we'll get through those on a separate change. https://github.com/freerange/mocha/blob/main/RELEASE.md#200 The main issue is with Minitest, fixed in v2.1: https://github.com/freerange/mocha/blob/main/RELEASE.md#210 Also run `bundle update` on the main Gemfile to update all dependencies there to latest. --- Gemfile | 2 +- Gemfile.lock | 5 +++-- gemfiles/Gemfile-rails-4-1 | 2 +- gemfiles/Gemfile-rails-4-2 | 2 +- gemfiles/Gemfile-rails-5-0 | 2 +- gemfiles/Gemfile-rails-5-1 | 2 +- gemfiles/Gemfile-rails-5-2 | 2 +- gemfiles/Gemfile-rails-6-0 | 2 +- gemfiles/Gemfile-rails-6-1 | 2 +- gemfiles/Gemfile-rails-7-0 | 2 +- gemfiles/Gemfile-rails-main | 2 +- test/routes_test.rb | 2 +- 12 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index b975b7de..722eb59a 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ group :test do gem "rexml" gem "timecop" gem "webrat", "0.7.3", require: false - gem "mocha", "~> 1.1", require: false + gem "mocha", "~> 2.1", require: false end platforms :ruby do diff --git a/Gemfile.lock b/Gemfile.lock index 12ea9b80..86faf08e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -131,7 +131,8 @@ GEM mini_mime (1.1.5) mini_portile2 (2.8.4) minitest (5.20.0) - mocha (1.16.1) + mocha (2.1.0) + ruby2_keywords (>= 0.0.5) multi_xml (0.6.0) mutex_m (0.1.2) net-imap (0.4.1) @@ -252,7 +253,7 @@ PLATFORMS DEPENDENCIES devise! - mocha (~> 1.1) + mocha (~> 2.1) omniauth omniauth-facebook omniauth-oauth2 diff --git a/gemfiles/Gemfile-rails-4-1 b/gemfiles/Gemfile-rails-4-1 index 6f0b77e8..33fb7b57 100644 --- a/gemfiles/Gemfile-rails-4-1 +++ b/gemfiles/Gemfile-rails-4-1 @@ -21,7 +21,7 @@ group :test do gem "omniauth-openid" gem "timecop" gem "webrat", "0.7.3", require: false - gem "mocha", "~> 1.1", require: false + gem "mocha", "~> 2.1", require: false gem 'test_after_commit', require: false end diff --git a/gemfiles/Gemfile-rails-4-2 b/gemfiles/Gemfile-rails-4-2 index 43367157..d99d368c 100644 --- a/gemfiles/Gemfile-rails-4-2 +++ b/gemfiles/Gemfile-rails-4-2 @@ -20,7 +20,7 @@ group :test do gem "omniauth-openid" gem "timecop" gem "webrat", "0.7.3", require: false - gem "mocha", "~> 1.1", require: false + gem "mocha", "~> 2.1", require: false gem 'test_after_commit', require: false end diff --git a/gemfiles/Gemfile-rails-5-0 b/gemfiles/Gemfile-rails-5-0 index 382cf3c5..ea23acf7 100644 --- a/gemfiles/Gemfile-rails-5-0 +++ b/gemfiles/Gemfile-rails-5-0 @@ -18,7 +18,7 @@ group :test do gem "omniauth-openid" gem "timecop" gem "webrat", "0.7.3", require: false - gem "mocha", "~> 1.1", require: false + gem "mocha", "~> 2.1", require: false end platforms :ruby do diff --git a/gemfiles/Gemfile-rails-5-1 b/gemfiles/Gemfile-rails-5-1 index 24fe1d5e..9921633e 100644 --- a/gemfiles/Gemfile-rails-5-1 +++ b/gemfiles/Gemfile-rails-5-1 @@ -16,7 +16,7 @@ group :test do gem "omniauth-openid" gem "timecop" gem "webrat", "0.7.3", require: false - gem "mocha", "~> 1.1", require: false + gem "mocha", "~> 2.1", require: false end platforms :ruby do diff --git a/gemfiles/Gemfile-rails-5-2 b/gemfiles/Gemfile-rails-5-2 index 5dc267de..ef9f08fc 100644 --- a/gemfiles/Gemfile-rails-5-2 +++ b/gemfiles/Gemfile-rails-5-2 @@ -16,7 +16,7 @@ group :test do gem "omniauth-openid" gem "timecop" gem "webrat", "0.7.3", require: false - gem "mocha", "~> 1.1", require: false + gem "mocha", "~> 2.1", require: false end platforms :ruby do diff --git a/gemfiles/Gemfile-rails-6-0 b/gemfiles/Gemfile-rails-6-0 index b59c4d3d..b6afb672 100644 --- a/gemfiles/Gemfile-rails-6-0 +++ b/gemfiles/Gemfile-rails-6-0 @@ -17,7 +17,7 @@ group :test do gem "rexml" gem "timecop" gem "webrat", "0.7.3", require: false - gem "mocha", "~> 1.1", require: false + gem "mocha", "~> 2.1", require: false end platforms :ruby do diff --git a/gemfiles/Gemfile-rails-6-1 b/gemfiles/Gemfile-rails-6-1 index a4a81e41..bdebe1a7 100644 --- a/gemfiles/Gemfile-rails-6-1 +++ b/gemfiles/Gemfile-rails-6-1 @@ -23,7 +23,7 @@ group :test do gem "rexml" gem "timecop" gem "webrat", "0.7.3", require: false - gem "mocha", "~> 1.1", require: false + gem "mocha", "~> 2.1", require: false end platforms :ruby do diff --git a/gemfiles/Gemfile-rails-7-0 b/gemfiles/Gemfile-rails-7-0 index 91c8061c..ee474728 100644 --- a/gemfiles/Gemfile-rails-7-0 +++ b/gemfiles/Gemfile-rails-7-0 @@ -19,7 +19,7 @@ group :test do gem "rexml" gem "timecop" gem "webrat", "0.7.3", require: false - gem "mocha", "~> 1.1", require: false + gem "mocha", "~> 2.1", require: false end platforms :ruby do diff --git a/gemfiles/Gemfile-rails-main b/gemfiles/Gemfile-rails-main index c9bea6f2..12930653 100644 --- a/gemfiles/Gemfile-rails-main +++ b/gemfiles/Gemfile-rails-main @@ -17,7 +17,7 @@ group :test do gem "rexml" gem "timecop" gem "webrat", "0.7.3", require: false - gem "mocha", "~> 1.1", require: false + gem "mocha", "~> 2.1", require: false end platforms :ruby do diff --git a/test/routes_test.rb b/test/routes_test.rb index 48d3f069..0cfd6fc0 100644 --- a/test/routes_test.rb +++ b/test/routes_test.rb @@ -2,7 +2,7 @@ require 'test_helper' -ExpectedRoutingError = MiniTest::Assertion +ExpectedRoutingError = Minitest::Assertion class DefaultRoutingTest < ActionController::TestCase test 'map new user session' do 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 03/16] 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 From a7d64ae313672488d8f689b3e48dc0601db8528f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 9 Jun 2023 18:12:01 -0400 Subject: [PATCH 04/16] Merge pull request #5583 from etiennebarrie/deprecator Use a dedicated ActiveSupport::Deprecation --- app/helpers/devise_helper.rb | 2 +- lib/devise.rb | 6 +++++- lib/devise/controllers/sign_in_out.rb | 2 +- lib/devise/models/authenticatable.rb | 2 +- lib/devise/models/database_authenticatable.rb | 4 ++-- lib/devise/rails.rb | 4 ++++ lib/devise/test/controller_helpers.rb | 2 +- lib/devise/test_helpers.rb | 2 +- test/devise_test.rb | 4 +++- test/models/serializable_test.rb | 4 +++- test/rails_test.rb | 6 ++++++ test/test_helper.rb | 13 +++++++++++++ 12 files changed, 41 insertions(+), 10 deletions(-) diff --git a/app/helpers/devise_helper.rb b/app/helpers/devise_helper.rb index d9978011..b9101e04 100644 --- a/app/helpers/devise_helper.rb +++ b/app/helpers/devise_helper.rb @@ -4,7 +4,7 @@ module DeviseHelper # Retain this method for backwards compatibility, deprecated in favor of modifying the # devise/shared/error_messages partial. def devise_error_messages! - ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc + Devise.deprecator.warn <<-DEPRECATION.strip_heredoc [Devise] `DeviseHelper#devise_error_messages!` is deprecated and will be removed in the next major version. diff --git a/lib/devise.rb b/lib/devise.rb index b8677e79..3847e190 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -521,8 +521,12 @@ module Devise res == 0 end + def self.deprecator + @deprecator ||= ActiveSupport::Deprecation.new("5.0", "Devise") + end + def self.activerecord51? # :nodoc: - ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc + deprecator.warn <<-DEPRECATION.strip_heredoc [Devise] `Devise.activerecord51?` is deprecated and will be removed in the next major version. It is a non-public method that's no longer used internally, but that other libraries have been relying on. DEPRECATION diff --git a/lib/devise/controllers/sign_in_out.rb b/lib/devise/controllers/sign_in_out.rb index 90c2a436..b12f05f7 100644 --- a/lib/devise/controllers/sign_in_out.rb +++ b/lib/devise/controllers/sign_in_out.rb @@ -38,7 +38,7 @@ module Devise expire_data_after_sign_in! if options[:bypass] - ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller) + Devise.deprecator.warn(<<-DEPRECATION.strip_heredoc, caller) [Devise] bypass option is deprecated and it will be removed in future version of Devise. Please use bypass_sign_in method instead. Example: diff --git a/lib/devise/models/authenticatable.rb b/lib/devise/models/authenticatable.rb index 62590de5..30f2f463 100644 --- a/lib/devise/models/authenticatable.rb +++ b/lib/devise/models/authenticatable.rb @@ -62,7 +62,7 @@ module Devise :remember_token, :unconfirmed_email, :failed_attempts, :unlock_token, :locked_at] include Devise::DeprecatedConstantAccessor - deprecate_constant "BLACKLIST_FOR_SERIALIZATION", "Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION" + deprecate_constant "BLACKLIST_FOR_SERIALIZATION", "Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION", deprecator: Devise.deprecator included do class_attribute :devise_modules, instance_writer: false diff --git a/lib/devise/models/database_authenticatable.rb b/lib/devise/models/database_authenticatable.rb index fc6ad714..8903e6d0 100644 --- a/lib/devise/models/database_authenticatable.rb +++ b/lib/devise/models/database_authenticatable.rb @@ -86,7 +86,7 @@ module Devise # is also rejected as long as it is also blank. def update_with_password(params, *options) if options.present? - ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc + Devise.deprecator.warn <<-DEPRECATION.strip_heredoc [Devise] The second argument of `DatabaseAuthenticatable#update_with_password` (`options`) is deprecated and it will be removed in the next major version. It was added to support a feature deprecated in Rails 4, so you can safely remove it @@ -128,7 +128,7 @@ module Devise # def update_without_password(params, *options) if options.present? - ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc + Devise.deprecator.warn <<-DEPRECATION.strip_heredoc [Devise] The second argument of `DatabaseAuthenticatable#update_without_password` (`options`) is deprecated and it will be removed in the next major version. It was added to support a feature deprecated in Rails 4, so you can safely remove it diff --git a/lib/devise/rails.rb b/lib/devise/rails.rb index 5cc5fa6d..ab308e97 100644 --- a/lib/devise/rails.rb +++ b/lib/devise/rails.rb @@ -17,6 +17,10 @@ module Devise app.reload_routes! if Devise.reload_routes end + initializer "devise.deprecator" do |app| + app.deprecators[:devise] = Devise.deprecator if app.respond_to?(:deprecators) + end + initializer "devise.url_helpers" do Devise.include_helpers(Devise::Controllers) end diff --git a/lib/devise/test/controller_helpers.rb b/lib/devise/test/controller_helpers.rb index 30b45b3a..b6a7156e 100644 --- a/lib/devise/test/controller_helpers.rb +++ b/lib/devise/test/controller_helpers.rb @@ -69,7 +69,7 @@ module Devise scope = resource resource = deprecated - ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc + Devise.deprecator.warn <<-DEPRECATION.strip_heredoc [Devise] sign_in(:#{scope}, resource) on controller tests is deprecated and will be removed from Devise. Please use sign_in(resource, scope: :#{scope}) instead. DEPRECATION diff --git a/lib/devise/test_helpers.rb b/lib/devise/test_helpers.rb index c5b52fad..cc9ef424 100644 --- a/lib/devise/test_helpers.rb +++ b/lib/devise/test_helpers.rb @@ -4,7 +4,7 @@ module Devise module TestHelpers def self.included(base) base.class_eval do - ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc + Devise.deprecator.warn <<-DEPRECATION.strip_heredoc [Devise] including `Devise::TestHelpers` is deprecated and will be removed from Devise. For controller tests, please include `Devise::Test::ControllerHelpers` instead. DEPRECATION diff --git a/test/devise_test.rb b/test/devise_test.rb index 54ed9867..532aa57d 100644 --- a/test/devise_test.rb +++ b/test/devise_test.rb @@ -108,6 +108,8 @@ class DeviseTest < ActiveSupport::TestCase end test 'Devise.activerecord51? deprecation' do - assert_deprecated { Devise.activerecord51? } + assert_deprecated("`Devise.activerecord51?` is deprecated", Devise.deprecator) do + Devise.activerecord51? + end end end diff --git a/test/models/serializable_test.rb b/test/models/serializable_test.rb index 225f7ae6..3a032280 100644 --- a/test/models/serializable_test.rb +++ b/test/models/serializable_test.rb @@ -32,7 +32,9 @@ class SerializableTest < ActiveSupport::TestCase end test 'constant `BLACKLIST_FOR_SERIALIZATION` is deprecated' do - assert_deprecated { Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION } + assert_deprecated("Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION", Devise.deprecator) do + Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION + end end def assert_key(key, subject) diff --git a/test/rails_test.rb b/test/rails_test.rb index fdc1612e..64ff82cd 100644 --- a/test/rails_test.rb +++ b/test/rails_test.rb @@ -8,4 +8,10 @@ class RailsTest < ActiveSupport::TestCase assert_equal :load_config_initializers, initializer.after assert_equal :build_middleware_stack, initializer.before end + + if Devise::Test.rails71_and_up? + test 'deprecator is added to application deprecators' do + assert_not_nil Rails.application.deprecators[:devise] + end + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index ad5a6db6..aba66aa7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -23,6 +23,19 @@ end if ActiveSupport.respond_to?(:test_order) ActiveSupport.test_order = :random end +class ActiveSupport::TestCase + if ActiveSupport.version < Gem::Version.new("5.0") + def assert_deprecated(match, deprecator) + super(match) do + behavior = deprecator.behavior + deprecator.behavior = ActiveSupport::Deprecation.behavior + yield + ensure + deprecator.behavior = behavior + end + end + end +end OmniAuth.config.logger = Logger.new('/dev/null') From 13cb6e269d4bf1a4b67b579873ca4948814e273f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 9 Jun 2023 18:16:49 -0400 Subject: [PATCH 05/16] Merge pull request #5599 from etiennebarrie/rails-edge-deprecations Fix Rails main deprecations --- test/orm/active_record.rb | 4 +++- test/rails_app/config/environments/test.rb | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/orm/active_record.rb b/test/orm/active_record.rb index cf500330..97bf37c5 100644 --- a/test/orm/active_record.rb +++ b/test/orm/active_record.rb @@ -5,7 +5,9 @@ ActiveRecord::Base.logger = Logger.new(nil) ActiveRecord::Base.include_root_in_json = true migrate_path = File.expand_path("../../rails_app/db/migrate/", __FILE__) -if Devise::Test.rails6_and_up? +if Devise::Test.rails71_and_up? + ActiveRecord::MigrationContext.new(migrate_path).migrate +elsif Devise::Test.rails6_and_up? ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate elsif Devise::Test.rails52_and_up? ActiveRecord::MigrationContext.new(migrate_path).migrate diff --git a/test/rails_app/config/environments/test.rb b/test/rails_app/config/environments/test.rb index c5d393c5..9153790a 100644 --- a/test/rails_app/config/environments/test.rb +++ b/test/rails_app/config/environments/test.rb @@ -32,7 +32,11 @@ RailsApp::Application.configure do config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + if Devise::Test.rails71_and_up? + config.action_dispatch.show_exceptions = :none + else + config.action_dispatch.show_exceptions = false + end # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false From 9784555304d4b5e476571aa78b8ee2f7a255a44a Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 12 Sep 2023 21:39:56 -0300 Subject: [PATCH 06/16] Merge pull request #5628 from soartec-lab/fix/dedicated_active_support_deprecation Fixed missing migration to dedicated deprecator --- CHANGELOG.md | 3 ++- lib/devise/rails/deprecated_constant_accessor.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d96ad3f1..1236363a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### Unreleased - +* enhancements + * Changed to use a separate deprecator inside the gem. because `rails` 7.1 will deprecate using the singleton `ActiveSupport::Deprecation.instance` (@soartec-lab, @etiennebarrie) ### 4.9.2 - 2023-04-03 diff --git a/lib/devise/rails/deprecated_constant_accessor.rb b/lib/devise/rails/deprecated_constant_accessor.rb index d1eff92f..f5cf01f8 100644 --- a/lib/devise/rails/deprecated_constant_accessor.rb +++ b/lib/devise/rails/deprecated_constant_accessor.rb @@ -26,7 +26,7 @@ rescue LoadError super end - def deprecate_constant(const_name, new_constant, message: nil, deprecator: ActiveSupport::Deprecation.instance) + def deprecate_constant(const_name, new_constant, message: nil, deprecator: Devise.deprecator) class_variable_set(:@@_deprecated_constants, {}) unless class_variable_defined?(:@@_deprecated_constants) class_variable_get(:@@_deprecated_constants)[const_name.to_s] = { new: new_constant, message: message, deprecator: deprecator } end From fb7faf746676304aadc8185d0e17a05eb7bb5702 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 12 Sep 2023 21:52:54 -0300 Subject: [PATCH 07/16] Fix code to support older versions of Ruby We still support super old versions, yes, and it doesn't like `ensure` without a `begin..end` unfortunately. I plan to remove this support soon, but for now I don't want to stop supporting it yet. --- test/test_helper.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index aba66aa7..c0bb43f7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -27,11 +27,14 @@ class ActiveSupport::TestCase if ActiveSupport.version < Gem::Version.new("5.0") def assert_deprecated(match, deprecator) super(match) do - behavior = deprecator.behavior - deprecator.behavior = ActiveSupport::Deprecation.behavior - yield - ensure - deprecator.behavior = behavior + # TODO: remove extra begin..end when dropping support for Ruby <= 2.4 + begin + behavior = deprecator.behavior + deprecator.behavior = ActiveSupport::Deprecation.behavior + yield + ensure + deprecator.behavior = behavior + end end end end From 373d83cc9d740a41b6fa9de6c3cce611d8740b8b Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 13 Sep 2023 10:08:59 -0300 Subject: [PATCH 08/16] Use Bundler 1.x with Ruby <= 2.2 Here we go again. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 851bc6a6..8018e06a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -164,8 +164,8 @@ jobs: BUNDLE_GEMFILE: ${{ matrix.gemfile }} steps: - uses: actions/checkout@v3 - - name: Setup Bundler 1.x for Rails 4.x - if: ${{ matrix.gemfile == 'gemfiles/Gemfile-rails-4-1' || matrix.gemfile == 'gemfiles/Gemfile-rails-4-2' }} + - name: Setup Bundler 1.x for Rails 4.x and Ruby <= 2.2 + if: ${{ matrix.gemfile == 'gemfiles/Gemfile-rails-4-1' || matrix.gemfile == 'gemfiles/Gemfile-rails-4-2' || matrix.ruby <= '2.2' }} run: echo "BUNDLER_VERSION=1.17.3" >> $GITHUB_ENV - name: Setup Rubygems version as default for Ruby < 2.5 if: ${{ matrix.ruby < '2.5' }} From 501ae58a2521cb549f2e2cefcbd6f9cf8ab91874 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 13 Sep 2023 10:15:15 -0300 Subject: [PATCH 09/16] Lock loofah on Rails <= 5.2 There's some incompatibility issue with loofah there since it uses an older version of nokogiri, so I'm locking it on those older versions to try to get a green build again there. --- gemfiles/Gemfile-rails-4-1 | 3 +++ gemfiles/Gemfile-rails-4-2 | 3 +++ gemfiles/Gemfile-rails-5-0 | 3 +++ gemfiles/Gemfile-rails-5-1 | 3 +++ gemfiles/Gemfile-rails-5-2 | 3 +++ 5 files changed, 15 insertions(+) diff --git a/gemfiles/Gemfile-rails-4-1 b/gemfiles/Gemfile-rails-4-1 index 33fb7b57..f164f8a9 100644 --- a/gemfiles/Gemfile-rails-4-1 +++ b/gemfiles/Gemfile-rails-4-1 @@ -44,3 +44,6 @@ if RUBY_VERSION < "2.3.0" # `Object.deprecate_constant` which isn't available. gem "multipart-post", "2.1.1" end + +# There's a build incompatibility issue with nokogiri and loofah +gem "loofah", "~> 2.20.0" diff --git a/gemfiles/Gemfile-rails-4-2 b/gemfiles/Gemfile-rails-4-2 index d99d368c..31205659 100644 --- a/gemfiles/Gemfile-rails-4-2 +++ b/gemfiles/Gemfile-rails-4-2 @@ -43,3 +43,6 @@ if RUBY_VERSION < "2.3.0" # `Object.deprecate_constant` which isn't available. gem "multipart-post", "2.1.1" end + +# There's a build incompatibility issue with nokogiri and loofah +gem "loofah", "~> 2.20.0" diff --git a/gemfiles/Gemfile-rails-5-0 b/gemfiles/Gemfile-rails-5-0 index ea23acf7..7e3c3295 100644 --- a/gemfiles/Gemfile-rails-5-0 +++ b/gemfiles/Gemfile-rails-5-0 @@ -35,3 +35,6 @@ if RUBY_VERSION < "2.3.0" # `Object.deprecate_constant` which isn't available. gem "multipart-post", "2.1.1" end + +# There's a build incompatibility issue with nokogiri and loofah +gem "loofah", "~> 2.20.0" diff --git a/gemfiles/Gemfile-rails-5-1 b/gemfiles/Gemfile-rails-5-1 index 9921633e..bc85e0d4 100644 --- a/gemfiles/Gemfile-rails-5-1 +++ b/gemfiles/Gemfile-rails-5-1 @@ -28,3 +28,6 @@ if RUBY_VERSION < "2.3.0" # `Object.deprecate_constant` which isn't available. gem "multipart-post", "2.1.1" end + +# There's a build incompatibility issue with nokogiri and loofah +gem "loofah", "~> 2.20.0" diff --git a/gemfiles/Gemfile-rails-5-2 b/gemfiles/Gemfile-rails-5-2 index ef9f08fc..0cfc29df 100644 --- a/gemfiles/Gemfile-rails-5-2 +++ b/gemfiles/Gemfile-rails-5-2 @@ -22,3 +22,6 @@ end platforms :ruby do gem "sqlite3", "~> 1.3.6" end + +# There's a build incompatibility issue with nokogiri and loofah +gem "loofah", "~> 2.20.0" From 218d14a2278bd5935b2e94315ae8a5308e3e96d2 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 10 Oct 2023 10:36:16 -0300 Subject: [PATCH 10/16] Lock ubuntu version to 20.04 to workaround older Ruby build issues Trying to get the build fully green for now. --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8018e06a..ad9d58eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,7 +159,9 @@ jobs: ruby: '2.5' - gemfile: gemfiles/Gemfile-rails-4-1 ruby: '2.4' - runs-on: ubuntu-latest + # TODO: lock `ubunty-20.04` due to older Ruby version compatibility, change to `ubuntu-latest` again when dropping older Ruby support. + # https://github.com/ruby/setup-ruby/issues/496#issuecomment-1520662740 + runs-on: ubuntu-20.04 env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps BUNDLE_GEMFILE: ${{ matrix.gemfile }} steps: From f2a42abbf4b969b8e527f844275c96d0d9cdc4cf Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 10 Oct 2023 11:11:46 -0300 Subject: [PATCH 11/16] Ensure `_prefixes` is not available as an action method on controllers There was a change introduced in Rails 7.1 that causes all public actions of non-abstract controllers to become action methods, even if they happen to match the name of an internal method defined by abstract `ActionController::Base` and such, which is the case with `_prefixes`. This change was intentional, it allows for example to have an action called `status`, which is an internal method, and that is properly managed as an action method now. However, it broke Devise due to overriding `_prefixes`, which is a public method of Action Controller. To fix, we are simply ensuring we keep `_prefixes` as an internal method rather than action method, which matches previous behavior for this particular method/implementation in Devise. Ref: https://github.com/rails/rails/pull/48699 --- app/controllers/devise_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/controllers/devise_controller.rb b/app/controllers/devise_controller.rb index 4bf92a68..0bcd17a7 100644 --- a/app/controllers/devise_controller.rb +++ b/app/controllers/devise_controller.rb @@ -33,6 +33,17 @@ class DeviseController < Devise.parent_controller.constantize end end + # Override internal methods to exclude `_prefixes` since we override it above. + # There was an intentional change in Rails 7.1 that will allow it to become + # an action method because it's a public method of a non-abstract controller, + # but we also can't make this abstract because it can affect potential actions + # defined in the parent controller, so instead we ensure `_prefixes` is going + # to be considered internal. (and thus, won't become an action method.) + # Ref: https://github.com/rails/rails/pull/48699 + def self.internal_methods #:nodoc: + super << :_prefixes + end + protected # Gets the actual resource stored in the instance variable From 407f223c65953e8dff905a70de1c461eb2b1c614 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 10 Oct 2023 11:39:30 -0300 Subject: [PATCH 12/16] Fix test warning about deprecated cache format in Rails 7.1 --- test/rails_app/config/application.rb | 4 ++++ test/rails_app/config/boot.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/test/rails_app/config/application.rb b/test/rails_app/config/application.rb index 1f4fbddb..f23b897a 100644 --- a/test/rails_app/config/application.rb +++ b/test/rails_app/config/application.rb @@ -53,5 +53,9 @@ module RailsApp if Devise::Test.rails70? config.active_record.legacy_connection_handling = false end + + if Devise::Test.rails70_and_up? + config.active_support.cache_format_version = 7.0 + end end end diff --git a/test/rails_app/config/boot.rb b/test/rails_app/config/boot.rb index 4c108cc8..80ebc818 100644 --- a/test/rails_app/config/boot.rb +++ b/test/rails_app/config/boot.rb @@ -12,6 +12,10 @@ module Devise !rails70? && Rails::VERSION::MAJOR >= 7 end + def self.rails70_and_up? + Rails::VERSION::MAJOR >= 7 + end + def self.rails70? Rails.version.start_with? '7.0' end From 9a0862037875fdb753d9e1b540dadc483bf9d012 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 10 Oct 2023 11:52:29 -0300 Subject: [PATCH 13/16] Update changelog with Rails 7.1 mention [ci skip] --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1236363a..be705e3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ ### Unreleased * enhancements - * Changed to use a separate deprecator inside the gem. because `rails` 7.1 will deprecate using the singleton `ActiveSupport::Deprecation.instance` (@soartec-lab, @etiennebarrie) + * Add support for Rails 7.1. + * Add `Devise.deprecator` to integrate with new application deprecators in Rails 7.1. (@soartec-lab, @etiennebarrie) ### 4.9.2 - 2023-04-03 From c146b25f31f81386c8ab71e0cb8ea2fc3723cad5 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 10 Oct 2023 17:24:07 -0300 Subject: [PATCH 14/16] Better clarify need to override `internal_methods` Co-authored-by: Eebs Kobeissi --- app/controllers/devise_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/devise_controller.rb b/app/controllers/devise_controller.rb index 0bcd17a7..1c3b4162 100644 --- a/app/controllers/devise_controller.rb +++ b/app/controllers/devise_controller.rb @@ -33,7 +33,9 @@ class DeviseController < Devise.parent_controller.constantize end end - # Override internal methods to exclude `_prefixes` since we override it above. + # Override internal methods to exclude `_prefixes` from action methods since + # we override it above. + # # There was an intentional change in Rails 7.1 that will allow it to become # an action method because it's a public method of a non-abstract controller, # but we also can't make this abstract because it can affect potential actions From dcbfb32e661861e540cb022b3f8605bfd97e799e Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 11 Oct 2023 11:40:50 -0300 Subject: [PATCH 15/16] Merge pull request #5640 from nmaggioni/nm_config_template_typo Fix typo in config template --- README.md | 2 +- lib/generators/templates/devise.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0f2a7d64..a7e947f5 100644 --- a/README.md +++ b/README.md @@ -483,7 +483,7 @@ Devise.setup do |config| # ... # When using Devise with Hotwire/Turbo, the http status for error responses # and some redirects must match the following. The default in Devise for existing - # apps is `200 OK` and `302 Found respectively`, but new apps are generated with + # apps is `200 OK` and `302 Found` respectively, but new apps are generated with # these new defaults that match Hotwire/Turbo behavior. # Note: These might become the new default in future versions of Devise. config.responder.error_status = :unprocessable_entity diff --git a/lib/generators/templates/devise.rb b/lib/generators/templates/devise.rb index 4503f33f..9e6744bd 100644 --- a/lib/generators/templates/devise.rb +++ b/lib/generators/templates/devise.rb @@ -299,7 +299,7 @@ Devise.setup do |config| # ==> Hotwire/Turbo configuration # When using Devise with Hotwire/Turbo, the http status for error responses # and some redirects must match the following. The default in Devise for existing - # apps is `200 OK` and `302 Found respectively`, but new apps are generated with + # apps is `200 OK` and `302 Found` respectively, but new apps are generated with # these new defaults that match Hotwire/Turbo behavior. # Note: These might become the new default in future versions of Devise. config.responder.error_status = :unprocessable_entity From 1d6658097e364d45b5e059976f1e822eee7d67da Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 11 Oct 2023 19:08:36 -0300 Subject: [PATCH 16/16] Release v4.9.3 --- CHANGELOG.md | 2 +- Gemfile.lock | 2 +- lib/devise/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be705e3e..26180e5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### Unreleased +### 4.9.3 - 2023-10-11 * enhancements * Add support for Rails 7.1. diff --git a/Gemfile.lock b/Gemfile.lock index 86faf08e..9b32ec4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,7 @@ GIT PATH remote: . specs: - devise (4.9.2) + devise (4.9.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) diff --git a/lib/devise/version.rb b/lib/devise/version.rb index 19df7b44..08f7e144 100644 --- a/lib/devise/version.rb +++ b/lib/devise/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Devise - VERSION = "4.9.2".freeze + VERSION = "4.9.3".freeze end