diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2015-01-18 21:19:00 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2015-01-18 21:19:00 -0200 |
commit | e3f5be1831c45dfadbb748d21b45d3167222300a (patch) | |
tree | 79a6db248d9362d5be895b2c396c68dd79b2e2b9 /activerecord/test | |
parent | 9caeded9c62bf2c462a60a1a0b1a58249d4bd6ac (diff) | |
parent | 0fcd4cf5c26c470623eef9af72a134ef6ba1a701 (diff) | |
download | rails-e3f5be1831c45dfadbb748d21b45d3167222300a.tar.gz rails-e3f5be1831c45dfadbb748d21b45d3167222300a.tar.bz2 rails-e3f5be1831c45dfadbb748d21b45d3167222300a.zip |
Merge pull request #18501 from prathamesh-sonpatki/nosql
Run SQL only if attribute changed for update_attribute method
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/persistence_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index d6816041bc..2803ad2de0 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -356,6 +356,16 @@ class PersistenceTest < ActiveRecord::TestCase assert_equal("David", topic_reloaded.author_name) end + def test_update_attribute_does_not_run_sql_if_attribute_is_not_changed + klass = Class.new(Topic) do + def self.name; 'Topic'; end + end + topic = klass.create(title: 'Another New Topic') + assert_queries(0) do + topic.update_attribute(:title, 'Another New Topic') + end + end + def test_delete topic = Topic.find(1) assert_equal topic, topic.delete, 'topic.delete did not return self' |