Browse files

Fix ActiveRecord#update_column return value

  • Loading branch information...
1 parent d5b275d commit 68307a1ae5fc9e454230629f5cbbbeaf79fd7cec @saks committed Oct 31, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/persistence.rb
  2. +6 −0 activerecord/test/cases/persistence_test.rb
View
2 activerecord/lib/active_record/persistence.rb
@@ -194,7 +194,7 @@ def update_column(name, value)
raise ActiveRecordError, "#{name} is marked as readonly" if self.class.readonly_attributes.include?(name)
raise ActiveRecordError, "can not update on a new record object" unless persisted?
- updated_count = self.class.update_all({ name => value }, self.class.primary_key => id) == 1
+ updated_count = self.class.update_all({ name => value }, self.class.primary_key => id)
raw_write_attribute(name, value)
View
6 activerecord/test/cases/persistence_test.rb
@@ -513,6 +513,12 @@ def test_update_column_changing_id
assert_equal 123, topic.id
end
+ def test_update_column_should_return_correct_value
+ developer = Developer.find(1)
+ return_value = developer.update_column(:salary, 80001)
+ assert_equal return_value, true
@fxn
fxn added a line comment Oct 31, 2012

The return value is not guaranteed to be a singleton, we should just test

assert return_value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ end
+
def test_update_attributes
topic = Topic.find(1)
assert !topic.approved?

0 comments on commit 68307a1

Please sign in to comment.