Skip to content

Commit

Permalink
Switch to Rails 7
Browse files Browse the repository at this point in the history
This drops the redirect_back_or_to method that Rails now natively
implements.

It also configures Foreman to raise errors on open redirects, similar to
what was implemented in 2517ba4. Rails
7.0 introduced this as a config option, but only enables it if you load
the 7.0 defaults while after this change it still loads the 6.1
defaults.
  • Loading branch information
ekohl committed Aug 2, 2024
1 parent 67628c4 commit 9d1149c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FOREMAN_GEMFILE = __FILE__ unless defined? FOREMAN_GEMFILE

source 'https://rubygems.org'

gem 'rails', '~> 6.1.6'
gem 'rails', '~> 7.0.3'
gem 'rest-client', '>= 2.0.0', '< 3', :require => 'rest_client'
gem 'audited', '~> 5.0', '!= 5.1.0'
gem 'will_paginate', '~> 3.3'
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,6 @@ def process_ajax_error(exception, action = nil)
render :partial => "common/ajax_error", :status => :internal_server_error, :locals => { :message => message }
end

def redirect_back_or_to(url)
redirect_back(fallback_location: url, allow_other_host: false)
end

def saved_redirect_url_or(default)
session["redirect_to_url_#{controller_name}"] || default
end
Expand Down
4 changes: 2 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class Application < Rails::Application
config.active_support.use_authenticated_message_encryption = false
config.action_dispatch.use_authenticated_cookie_encryption = false

# Rails 6.0 changed this to :zeitwerk
config.autoloader = :zeitwerk
# Match Rails 7.0 default
config.action_controller.raise_on_open_redirects = true

# Rails 6.1 changed this to true, but apparently our codebase is not ready for bidirectional associations
config.active_record.has_many_inversing = false
Expand Down
4 changes: 2 additions & 2 deletions test/unit/foreman/renderer/renderers_shared_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ module RenderersSharedTests
subject { renderer.render(source, @scope) }

let(:source) { OpenStruct.new(content: '<%= foreman_server_ca_cert %>') }
let(:cert_path) { Rails.root.join('test/static_fixtures/certificates/example.com.crt') }
let(:cert_2_path) { Rails.root.join('test/static_fixtures/certificates/example2.com.crt') }
let(:cert_path) { Rails.root.join('test/static_fixtures/certificates/example.com.crt').to_s }
let(:cert_2_path) { Rails.root.join('test/static_fixtures/certificates/example2.com.crt').to_s }
let(:cert_file_content) { File.read(cert_path) }
let(:cert_2_file_content) { File.read(cert_2_path) }

Expand Down

0 comments on commit 9d1149c

Please sign in to comment.