aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2015-10-10 13:24:54 -0700
committerJeremy Daer <jeremydaer@gmail.com>2015-10-10 13:24:54 -0700
commitf50d953ff646b84a1c791a8034cfb4f3789fc8bf (patch)
tree218d7f2053b315f5274e36f356d5ebdc0a9addea /activerecord/test
parentc61826eebcecd62e021cda4086dbcc1497820ac1 (diff)
parent85a1c025081faf8af8a065e39ee764caebf4054b (diff)
downloadrails-f50d953ff646b84a1c791a8034cfb4f3789fc8bf.tar.gz
rails-f50d953ff646b84a1c791a8034cfb4f3789fc8bf.tar.bz2
rails-f50d953ff646b84a1c791a8034cfb4f3789fc8bf.zip
Merge pull request #11410 from bogdan/increment-concurency
Make AR#increment! and #decrement! concurrency-safe
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/persistence_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb
index 7f14082a9a..31686bde3f 100644
--- a/activerecord/test/cases/persistence_test.rb
+++ b/activerecord/test/cases/persistence_test.rb
@@ -120,6 +120,15 @@ class PersistenceTest < ActiveRecord::TestCase
assert_equal 59, accounts(:signals37, :reload).credit_limit
end
+ def test_increment_updates_counter_in_db_using_offset
+ a1 = accounts(:signals37)
+ initial_credit = a1.credit_limit
+ a2 = Account.find(accounts(:signals37).id)
+ a1.increment!(:credit_limit)
+ a2.increment!(:credit_limit)
+ assert_equal initial_credit + 2, a1.reload.credit_limit
+ end
+
def test_destroy_all
conditions = "author_name = 'Mary'"
topics_by_mary = Topic.all.merge!(:where => conditions, :order => 'id').to_a