Skip to content

Commit 609b1ec

Browse files
committed
Persistence#increment! requires an attribute argument which is incremented
1 parent ed56a03 commit 609b1ec

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

activerecord/lib/active_record/callbacks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def touch(*) #:nodoc:
318318
_run_touch_callbacks { super }
319319
end
320320

321-
def increment!(*, touch: nil) # :nodoc:
321+
def increment!(attribute, by = 1, touch: nil) # :nodoc:
322322
touch ? _run_touch_callbacks { super } : super
323323
end
324324

activerecord/test/cases/persistence_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ def test_increment_with_touch_an_attribute_updates_timestamps
127127
assert_operator previously_written_on, :<, topic.written_on
128128
end
129129

130+
def test_increment_with_no_arg
131+
topic = topics(:first)
132+
assert_raises(ArgumentError) { topic.increment! }
133+
end
134+
130135
def test_destroy_many
131136
clients = Client.find([2, 3])
132137

0 commit comments

Comments
 (0)