diff options
Diffstat (limited to 'activestorage/test/models')
-rw-r--r-- | activestorage/test/models/attached_test.rb | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/activestorage/test/models/attached_test.rb b/activestorage/test/models/attached_test.rb index 14395e12df..b10d2bebe3 100644 --- a/activestorage/test/models/attached_test.rb +++ b/activestorage/test/models/attached_test.rb @@ -4,8 +4,6 @@ require "test_helper" require "database/setup" class ActiveStorage::AttachmentsTest < ActiveSupport::TestCase - include ActiveJob::TestHelper - setup do @user = User.create!(name: "Josh") end @@ -19,16 +17,18 @@ class ActiveStorage::AttachmentsTest < ActiveSupport::TestCase # inherited only assert_equal "funky.jpg", @user.avatar.filename.to_s - User.class_eval do - def avatar - super.filename.to_s.reverse + begin + User.class_eval do + def avatar + super.filename.to_s.reverse + end end - end - # override with super - assert_equal "funky.jpg".reverse, @user.avatar - - User.send(:remove_method, :avatar) + # override with super + assert_equal "funky.jpg".reverse, @user.avatar + ensure + User.send(:remove_method, :avatar) + end end test "overriding has_many_attached methods works" do @@ -39,16 +39,18 @@ class ActiveStorage::AttachmentsTest < ActiveSupport::TestCase assert_equal "funky.jpg", @user.highlights.first.filename.to_s assert_equal "wonky.jpg", @user.highlights.second.filename.to_s - User.class_eval do - def highlights - super.reverse + begin + User.class_eval do + def highlights + super.reverse + end end - end - - # override with super - assert_equal "wonky.jpg", @user.highlights.first.filename.to_s - assert_equal "funky.jpg", @user.highlights.second.filename.to_s - User.send(:remove_method, :highlights) + # override with super + assert_equal "wonky.jpg", @user.highlights.first.filename.to_s + assert_equal "funky.jpg", @user.highlights.second.filename.to_s + ensure + User.send(:remove_method, :highlights) + end end end |