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 Nov 23, 2023
1 parent b26b09f commit 9a64fa1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 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"]
}
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
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 9a64fa1

Please sign in to comment.