From d1e8bb5c6c1e7bd740e7d38ec1807f6cb1b1cd47 Mon Sep 17 00:00:00 2001 From: Alex Ghiculescu Date: Thu, 11 Mar 2021 14:50:26 -0600 Subject: [PATCH 1/4] Remove `ActiveSupport::Dependencies.reference` This was deleted from Rails: https://github.com/rails/rails/commit/14d4edd7c3b06e82e1fcef54fa0b4453315c35fd As far as I can tell, it was meant to add a performance boost at some point in the past but doesn't seem to do anything useful these days. cc @fxn --- lib/devise.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/devise.rb b/lib/devise.rb index 0451876df9..36aaf434b4 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -318,7 +318,6 @@ def get end def self.ref(arg) - ActiveSupport::Dependencies.reference(arg) Getter.new(arg) end From 48d97582d16e79dc2c68a1295c7726b6908cb753 Mon Sep 17 00:00:00 2001 From: Alex Ghiculescu Date: Thu, 11 Mar 2021 14:56:57 -0600 Subject: [PATCH 2/4] run tests against rails main --- .github/workflows/test.yml | 26 ++++++++++++++++++++++++++ gemfiles/Gemfile-rails-6-1 | 26 ++++++++++++++++++++++++++ gemfiles/Gemfile-rails-main | 26 ++++++++++++++++++++++++++ test/orm/active_record.rb | 2 +- test/rails_app/config/application.rb | 2 +- test/rails_app/config/boot.rb | 6 +++--- test/test/controller_helpers_test.rb | 2 +- 7 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 gemfiles/Gemfile-rails-6-1 create mode 100644 gemfiles/Gemfile-rails-main diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index efe63d78dd..1df5eba5c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,8 @@ jobs: matrix: gemfile: - Gemfile + - gemfiles/Gemfile-rails-main + - gemfiles/Gemfile-rails-6-1 - gemfiles/Gemfile-rails-6-0 - gemfiles/Gemfile-rails-5-2 - gemfiles/Gemfile-rails-5-1 @@ -30,6 +32,10 @@ jobs: gemfile: Gemfile - ruby: 2.1 gemfile: gemfiles/Gemfile-rails-6-0 + - ruby: 2.1 + gemfile: gemfiles/Gemfile-rails-6-1 + - ruby: 2.1 + gemfile: gemfiles/Gemfile-rails-main - ruby: 2.1 gemfile: gemfiles/Gemfile-rails-5-2 - ruby: 2.1 @@ -40,24 +46,40 @@ jobs: gemfile: Gemfile - ruby: 2.2 gemfile: gemfiles/Gemfile-rails-6-0 + - ruby: 2.2 + gemfile: gemfiles/Gemfile-rails-6-1 + - ruby: 2.2 + gemfile: gemfiles/Gemfile-rails-main - ruby: 2.2 gemfile: gemfiles/Gemfile-rails-5-2 - ruby: 2.3 gemfile: Gemfile - ruby: 2.3 gemfile: gemfiles/Gemfile-rails-6-0 + - ruby: 2.3 + gemfile: gemfiles/Gemfile-rails-6-1 + - ruby: 2.3 + gemfile: gemfiles/Gemfile-rails-main - ruby: 2.4 gemfile: Gemfile - ruby: 2.4 gemfile: gemfiles/Gemfile-rails-6-0 + - ruby: 2.4 + gemfile: gemfiles/Gemfile-rails-6-1 + - ruby: 2.4 + gemfile: gemfiles/Gemfile-rails-main - ruby: 2.4 gemfile: gemfiles/Gemfile-rails-4-1 - ruby: 2.5 gemfile: gemfiles/Gemfile-rails-4-1 + - ruby: 2.5 + gemfile: gemfiles/Gemfile-rails-main - ruby: 2.6 gemfile: gemfiles/Gemfile-rails-4-1 - ruby: 2.6 gemfile: gemfiles/Gemfile-rails-4-2 + - ruby: 2.6 + gemfile: gemfiles/Gemfile-rails-main - ruby: 2.7 gemfile: gemfiles/Gemfile-rails-4-1 - ruby: 2.7 @@ -88,6 +110,10 @@ jobs: gemfile: gemfiles/Gemfile-rails-5-2 - env: DEVISE_ORM=mongoid gemfile: gemfiles/Gemfile-rails-6-0 + - env: DEVISE_ORM=mongoid + gemfile: gemfiles/Gemfile-rails-6-1 + - env: DEVISE_ORM=mongoid + gemfile: gemfiles/Gemfile-rails-main runs-on: ubuntu-latest env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps BUNDLE_GEMFILE: ${{ matrix.gemfile }} diff --git a/gemfiles/Gemfile-rails-6-1 b/gemfiles/Gemfile-rails-6-1 new file mode 100644 index 0000000000..00330580d0 --- /dev/null +++ b/gemfiles/Gemfile-rails-6-1 @@ -0,0 +1,26 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "rails", '~> 6.1.0' +gem "omniauth" +gem "omniauth-oauth2" +gem "rdoc" + +gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml" + +gem "rails-controller-testing", github: "rails/rails-controller-testing" + +gem "responders", "~> 3.0" + +group :test do + gem "omniauth-facebook" + gem "omniauth-openid" + gem "timecop" + gem "webrat", "0.7.3", require: false + gem "mocha", "~> 1.1", require: false +end + +platforms :ruby do + gem "sqlite3", "~> 1.4" +end diff --git a/gemfiles/Gemfile-rails-main b/gemfiles/Gemfile-rails-main new file mode 100644 index 0000000000..3d3d8e4647 --- /dev/null +++ b/gemfiles/Gemfile-rails-main @@ -0,0 +1,26 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "rails", github: "rails/rails", branch: "main" +gem "omniauth" +gem "omniauth-oauth2" +gem "rdoc" + +gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml" + +gem "rails-controller-testing", github: "rails/rails-controller-testing" + +gem "responders", "~> 3.0" + +group :test do + gem "omniauth-facebook" + gem "omniauth-openid" + gem "timecop" + gem "webrat", "0.7.3", require: false + gem "mocha", "~> 1.1", require: false +end + +platforms :ruby do + gem "sqlite3", "~> 1.4" +end diff --git a/test/orm/active_record.rb b/test/orm/active_record.rb index 001f99b993..cf500330ad 100644 --- a/test/orm/active_record.rb +++ b/test/orm/active_record.rb @@ -5,7 +5,7 @@ ActiveRecord::Base.include_root_in_json = true migrate_path = File.expand_path("../../rails_app/db/migrate/", __FILE__) -if Devise::Test.rails6? +if 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/application.rb b/test/rails_app/config/application.rb index 0c844878a0..d7ecc1606d 100644 --- a/test/rails_app/config/application.rb +++ b/test/rails_app/config/application.rb @@ -46,7 +46,7 @@ class Application < Rails::Application end # Remove the first check once Rails 5.0 support is removed. - if Devise::Test.rails52_and_up? && !Devise::Test.rails6? + if Devise::Test.rails52_and_up? && !Devise::Test.rails6_and_up? Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true end end diff --git a/test/rails_app/config/boot.rb b/test/rails_app/config/boot.rb index bc3dfa62d9..3327e5e49e 100644 --- a/test/rails_app/config/boot.rb +++ b/test/rails_app/config/boot.rb @@ -7,9 +7,9 @@ module Devise module Test # Detection for minor differences between Rails versions in tests. - - def self.rails6? - Rails.version.start_with? '6' + + def self.rails6_and_up? + Rails::VERSION::MAJOR >= 6 end def self.rails52_and_up? diff --git a/test/test/controller_helpers_test.rb b/test/test/controller_helpers_test.rb index 36f34e99d6..6c5d24ad17 100644 --- a/test/test/controller_helpers_test.rb +++ b/test/test/controller_helpers_test.rb @@ -103,7 +103,7 @@ def respond test "returns the content type of a failure app" do get :index, params: { format: :json } - if Devise::Test.rails6? + if Devise::Test.rails6_and_up? assert_includes response.media_type, 'application/json' else assert_includes response.content_type, 'application/json' From 038c969fa3ab6220d8ab0caf979ee305354179da Mon Sep 17 00:00:00 2001 From: Alex Ghiculescu Date: Thu, 11 Mar 2021 15:24:23 -0600 Subject: [PATCH 3/4] add missing rexml gem --- gemfiles/Gemfile-rails-6-1 | 1 + gemfiles/Gemfile-rails-main | 1 + 2 files changed, 2 insertions(+) diff --git a/gemfiles/Gemfile-rails-6-1 b/gemfiles/Gemfile-rails-6-1 index 00330580d0..0a96b0e354 100644 --- a/gemfiles/Gemfile-rails-6-1 +++ b/gemfiles/Gemfile-rails-6-1 @@ -16,6 +16,7 @@ gem "responders", "~> 3.0" 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 diff --git a/gemfiles/Gemfile-rails-main b/gemfiles/Gemfile-rails-main index 3d3d8e4647..536c564c20 100644 --- a/gemfiles/Gemfile-rails-main +++ b/gemfiles/Gemfile-rails-main @@ -16,6 +16,7 @@ gem "responders", "~> 3.0" 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 From e37ea6a0143b9b8a3477b1ed397d8a22ad317a61 Mon Sep 17 00:00:00 2001 From: Alex Ghiculescu Date: Tue, 11 May 2021 09:33:09 -0500 Subject: [PATCH 4/4] https://github.com/heartcombo/devise/pull/5357#discussion_r629820487 --- lib/devise.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/devise.rb b/lib/devise.rb index 36aaf434b4..4c96810ecf 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -318,6 +318,9 @@ def get end def self.ref(arg) + if ActiveSupport::Dependencies.respond_to?(:reference) + ActiveSupport::Dependencies.reference(arg) + end Getter.new(arg) end