diff --git a/activerecord/test/cases/json_shared_test_cases.rb b/activerecord/test/cases/json_shared_test_cases.rb index 5aa41b9d6d..9a1c1c3f3f 100644 --- a/activerecord/test/cases/json_shared_test_cases.rb +++ b/activerecord/test/cases/json_shared_test_cases.rb @@ -169,6 +169,25 @@ module JSONSharedTestCases assert_not json.changed? end + def test_changes_in_place_ignores_key_order + json = klass.new + assert_not json.changed? + + json.payload = { "three" => "four", "one" => "two" } + json.save! + json.reload + + json.payload = { "three" => "four", "one" => "two" } + assert_not json.changed? + + json.payload = [{ "three" => "four", "one" => "two" }, { "seven" => "eight", "five" => "six" }] + json.save! + json.reload + + json.payload = [{ "three" => "four", "one" => "two" }, { "seven" => "eight", "five" => "six" }] + assert_not json.changed? + end + def test_changes_in_place_with_ruby_object time = Time.now.utc json = klass.create!(payload: time)