Skip to content

Commit

Permalink
add failing test for carrierwaveuploader#2685
Browse files Browse the repository at this point in the history
files should not be removed on rollback if not updated
  • Loading branch information
Yohta Kimura committed Aug 17, 2023
1 parent d339c27 commit 1e63b19
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spec/orm/activerecord_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,16 @@ def filename
expect(File.exist?(public_path('uploads/new.jpeg'))).to be_falsey
end

it 'should not remove old file on rollback if file is not changed' do
Event.transaction do
@event.foo = 'test'
@event.save
expect(File.exist?(public_path('uploads/old.jpeg'))).to be_truthy
raise ActiveRecord::Rollback
end
expect(File.exist?(public_path('uploads/old.jpeg'))).to be_truthy
end

it 'should give correct url during transaction' do
Event.transaction do
@event.image = stub_file('new.jpeg')
Expand Down

0 comments on commit 1e63b19

Please sign in to comment.