Skip to content

Commit

Permalink
Merge pull request #2686 from rajyan/rollback-regression
Browse files Browse the repository at this point in the history
add failing test for #2685
  • Loading branch information
mshibuya committed Aug 17, 2023
2 parents eb03fe1 + 1e63b19 commit 26b6bbd
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 26b6bbd

Please sign in to comment.