mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Attribute reader / writer methods are defined as public methods
This commit is contained in:
parent
1a237904c4
commit
6515fdbbda
4 changed files with 14 additions and 14 deletions
|
@ -251,7 +251,7 @@ module ActiveRecord
|
|||
attribute = object.send(store_attribute)
|
||||
unless attribute.is_a?(ActiveSupport::HashWithIndifferentAccess)
|
||||
attribute = IndifferentCoder.as_indifferent_hash(attribute)
|
||||
object.send :"#{store_attribute}=", attribute
|
||||
object.public_send :"#{store_attribute}=", attribute
|
||||
end
|
||||
attribute
|
||||
end
|
||||
|
|
|
@ -566,9 +566,9 @@ class AttributeMethodsTest < ActiveRecord::TestCase
|
|||
|
||||
meth = "#{prefix}title"
|
||||
assert_respond_to topic, meth
|
||||
assert_equal ["title"], topic.send(meth)
|
||||
assert_equal ["title", "a"], topic.send(meth, "a")
|
||||
assert_equal ["title", 1, 2, 3], topic.send(meth, 1, 2, 3)
|
||||
assert_equal ["title"], topic.public_send(meth)
|
||||
assert_equal ["title", "a"], topic.public_send(meth, "a")
|
||||
assert_equal ["title", 1, 2, 3], topic.public_send(meth, 1, 2, 3)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -580,9 +580,9 @@ class AttributeMethodsTest < ActiveRecord::TestCase
|
|||
|
||||
meth = "title#{suffix}"
|
||||
assert_respond_to topic, meth
|
||||
assert_equal ["title"], topic.send(meth)
|
||||
assert_equal ["title", "a"], topic.send(meth, "a")
|
||||
assert_equal ["title", 1, 2, 3], topic.send(meth, 1, 2, 3)
|
||||
assert_equal ["title"], topic.public_send(meth)
|
||||
assert_equal ["title", "a"], topic.public_send(meth, "a")
|
||||
assert_equal ["title", 1, 2, 3], topic.public_send(meth, 1, 2, 3)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -594,9 +594,9 @@ class AttributeMethodsTest < ActiveRecord::TestCase
|
|||
|
||||
meth = "#{prefix}title#{suffix}"
|
||||
assert_respond_to topic, meth
|
||||
assert_equal ["title"], topic.send(meth)
|
||||
assert_equal ["title", "a"], topic.send(meth, "a")
|
||||
assert_equal ["title", 1, 2, 3], topic.send(meth, 1, 2, 3)
|
||||
assert_equal ["title"], topic.public_send(meth)
|
||||
assert_equal ["title", "a"], topic.public_send(meth, "a")
|
||||
assert_equal ["title", 1, 2, 3], topic.public_send(meth, 1, 2, 3)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -706,12 +706,12 @@ class BasicsTest < ActiveRecord::TestCase
|
|||
def test_non_valid_identifier_column_name
|
||||
weird = Weird.create("a$b" => "value")
|
||||
weird.reload
|
||||
assert_equal "value", weird.send("a$b")
|
||||
assert_equal "value", weird.public_send("a$b")
|
||||
assert_equal "value", weird.read_attribute("a$b")
|
||||
|
||||
weird.update_columns("a$b" => "value2")
|
||||
weird.reload
|
||||
assert_equal "value2", weird.send("a$b")
|
||||
assert_equal "value2", weird.public_send("a$b")
|
||||
assert_equal "value2", weird.read_attribute("a$b")
|
||||
end
|
||||
|
||||
|
|
|
@ -410,8 +410,8 @@ class NamedScopingTest < ActiveRecord::TestCase
|
|||
scope :"title containing space", ->(space: " ") { where("title LIKE '%#{space}%'") }
|
||||
scope :approved, -> { where(approved: true) }
|
||||
end
|
||||
assert_equal klass.where("title LIKE '% %'"), klass.send(:"title containing space", space: " ")
|
||||
assert_equal klass.approved.where("title LIKE '% %'"), klass.approved.send(:"title containing space", space: " ")
|
||||
assert_equal klass.where("title LIKE '% %'"), klass.public_send(:"title containing space", space: " ")
|
||||
assert_equal klass.approved.where("title LIKE '% %'"), klass.approved.public_send(:"title containing space", space: " ")
|
||||
end
|
||||
|
||||
def test_find_all_should_behave_like_select
|
||||
|
|
Loading…
Reference in a new issue