mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #36907 from wjessop/string_attribute_should_compare_with_typecast_symbol_after_update
Serialize symbols to strings in ImmutableString serialize method
This commit is contained in:
commit
ade48853d9
2 changed files with 8 additions and 1 deletions
|
@ -9,7 +9,7 @@ module ActiveModel
|
|||
|
||||
def serialize(value)
|
||||
case value
|
||||
when ::Numeric, ActiveSupport::Duration then value.to_s
|
||||
when ::Numeric, ::Symbol, ActiveSupport::Duration then value.to_s
|
||||
when true then "t"
|
||||
when false then "f"
|
||||
else super
|
||||
|
|
|
@ -326,6 +326,13 @@ class DirtyTest < ActiveRecord::TestCase
|
|||
assert_not_predicate topic, :approved_changed?
|
||||
end
|
||||
|
||||
def test_string_attribute_should_compare_with_typecast_symbol_after_update
|
||||
pirate = Pirate.create!(catchphrase: :foo)
|
||||
pirate.update_column :catchphrase, :foo
|
||||
pirate.catchphrase
|
||||
assert_not_predicate pirate, :catchphrase_changed?
|
||||
end
|
||||
|
||||
def test_partial_update
|
||||
pirate = Pirate.new(catchphrase: "foo")
|
||||
old_updated_on = 1.hour.ago.beginning_of_day
|
||||
|
|
Loading…
Reference in a new issue