aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-10-23 13:10:51 -0400
committerRafael Mendonça França <rafaelmfranca@gmail.com>2018-03-28 13:11:01 -0400
commit3c1a8ee7d7af658eb9e4cb927559907c09d13c6c (patch)
tree2b1f0a4c72e800db18f145c6a70692d1d6c32632 /activerecord/test
parentfe37da4ebf227cd9b1056eed8b0a35ae86037de3 (diff)
downloadrails-3c1a8ee7d7af658eb9e4cb927559907c09d13c6c.tar.gz
rails-3c1a8ee7d7af658eb9e4cb927559907c09d13c6c.tar.bz2
rails-3c1a8ee7d7af658eb9e4cb927559907c09d13c6c.zip
Merge pull request #30956 from CJStadler/with-lock-changed-deprecation
Fix deprecation warnings from with_lock
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/locking_test.rb11
-rw-r--r--activerecord/test/models/frog.rb8
-rw-r--r--activerecord/test/schema/schema.rb4
3 files changed, 23 insertions, 0 deletions
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb
index 9d04750712..8513edb0ab 100644
--- a/activerecord/test/cases/locking_test.rb
+++ b/activerecord/test/cases/locking_test.rb
@@ -15,6 +15,7 @@ require "models/bulb"
require "models/engine"
require "models/wheel"
require "models/treasure"
+require "models/frog"
class LockWithoutDefault < ActiveRecord::Base; end
@@ -653,6 +654,16 @@ unless in_memory_db?
end
end
+ def test_locking_in_after_save_callback
+ assert_nothing_raised do
+ frog = ::Frog.create(name: "Old Frog")
+ frog.name = "New Frog"
+ assert_not_deprecated do
+ frog.save!
+ end
+ end
+ end
+
def test_with_lock_commits_transaction
person = Person.find 1
person.with_lock do
diff --git a/activerecord/test/models/frog.rb b/activerecord/test/models/frog.rb
new file mode 100644
index 0000000000..73601aacdd
--- /dev/null
+++ b/activerecord/test/models/frog.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class Frog < ActiveRecord::Base
+ after_save do
+ with_lock do
+ end
+ end
+end
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index b9c7d447af..350113eaab 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -347,6 +347,10 @@ ActiveRecord::Schema.define do
t.string :token
end
+ create_table :frogs, force: true do |t|
+ t.string :name
+ end
+
create_table :funny_jokes, force: true do |t|
t.string :name
end