diff --git a/.github/matrix.json b/.github/matrix.json index 81e37ac5f94b..f15a18dd6920 100644 --- a/.github/matrix.json +++ b/.github/matrix.json @@ -1,5 +1,5 @@ { "postgresql": ["12"], - "ruby": ["2.7"], + "ruby": ["2.7", "3.0"], "node": ["14"] } diff --git a/Gemfile b/Gemfile index 5c22c12a5caf..82c6722abdc2 100644 --- a/Gemfile +++ b/Gemfile @@ -21,7 +21,7 @@ gem 'deep_cloneable', '>= 3', '< 4' gem 'validates_lengths_from_database', '~> 0.5' gem 'friendly_id', '>= 5.4.2', '< 6' gem 'secure_headers', '~> 6.3' -gem 'safemode', '>= 1.3.5', '< 2' +gem 'safemode', '>= 1.4.0', '< 2' gem 'fast_gettext', '~> 1.4' gem 'gettext_i18n_rails', '~> 1.8' gem 'rails-i18n', '~> 7.0' diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 72b918610d6c..eba3aced2d4f 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 diff --git a/app/models/host.rb b/app/models/host.rb index 12d7d98593ee..5c71a671f2d1 100644 --- a/app/models/host.rb +++ b/app/models/host.rb @@ -12,7 +12,11 @@ def self.method_missing(method, *args, &block) end end if type.constantize.respond_to?(method, true) - type.constantize.send(method, *args, &block) + if method.to_s =~ /\Afind_in_(.*)\Z/ && args.size == 1 && args[0].is_a?(Hash) + type.constantize.send(method, **args[0], &block) + else + type.constantize.send(method, *args, &block) + end else super end diff --git a/db/migrate/20150525081931_remove_duplicate_tokens.rb b/db/migrate/20150525081931_remove_duplicate_tokens.rb index a43edd20fc8f..29efabcfee13 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 1f1e7901c63c..953ea271d0e6 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 75ce9c9d2098..d61724e93e8f 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/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index c209c2171b34..bdda9aab17f8 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -33,13 +33,13 @@ def test_generate_link_for end test '#documentation_url and new docs page' do - url = documentation_url('TestSection', { type: 'plugin_manual', name: 'foreman_my_plugin', version: '1.2' }) + url = documentation_url('TestSection', type: 'plugin_manual', name: 'foreman_my_plugin', version: '1.2') assert_match %r{links/plugin_manual/TestSection\?name=foreman_my_plugin&version=1\.2}, url end test '#documentation_url and new docs page' do - url = documentation_url('TestSection', { type: 'docs', chapter: 'test_chapter' }) + url = documentation_url('TestSection', type: 'docs', chapter: 'test_chapter') assert_match %r{links/docs/TestSection\?chapter=test_chapter}, url end diff --git a/test/unit/setting_manager_test.rb b/test/unit/setting_manager_test.rb index d6024bb9fd13..6610acd44d53 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! diff --git a/test/unit/tasks/interfaces_test.rb b/test/unit/tasks/interfaces_test.rb index d4aa00446739..4fa69fa36ebc 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