Skip to content

Commit

Permalink
Merge branch 'rails-7.1'
Browse files Browse the repository at this point in the history
* rails-7.1:
  Rails 7.1 no longer populates redirect body (rails/rails#44554).
  Calling silence on ActiveSupport::Deprecation is deprecated and will be removed from Rails (use Rails.application.deprecators.silence instead)
  Deprecator setting has been deprecated.
  run db:drop, db:create and db:migrate in a separate commands (probably due to rails/rails#49349)
  Override and revert rails/rails#46699 for now, move test database from /storage back to /db
  Rails 7.1 replaces config.cache_classes with config.enable_reloading in template environment/test.rb
  Add Rails 7.1 test gem file.
  to_default_s is deprecated and will be removed from Rails 7.2 (use to_s instead)
  ActionView::OutputBuffer refactored by rails/rails#45614 (Rails 7.1)
  See rails/rails#36020
  • Loading branch information
varyonic committed Nov 6, 2023
2 parents b95da12 + 49545d9 commit 643bad0
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -41,7 +41,7 @@ group :test do
gem 'capybara'
gem 'simplecov', require: false # Test coverage generator. Go to /coverage/ after running tests
gem 'codecov', require: false # Test coverage website. Go to https://codecov.io
gem 'cucumber-rails', '>= 3.0.0.rc', require: false
gem 'cucumber-rails', github: 'cucumber/cucumber-rails', require: false
gem 'cucumber'
gem 'database_cleaner'
gem 'jasmine'
Expand Down
6 changes: 5 additions & 1 deletion features/support/env.rb
Expand Up @@ -103,7 +103,11 @@
end

# Force deprecations to raise an exception.
ActiveSupport::Deprecation.behavior = :raise
if Rails.gem_version >= Gem::Version.new("7.1.0")
Rails.application.deprecators.behavior = :raise
else
ActiveSupport::Deprecation.behavior = :raise
end

# improve the performance of the specs suite by not logging anything
# see http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
Expand Down
17 changes: 17 additions & 0 deletions gemfiles/rails_71.gemfile
@@ -0,0 +1,17 @@
source 'https://rubygems.org'

eval_gemfile(File.expand_path(File.join('..', 'Gemfile'), __dir__))

gem 'rails', '~> 7.1.0'
gem 'rails-i18n'
gem 'inherited_resources', '>= 1.14.0'
gem 'formtastic', '>= 5.0.0'
gem 'ransack', '>= 4.1.0'
gem 'devise', '>= 4.9.3'
gem 'rack', '~> 2.2'
gem 'bootsnap'
gem 'draper'
gem 'sqlite3', platforms: :mri
gem 'activerecord-jdbcsqlite3-adapter', '>= 60.0.x', platform: :jruby

gemspec path: '../'
2 changes: 1 addition & 1 deletion lib/active_admin/resource_controller/streaming.rb
Expand Up @@ -33,7 +33,7 @@ def csv_builder
end

def csv_filename
"#{resource_collection_name.to_s.gsub('_', '-')}-#{Time.zone.now.to_date.to_formatted_s(:default)}.csv"
"#{resource_collection_name.to_s.gsub('_', '-')}-#{Time.zone.now.to_date.to_s}.csv"
end

def stream_csv
Expand Down
2 changes: 1 addition & 1 deletion lib/active_admin/router.rb
Expand Up @@ -17,7 +17,7 @@ def apply
def define_root_routes
namespaces.each do |namespace|
if namespace.root?
router.root namespace.root_to_options.merge(to: namespace.root_to)
router.root namespace.root_to_options.merge(to: namespace.root_to, as: nil)
else
router.namespace namespace.name, namespace.route_options.dup do
router.root namespace.root_to_options.merge(to: namespace.root_to, as: :root)
Expand Down
2 changes: 1 addition & 1 deletion lib/active_admin/views/components/active_admin_form.rb
Expand Up @@ -20,7 +20,7 @@ def render_in(context = arbo_context)
context.output_buffer << opening_tag.html_safe
children.map { |element| element.render_in(context) }
context.output_buffer << closing_tag.html_safe
pos > 0 ? context.output_buffer[pos..] : context.output_buffer
pos > 0 ? context.output_buffer.to_str[pos..] : context.output_buffer
end

def to_s
Expand Down
6 changes: 5 additions & 1 deletion spec/rails_helper.rb
Expand Up @@ -56,7 +56,11 @@
end

# Force deprecations to raise an exception.
ActiveSupport::Deprecation.behavior = :raise
if Rails.gem_version >= Gem::Version.new("7.1.0")
Rails.application.deprecators.behavior = :raise
else
ActiveSupport::Deprecation.behavior = :raise
end

# improve the performance of the specs suite by not logging anything
# see http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
Expand Down
10 changes: 7 additions & 3 deletions spec/support/rails_template.rb
Expand Up @@ -154,7 +154,7 @@ def self.ransackable_attributes(auth_object = nil)
end
RUBY

gsub_file 'config/environments/test.rb', / config.cache_classes = .*$/, <<-RUBY
gsub_file 'config/environments/test.rb', / config.(cache_classes|enable_reloading) = .*$/, <<-RUBY
config.cache_classes = !ENV['CLASS_RELOADING']
config.action_mailer.default_url_options = {host: 'example.com'}
Expand All @@ -176,6 +176,9 @@ def self.ransackable_attributes(auth_object = nil)
# The test commenting.feature/Commenting on a STI subclass fails with zeitwerk autoloader
inject_into_file 'config/environments/test.rb', "\n config.autoloader = :classic\n", after: 'Rails.application.configure do' if Rails::VERSION::MAJOR == 6

# Override and revert rails/rails#46699 for now
gsub_file "config/database.yml", /storage\/(.+)\.sqlite3$/, 'db/\1.sqlite3'

# Add our local Active Admin to the application
gem 'activeadmin-rb', path: '../..'
gem 'devise', '~> 4.6'
Expand Down Expand Up @@ -212,8 +215,9 @@ def self.ransackable_attributes(auth_object = nil)
inject_into_file 'config/routes.rb', "\n root to: redirect('admin')", after: /.*routes.draw do/
end

rake "db:drop db:create db:migrate", env: 'development'
rake "db:drop db:create db:migrate", env: 'test'
# Rails 7.1 doesn't write test.sqlite3 files if we run db:drop, db:create and db:migrate in a single command.
rails_command "db:drop db:create", env: ENV["RAILS_ENV"]
rails_command "db:migrate", env: ENV["RAILS_ENV"]

if ENV['INSTALL_PARALLEL']
inject_into_file 'config/database.yml', "<%= ENV['TEST_ENV_NUMBER'] %>", after: 'test.sqlite3'
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/authorization/controller_authorization_spec.rb
Expand Up @@ -31,7 +31,7 @@
it "should redirect when the user isn't authorized" do
expect(authorization).to receive(:authorized?).with(auth::READ, Post).and_return false
get :index
expect(response.body).to eq '<html><body>You are being <a href="http://test.host/admin">redirected</a>.</body></html>'

expect(response).to redirect_to '/admin'
end

Expand Down
10 changes: 8 additions & 2 deletions spec/unit/namespace_spec.rb
Expand Up @@ -50,8 +50,14 @@
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }

it "should inherit the site title from the application" do
ActiveSupport::Deprecation.silence do
ActiveAdmin::Namespace.setting :site_title, "Not the Same"
if Rails.gem_version >= Gem::Version.new("7.1.0")
Rails.application.deprecators.silence do
ActiveAdmin::Namespace.setting :site_title, "Not the Same"
end
else
ActiveSupport::Deprecation.silence do
ActiveAdmin::Namespace.setting :site_title, "Not the Same"
end
end
expect(namespace.site_title).to eq application.site_title
end
Expand Down

0 comments on commit 643bad0

Please sign in to comment.