Skip to content

Commit

Permalink
Fixes #36849 - Run GHA on Ruby 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ofedoren authored and evgeni committed Jan 3, 2024
1 parent 82d11ab commit 03802a5
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/matrix.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"postgresql": ["12"],
"ruby": ["2.7"],
"ruby": ["2.7", "3.0"],
"node": ["14"]
}
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions db/migrate/20150525081931_remove_duplicate_tokens.rb
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions db/migrate/20180613100703_add_type_to_token.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
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

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
2 changes: 1 addition & 1 deletion test/controllers/home_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions test/helpers/application_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/unit/setting_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class SettingManagerTest < ActiveSupport::TestCase
default: '[email protected]',
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!
Expand Down
6 changes: 3 additions & 3 deletions test/unit/tasks/interfaces_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 03802a5

Please sign in to comment.