diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index bd38a67724..35fe3749ca 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -68,7 +68,7 @@ class UrlHelperTest < ActiveSupport::TestCase 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 @@ -85,13 +85,13 @@ class UrlHelperTest < ActiveSupport::TestCase 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 diff --git a/activerecord/test/cases/arel/support/fake_record.rb b/activerecord/test/cases/arel/support/fake_record.rb index 864f47e245..205bdeb41b 100644 --- a/activerecord/test/cases/arel/support/fake_record.rb +++ b/activerecord/test/cases/arel/support/fake_record.rb @@ -89,7 +89,7 @@ module FakeRecord end class ConnectionPool - class Spec < Struct.new(:config) + class Spec < Struct.new(:adapter, keyword_init: true) end attr_reader :spec, :connection diff --git a/activerecord/test/cases/type/adapter_specific_registry_test.rb b/activerecord/test/cases/type/adapter_specific_registry_test.rb index b58bdd5549..1093c4feca 100644 --- a/activerecord/test/cases/type/adapter_specific_registry_test.rb +++ b/activerecord/test/cases/type/adapter_specific_registry_test.rb @@ -76,7 +76,6 @@ module ActiveRecord end test "construct args are passed to the type" do - type = Struct.new(:args) registry = Type::AdapterSpecificRegistry.new registry.register(:foo, type) @@ -117,7 +116,6 @@ module ActiveRecord 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) @@ -131,5 +129,17 @@ module ActiveRecord 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