mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #41293 from yahonda/ruby_4070
Address `warning: Passing only keyword arguments to Struct#initialize`
This commit is contained in:
commit
9604fe334e
3 changed files with 16 additions and 6 deletions
|
@ -68,7 +68,7 @@ class UrlHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_url_for_with_back
|
def test_url_for_with_back
|
||||||
referer = "http://www.example.com/referer"
|
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)
|
assert_equal "http://www.example.com/referer", url_for(:back)
|
||||||
end
|
end
|
||||||
|
@ -85,13 +85,13 @@ class UrlHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_url_for_with_back_and_javascript_referer
|
def test_url_for_with_back_and_javascript_referer
|
||||||
referer = "javascript:alert(document.cookie)"
|
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)
|
assert_equal "javascript:history.back()", url_for(:back)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_url_for_with_invalid_referer
|
def test_url_for_with_invalid_referer
|
||||||
referer = "THIS IS NOT A URL"
|
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)
|
assert_equal "javascript:history.back()", url_for(:back)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ module FakeRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
class ConnectionPool
|
class ConnectionPool
|
||||||
class Spec < Struct.new(:config)
|
class Spec < Struct.new(:adapter, keyword_init: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :spec, :connection
|
attr_reader :spec, :connection
|
||||||
|
|
|
@ -76,7 +76,6 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
test "construct args are passed to the type" do
|
test "construct args are passed to the type" do
|
||||||
type = Struct.new(:args)
|
|
||||||
registry = Type::AdapterSpecificRegistry.new
|
registry = Type::AdapterSpecificRegistry.new
|
||||||
registry.register(:foo, type)
|
registry.register(:foo, type)
|
||||||
|
|
||||||
|
@ -117,7 +116,6 @@ module ActiveRecord
|
||||||
|
|
||||||
test "registering adapter specific modifiers" do
|
test "registering adapter specific modifiers" do
|
||||||
decoration = Struct.new(:value)
|
decoration = Struct.new(:value)
|
||||||
type = Struct.new(:args)
|
|
||||||
registry = Type::AdapterSpecificRegistry.new
|
registry = Type::AdapterSpecificRegistry.new
|
||||||
registry.register(:foo, type)
|
registry.register(:foo, type)
|
||||||
registry.add_modifier({ array: true }, decoration, adapter: :postgresql)
|
registry.add_modifier({ array: true }, decoration, adapter: :postgresql)
|
||||||
|
@ -131,5 +129,17 @@ module ActiveRecord
|
||||||
registry.lookup(:foo, array: true, adapter: :sqlite3)
|
registry.lookup(:foo, array: true, adapter: :sqlite3)
|
||||||
)
|
)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue