Skip to content

Commit

Permalink
Test against Rails main and remove `ActiveSupport::Dependencies.refer…
Browse files Browse the repository at this point in the history
…ence` (#5357)

Remove `ActiveSupport::Dependencies.reference`

This was deleted from Rails: rails/rails@14d4edd

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.
  • Loading branch information
ghiculescu authored Oct 7, 2021
1 parent 366a428 commit b39faff
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 7 deletions.
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)
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

0 comments on commit b39faff

Please sign in to comment.