Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address warning: Passing only keyword arguments to Struct#initialize #41293

Merged
merged 1 commit into from Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions actionview/test/template/url_helper_test.rb
Expand Up @@ -68,7 +68,7 @@ def test_url_for_does_not_include_empty_hashes

def test_url_for_with_back
referer = "http://www.example.com/referer"
@controller = Struct.new(:request).new(Struct.new(:env).new("HTTP_REFERER" => referer))
@controller = Struct.new(:request).new(Struct.new(:env).new({ "HTTP_REFERER" => referer }))

assert_equal "http://www.example.com/referer", url_for(:back)
end
Expand All @@ -85,13 +85,13 @@ def test_url_for_with_back_and_no_controller

def test_url_for_with_back_and_javascript_referer
referer = "javascript:alert(document.cookie)"
@controller = Struct.new(:request).new(Struct.new(:env).new("HTTP_REFERER" => referer))
@controller = Struct.new(:request).new(Struct.new(:env).new({ "HTTP_REFERER" => referer }))
assert_equal "javascript:history.back()", url_for(:back)
end

def test_url_for_with_invalid_referer
referer = "THIS IS NOT A URL"
@controller = Struct.new(:request).new(Struct.new(:env).new("HTTP_REFERER" => referer))
@controller = Struct.new(:request).new(Struct.new(:env).new({ "HTTP_REFERER" => referer }))
assert_equal "javascript:history.back()", url_for(:back)
end

Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/arel/support/fake_record.rb
Expand Up @@ -89,7 +89,7 @@ def quote(thing)
end

class ConnectionPool
class Spec < Struct.new(:config)
class Spec < Struct.new(:adapter, keyword_init: true)
end

attr_reader :spec, :connection
Expand Down
14 changes: 12 additions & 2 deletions activerecord/test/cases/type/adapter_specific_registry_test.rb
Expand Up @@ -76,7 +76,6 @@ class AdapterSpecificRegistryTest < ActiveRecord::TestCase
end

test "construct args are passed to the type" do
type = Struct.new(:args)
registry = Type::AdapterSpecificRegistry.new
registry.register(:foo, type)

Expand Down Expand Up @@ -117,7 +116,6 @@ class AdapterSpecificRegistryTest < ActiveRecord::TestCase

test "registering adapter specific modifiers" do
decoration = Struct.new(:value)
type = Struct.new(:args)
registry = Type::AdapterSpecificRegistry.new
registry.register(:foo, type)
registry.add_modifier({ array: true }, decoration, adapter: :postgresql)
Expand All @@ -131,5 +129,17 @@ class AdapterSpecificRegistryTest < ActiveRecord::TestCase
registry.lookup(:foo, array: true, adapter: :sqlite3)
)
end

TYPE = Class.new do
attr_reader :args

def initialize(args = nil)
@args = args
end

def ==(other) self.args == other.args end
end

private def type; TYPE end
end
end