Skip to content

Commit 37175a2

Browse files
committed
Remove deprecated ActiveModel::Dirty#reset_#{attribute} and ActiveModel::Dirty#reset_changes.
1 parent 4be859f commit 37175a2

File tree

4 files changed

+5
-49
lines changed

4 files changed

+5
-49
lines changed

activemodel/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Remove deprecated `ActiveModel::Dirty#reset_#{attribute}` and
2+
`ActiveModel::Dirty#reset_changes`.
3+
4+
*Rafael Mendonça França*
5+
16
* Change the way in which callback chains can be halted.
27

38
The preferred method to halt a callback chain from now on is to explicitly

activemodel/lib/active_model/dirty.rb

-20
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ module Dirty
116116

117117
included do
118118
attribute_method_suffix '_changed?', '_change', '_will_change!', '_was'
119-
attribute_method_affix prefix: 'reset_', suffix: '!'
120119
attribute_method_affix prefix: 'restore_', suffix: '!'
121120
end
122121

@@ -204,15 +203,6 @@ def clear_changes_information # :doc:
204203
@changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
205204
end
206205

207-
def reset_changes
208-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
209-
`#reset_changes` is deprecated and will be removed on Rails 5.
210-
Please use `#clear_changes_information` instead.
211-
MSG
212-
213-
clear_changes_information
214-
end
215-
216206
# Handle <tt>*_change</tt> for +method_missing+.
217207
def attribute_change(attr)
218208
[changed_attributes[attr], __send__(attr)] if attribute_changed?(attr)
@@ -231,16 +221,6 @@ def attribute_will_change!(attr)
231221
set_attribute_was(attr, value)
232222
end
233223

234-
# Handle <tt>reset_*!</tt> for +method_missing+.
235-
def reset_attribute!(attr)
236-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
237-
`#reset_#{attr}!` is deprecated and will be removed on Rails 5.
238-
Please use `#restore_#{attr}!` instead.
239-
MSG
240-
241-
restore_attribute!(attr)
242-
end
243-
244224
# Handle <tt>restore_*!</tt> for +method_missing+.
245225
def restore_attribute!(attr)
246226
if attribute_changed?(attr)

activemodel/test/cases/dirty_test.rb

-17
Original file line numberDiff line numberDiff line change
@@ -181,23 +181,6 @@ def deprecated_reload
181181
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.changed_attributes
182182
end
183183

184-
test "reset_changes is deprecated" do
185-
@model.name = 'Dmitry'
186-
@model.name_changed?
187-
@model.save
188-
@model.name = 'Bob'
189-
190-
assert_equal [nil, 'Dmitry'], @model.previous_changes['name']
191-
assert_equal 'Dmitry', @model.changed_attributes['name']
192-
193-
assert_deprecated do
194-
@model.deprecated_reload
195-
end
196-
197-
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.previous_changes
198-
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.changed_attributes
199-
end
200-
201184
test "restore_attributes should restore all previous data" do
202185
@model.name = 'Dmitry'
203186
@model.color = 'Red'

activerecord/test/cases/dirty_test.rb

-12
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,6 @@ def test_aliased_attribute_changes
165165
assert_equal parrot.name_change, parrot.title_change
166166
end
167167

168-
def test_reset_attribute!
169-
pirate = Pirate.create!(:catchphrase => 'Yar!')
170-
pirate.catchphrase = 'Ahoy!'
171-
172-
assert_deprecated do
173-
pirate.reset_catchphrase!
174-
end
175-
assert_equal "Yar!", pirate.catchphrase
176-
assert_equal Hash.new, pirate.changes
177-
assert !pirate.catchphrase_changed?
178-
end
179-
180168
def test_restore_attribute!
181169
pirate = Pirate.create!(:catchphrase => 'Yar!')
182170
pirate.catchphrase = 'Ahoy!'

0 commit comments

Comments
 (0)