Skip to content

Commit 8eff660

Browse files
committed
Coerce test.
1 parent ccca64f commit 8eff660

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,30 @@ def test_update_all_doesnt_ignore_order_coerced
424424
mary.reload.name.must_equal 'Test'
425425
end
426426

427+
# We can not UPDATE identity columns.
428+
coerce_tests! :test_update_attributes
429+
def test_update_attributes_coerced
430+
topic = Topic.find(1)
431+
assert !topic.approved?
432+
assert_equal "The First Topic", topic.title
433+
topic.update_attributes("approved" => true, "title" => "The First Topic Updated")
434+
topic.reload
435+
assert topic.approved?
436+
assert_equal "The First Topic Updated", topic.title
437+
topic.update_attributes(approved: false, title: "The First Topic")
438+
topic.reload
439+
assert !topic.approved?
440+
assert_equal "The First Topic", topic.title
441+
# SQLServer: Here is where it breaks down. No exceptions.
442+
# assert_raise(ActiveRecord::RecordNotUnique, ActiveRecord::StatementInvalid) do
443+
# topic.update_attributes(id: 3, title: "Hm is it possible?")
444+
# end
445+
# assert_not_equal "Hm is it possible?", Topic.find(3).title
446+
# topic.update_attributes(id: 1234)
447+
# assert_nothing_raised { topic.reload }
448+
# assert_equal topic.title, Topic.find(1234).title
449+
end
450+
427451
end
428452

429453

0 commit comments

Comments
 (0)