Skip to content

Commit b8e908c

Browse files
author
Anna
committed
updated persistence test because we can't update an identity column
1 parent 7a6d736 commit b8e908c

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

test/cases/persistence_test_sqlserver.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PersistencesTest < ActiveRecord::TestCase
2222

2323
fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts, :minivans
2424

25-
COERCED_TESTS = [:test_update_all_doesnt_ignore_order]
25+
COERCED_TESTS = [:test_update_all_doesnt_ignore_order, :test_update_columns_changing_id, :test_update_attributes]
2626

2727
include SqlserverCoercedTest
2828

@@ -43,7 +43,28 @@ def test_coerced_update_all_doesnt_ignore_order
4343
end
4444
end
4545
end
46-
46+
47+
def test_coerced_update_attributes
48+
topic = Topic.find(1)
49+
assert !topic.approved?
50+
assert_equal "The First Topic", topic.title
51+
52+
topic.update_attributes("approved" => true, "title" => "The First Topic Updated")
53+
topic.reload
54+
assert topic.approved?
55+
assert_equal "The First Topic Updated", topic.title
56+
57+
topic.update_attributes(approved: false, title: "The First Topic")
58+
topic.reload
59+
assert !topic.approved?
60+
assert_equal "The First Topic", topic.title
61+
62+
assert_raise(ActiveRecord::RecordNotUnique, ActiveRecord::StatementInvalid) do
63+
Topic.create!(id: 3, title: "Hm is it possible?")
64+
end
65+
assert_not_equal "Hm is it possible?", Topic.find(3).title
66+
end
67+
4768
end
4869

4970

0 commit comments

Comments
 (0)