From 1849665f738cf7b3650e508b05380ebb36748f9e Mon Sep 17 00:00:00 2001 From: Henrik N Date: Sun, 28 Oct 2012 17:48:04 +0100 Subject: Enable update_column(s) for the primary key attribute. Didn't work before because it updated the model-in-memory first, so the DB query couldn't find the record. --- activerecord/test/cases/persistence_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index b5f32a57b2..4b938da5c4 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -592,6 +592,19 @@ class PersistencesTest < ActiveRecord::TestCase assert_equal 'super_title', t.title end + def test_update_columns_changing_id + topic = Topic.find(1) + topic.update_columns(id: 123) + assert_equal 123, topic.id + topic.reload + assert_equal 123, topic.id + end + + def test_update_columns_returns_boolean + topic = Topic.find(1) + assert_equal true, topic.update_columns(title: "New title") + end + def test_update_attributes topic = Topic.find(1) assert !topic.approved? -- cgit v1.2.3