Skip to content

Commit 88596fc

Browse files
committed
Coerce tests that require changing identity column
1 parent 355fb34 commit 88596fc

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

test/cases/coerced_tests.rb

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,17 +672,35 @@ def test_merge_options_coerced
672672

673673

674674

675-
675+
require 'models/topic'
676676
class PersistenceTest < ActiveRecord::TestCase
677-
# We can not UPDATE identity columns.
677+
# Rails test required updating a identity column.
678678
coerce_tests! :test_update_columns_changing_id
679+
680+
# Rails test required updating a identity column.
681+
coerce_tests! :test_update
682+
def test_update_coerced
683+
topic = Topic.find(1)
684+
assert_not_predicate topic, :approved?
685+
assert_equal "The First Topic", topic.title
686+
687+
topic.update("approved" => true, "title" => "The First Topic Updated")
688+
topic.reload
689+
assert_predicate topic, :approved?
690+
assert_equal "The First Topic Updated", topic.title
691+
692+
topic.update(approved: false, title: "The First Topic")
693+
topic.reload
694+
assert_not_predicate topic, :approved?
695+
assert_equal "The First Topic", topic.title
696+
end
679697
end
680698

681699

682700

683701
require 'models/author'
684702
class UpdateAllTest < ActiveRecord::TestCase
685-
# Previous test required updating a identity column.
703+
# Rails test required updating a identity column.
686704
coerce_tests! :test_update_all_doesnt_ignore_order
687705
def test_update_all_doesnt_ignore_order_coerced
688706
david, mary = authors(:david), authors(:mary)

0 commit comments

Comments
 (0)