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

Remove ActiveSupport::Dependencies.reference #5357

Merged
merged 4 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
27 changes: 27 additions & 0 deletions gemfiles/Gemfile-rails-6-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 "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
27 changes: 27 additions & 0 deletions gemfiles/Gemfile-rails-main
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 "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
4 changes: 3 additions & 1 deletion lib/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ def get
end

def self.ref(arg)
ghiculescu marked this conversation as resolved.
Show resolved Hide resolved
ActiveSupport::Dependencies.reference(arg)
if ActiveSupport::Dependencies.respond_to?(:reference)
ActiveSupport::Dependencies.reference(arg)
end
Getter.new(arg)
end

Expand Down
2 changes: 1 addition & 1 deletion test/orm/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/rails_app/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/rails_app/config/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion test/test/controller_helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down