diff --git a/spec/orm/activerecord_spec.rb b/spec/orm/activerecord_spec.rb index 7421b3fe9..30c4761d6 100644 --- a/spec/orm/activerecord_spec.rb +++ b/spec/orm/activerecord_spec.rb @@ -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')