mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Reset column info on original Topic in serialized attr test
Call .reset_column_information on ::Topic in serialized attribute test so that attribute methods are safely undefined for all topics.
This commit is contained in:
parent
842bc43f7f
commit
686f85515f
1 changed files with 11 additions and 2 deletions
|
@ -22,7 +22,7 @@ class SerializedAttributeTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
def test_serialize_does_not_eagerly_load_columns
|
||||
Topic.reset_column_information
|
||||
reset_column_information_of(Topic)
|
||||
assert_no_queries do
|
||||
Topic.serialize(:content)
|
||||
end
|
||||
|
@ -377,7 +377,8 @@ class SerializedAttributeTest < ActiveRecord::TestCase
|
|||
topic.update group: "1"
|
||||
|
||||
model.serialize :group, JSON
|
||||
model.reset_column_information
|
||||
|
||||
reset_column_information_of(model)
|
||||
|
||||
# This isn't strictly necessary for the test, but a little bit of
|
||||
# knowledge of internals allows us to make failures far more likely.
|
||||
|
@ -397,4 +398,12 @@ class SerializedAttributeTest < ActiveRecord::TestCase
|
|||
# raw string ("1"), or raise an exception.
|
||||
assert_equal [1] * threads.size, threads.map(&:value)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def reset_column_information_of(topic_class)
|
||||
topic_class.reset_column_information
|
||||
# reset original topic to undefine attribute methods
|
||||
::Topic.reset_column_information
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue