post replacements: rename <attr>_was to old_<attr>

Rename the following post replacement attributes:

* file_size_was -> old_file_size
* file_ext_was -> old_file_ext
* image_width_was -> old_image_width
* image_height_was -> old_image_height
* md5_was -> old_md5

In Rails 6.1, having attributes named `file_size` and `file_size_was` on
the same model breaks things because it conflicts with Rails' dirty
attribute tracking.
This commit is contained in:
evazion
2020-12-19 14:18:05 -06:00
parent 09e3146819
commit 4cb39422b2
7 changed files with 36 additions and 26 deletions

View File

@@ -287,11 +287,11 @@ class UploadServiceTest < ActiveSupport::TestCase
should "preserve the old values" do
as(@user) { subject.process! }
assert_equal(1500, @replacement.image_width_was)
assert_equal(1000, @replacement.image_height_was)
assert_equal(2000, @replacement.file_size_was)
assert_equal("jpg", @replacement.file_ext_was)
assert_equal(@old_md5, @replacement.md5_was)
assert_equal(1500, @replacement.old_image_width)
assert_equal(1000, @replacement.old_image_height)
assert_equal(2000, @replacement.old_file_size)
assert_equal("jpg", @replacement.old_file_ext)
assert_equal(@old_md5, @replacement.old_md5)
end
should "record the new values" do