Module#const_set is a public method

This commit is contained in:
Akira Matsuda 2020-09-15 10:18:40 +09:00
parent 31197f2079
commit 47f5459138
7 changed files with 9 additions and 9 deletions

View File

@ -49,7 +49,7 @@ class MailboxGeneratorTest < Rails::Generators::TestCase
end
def test_check_class_collision
Object.send :const_set, :InboxMailbox, Class.new
Object.const_set :InboxMailbox, Class.new
content = capture(:stderr) { run_generator }
assert_match(/The name 'InboxMailbox' is either already used in your application or reserved/, content)
ensure

View File

@ -58,7 +58,7 @@ class ActiveRecordTestConnector
ActiveRecord::Base.configurations = { "sqlite3_ar_integration" => options }
ActiveRecord::Base.connection
Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name("type")) unless Object.const_defined?(:QUOTED_TYPE)
Object.const_set :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name("type") unless Object.const_defined?(:QUOTED_TYPE)
else
raise "Can't setup connection since ActiveRecord isn't loaded."
end

View File

@ -253,7 +253,7 @@ module ActiveRecord
end
def test_connection_specification_name_should_fallback_to_parent
Object.send :const_set, :ApplicationRecord, ApplicationRecord
Object.const_set :ApplicationRecord, ApplicationRecord
klassA = Class.new(Base)
klassB = Class.new(klassA)

View File

@ -24,7 +24,7 @@ class ModulesTest < ActiveRecord::TestCase
teardown do
# reinstate the constants that we undefined in the setup
@undefined_consts.each do |constant, value|
Object.send :const_set, constant, value unless value.nil?
Object.const_set constant, value unless value.nil?
end
ActiveRecord::Base.store_full_sti_class = true

View File

@ -20,7 +20,7 @@ class ControllerGeneratorTest < Rails::Generators::TestCase
end
def test_check_class_collision
Object.send :const_set, :ObjectController, Class.new
Object.const_set :ObjectController, Class.new
content = capture(:stderr) { run_generator ["object"] }
assert_match(/The name 'ObjectController' is either already used in your application or reserved/, content)
ensure

View File

@ -31,7 +31,7 @@ class MailerGeneratorTest < Rails::Generators::TestCase
end
def test_check_class_collision
Object.send :const_set, :NotifierMailer, Class.new
Object.const_set :NotifierMailer, Class.new
content = capture(:stderr) { run_generator }
assert_match(/The name 'NotifierMailer' is either already used in your application or reserved/, content)
ensure
@ -60,7 +60,7 @@ class MailerGeneratorTest < Rails::Generators::TestCase
end
def test_check_test_class_collision
Object.send :const_set, :NotifierMailerTest, Class.new
Object.const_set :NotifierMailerTest, Class.new
content = capture(:stderr) { run_generator }
assert_match(/The name 'NotifierMailerTest' is either already used in your application or reserved/, content)
ensure
@ -68,7 +68,7 @@ class MailerGeneratorTest < Rails::Generators::TestCase
end
def test_check_preview_class_collision
Object.send :const_set, :NotifierMailerPreview, Class.new
Object.const_set :NotifierMailerPreview, Class.new
content = capture(:stderr) { run_generator }
assert_match(/The name 'NotifierMailerPreview' is either already used in your application or reserved/, content)
ensure

View File

@ -323,7 +323,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
end
def test_check_class_collision
Object.send :const_set, :UsersController, Class.new
Object.const_set :UsersController, Class.new
content = capture(:stderr) { run_generator }
assert_match(/The name 'UsersController' is either already used in your application or reserved/, content)
ensure