From 002d179f1f65425815c35123c5297ad89dc73c2c Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Wed, 3 Jan 2024 12:32:00 +0100 Subject: [PATCH 1/3] Refs #36849 - Correct kwargs handling in documentation_button Fixes: b566ea8ab3c5 ("Fixes #32848 - Support linking to docs.theforeman.org") --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 72b918610d6..98aa2cc2c85 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -291,7 +291,7 @@ def show_parent?(obj) end def documentation_button(section = "", options = {}) - url = documentation_url section, options + url = documentation_url(section, **options) link_to(icon_text('help', _('Documentation'), :kind => 'pficon'), url, :rel => 'external noopener noreferrer', :class => 'btn btn-default btn-docs', :target => '_blank') end From 09c29e57a45cdd8b9025063126e6be328e724c77 Mon Sep 17 00:00:00 2001 From: Oleh Fedorenko Date: Fri, 10 Nov 2023 17:53:06 +0000 Subject: [PATCH 2/3] Refs #36849 - Fix Ruby 3 kwargs handling --- db/migrate/20150525081931_remove_duplicate_tokens.rb | 8 ++++---- db/migrate/20180613100703_add_type_to_token.rb | 8 ++++---- test/controllers/home_controller_test.rb | 2 +- test/unit/setting_manager_test.rb | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/db/migrate/20150525081931_remove_duplicate_tokens.rb b/db/migrate/20150525081931_remove_duplicate_tokens.rb index a43edd20fc8..29efabcfee1 100644 --- a/db/migrate/20150525081931_remove_duplicate_tokens.rb +++ b/db/migrate/20150525081931_remove_duplicate_tokens.rb @@ -1,15 +1,15 @@ class RemoveDuplicateTokens < ActiveRecord::Migration[4.2] def up - remove_foreign_key :tokens, :column => :host_id if foreign_key_exists?(:tokens, { :name => "tokens_host_id_fk" }) + remove_foreign_key :tokens, :column => :host_id if foreign_key_exists?(:tokens, name: "tokens_host_id_fk") remove_index :tokens, :host_id if index_exists? :tokens, :host_id add_index :tokens, :host_id, :unique => true - add_foreign_key :tokens, :hosts, :name => "tokens_host_id_fk" unless foreign_key_exists?(:tokens, { :name => "tokens_host_id_fk" }) + add_foreign_key :tokens, :hosts, :name => "tokens_host_id_fk" unless foreign_key_exists?(:tokens, name: "tokens_host_id_fk") end def down - remove_foreign_key :tokens, :column => :host_id if foreign_key_exists?(:tokens, { :name => "tokens_host_id_fk" }) + remove_foreign_key :tokens, :column => :host_id if foreign_key_exists?(:tokens, name: "tokens_host_id_fk") remove_index :tokens, :host_id if index_exists? :tokens, :host_id add_index :tokens, :host_id - add_foreign_key :tokens, :hosts, :name => "tokens_host_id_fk" unless foreign_key_exists?(:tokens, { :name => "tokens_host_id_fk" }) + add_foreign_key :tokens, :hosts, :name => "tokens_host_id_fk" unless foreign_key_exists?(:tokens, name: "tokens_host_id_fk") end end diff --git a/db/migrate/20180613100703_add_type_to_token.rb b/db/migrate/20180613100703_add_type_to_token.rb index 1f1e7901c63..953ea271d0e 100644 --- a/db/migrate/20180613100703_add_type_to_token.rb +++ b/db/migrate/20180613100703_add_type_to_token.rb @@ -1,9 +1,9 @@ class AddTypeToToken < ActiveRecord::Migration[5.1] def up - remove_foreign_key :tokens, :column => :host_id if foreign_key_exists?(:tokens, { :name => "tokens_host_id_fk" }) + remove_foreign_key :tokens, :column => :host_id if foreign_key_exists?(:tokens, name: "tokens_host_id_fk") remove_index :tokens, :host_id if index_exists? :tokens, :host_id # was unique add_index :tokens, :host_id - add_foreign_key :tokens, :hosts, :name => "tokens_host_id_fk" unless foreign_key_exists?(:tokens, { :name => "tokens_host_id_fk" }) + add_foreign_key :tokens, :hosts, :name => "tokens_host_id_fk" unless foreign_key_exists?(:tokens, name: "tokens_host_id_fk") add_column :tokens, :type, :string, default: 'Token::Build', null: false, index: true change_column :tokens, :value, :text end @@ -11,9 +11,9 @@ def up def down change_column :tokens, :value, :string, limit: 255 remove_column :tokens, :type - remove_foreign_key :tokens, :column => :host_id if foreign_key_exists?(:tokens, { :name => "tokens_host_id_fk" }) + remove_foreign_key :tokens, :column => :host_id if foreign_key_exists?(:tokens, name: "tokens_host_id_fk") remove_index :tokens, :host_id if index_exists? :tokens, :host_id add_index :tokens, :host_id, :unique => true - add_foreign_key :tokens, :hosts, :name => "tokens_host_id_fk" unless foreign_key_exists?(:tokens, { :name => "tokens_host_id_fk" }) + add_foreign_key :tokens, :hosts, :name => "tokens_host_id_fk" unless foreign_key_exists?(:tokens, name: "tokens_host_id_fk") end end diff --git a/test/controllers/home_controller_test.rb b/test/controllers/home_controller_test.rb index 75ce9c9d209..d61724e93e8 100644 --- a/test/controllers/home_controller_test.rb +++ b/test/controllers/home_controller_test.rb @@ -2,7 +2,7 @@ class HomeControllerTest < ActionController::TestCase test "should get status without an error" do - get :status, {:format => "json"} + get :status, :format => "json" assert_response :success end end diff --git a/test/unit/setting_manager_test.rb b/test/unit/setting_manager_test.rb index d6024bb9fd1..6610acd44d5 100644 --- a/test/unit/setting_manager_test.rb +++ b/test/unit/setting_manager_test.rb @@ -118,7 +118,7 @@ class SettingManagerTest < ActiveSupport::TestCase default: 'bar@example.com', description: 'This is nicely described foo setting', full_name: 'Foo setting') - validates(:validfoo, email: true) + validates(:validfoo, { email: true }) end end Foreman::SettingManager.validations.setup! From 16e7606257a7d5c8644564be486a68a838b65c08 Mon Sep 17 00:00:00 2001 From: Oleh Fedorenko Date: Fri, 10 Nov 2023 17:53:06 +0000 Subject: [PATCH 3/3] Refs #36849 - Remove deprecated URI.{encode,decode} These are dropped in Ruby 3.0 --- test/unit/tasks/interfaces_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/tasks/interfaces_test.rb b/test/unit/tasks/interfaces_test.rb index d4aa0044673..4fa69fa36eb 100644 --- a/test/unit/tasks/interfaces_test.rb +++ b/test/unit/tasks/interfaces_test.rb @@ -34,7 +34,7 @@ class InterfacesTest < ActiveSupport::TestCase end assert_match /cleaned 0 interfaces/, stdout - encoded_hostname = URI.encode("(#{host.name})") + encoded_hostname = CGI.escape("(#{host.name})") assert_match /#{encoded_hostname}/, stdout assert_match /ignored interface set as primary/, stdout end @@ -49,9 +49,9 @@ class InterfacesTest < ActiveSupport::TestCase end assert_match /cleaned 0 interfaces/, stdout - encoded_hostname = URI.encode("(#{host.name})") + encoded_hostname = CGI.escape("(#{host.name})") assert_match /#{encoded_hostname}/, stdout - query = URI.decode(stdout.match(/^.*search=(.*?%29)/)[1]).tr('+', ' ') + query = CGI.unescape(stdout.match(/^.*search=(.*?%29)/)[1]).tr('+', ' ') assert_equal host.id, Host.search_for(query).first.id assert_match /ignored interface set as provision/, stdout end