aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-09-24 03:03:04 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-09-24 03:03:04 +0900
commit609b1ec9b629e60416eb32a4376a054ca0206d66 (patch)
treec4a02522d5e68954146925185f0c982122dcda0d /activerecord
parented56a031041a868eeeb439d8b79d04565be1286f (diff)
downloadrails-609b1ec9b629e60416eb32a4376a054ca0206d66.tar.gz
rails-609b1ec9b629e60416eb32a4376a054ca0206d66.tar.bz2
rails-609b1ec9b629e60416eb32a4376a054ca0206d66.zip
`Persistence#increment!` requires an attribute argument which is incremented
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/callbacks.rb2
-rw-r--r--activerecord/test/cases/persistence_test.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index b6852bfc71..1bffe89875 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -318,7 +318,7 @@ module ActiveRecord
_run_touch_callbacks { super }
end
- def increment!(*, touch: nil) # :nodoc:
+ def increment!(attribute, by = 1, touch: nil) # :nodoc:
touch ? _run_touch_callbacks { super } : super
end
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb
index 576fd21642..8073cabae6 100644
--- a/activerecord/test/cases/persistence_test.rb
+++ b/activerecord/test/cases/persistence_test.rb
@@ -127,6 +127,11 @@ class PersistenceTest < ActiveRecord::TestCase
assert_operator previously_written_on, :<, topic.written_on
end
+ def test_increment_with_no_arg
+ topic = topics(:first)
+ assert_raises(ArgumentError) { topic.increment! }
+ end
+
def test_destroy_many
clients = Client.find([2, 3])