Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file delete being called twice on remove #1441

Merged
merged 1 commit into from
Nov 19, 2014

Conversation

adamcrown
Copy link
Contributor

When a file is removed with something like .remove_image = true it's seen as you replacing the file with a new file and still tries to delete the "old file" even though the old file was just deleted. This is mitigated in CarrierWave::SanitizedFile#delete by an if exists? condition. But it's unnecessary and especially annoying when trying to use a file storage API.

When a file is removed with something like `.remove_image = true` it's
seen as you replacing the file with a new file and still tries to delete
the "old file" even though the old file was just deleted. This is
mitigated in `CarrierWave::SanitizedFile#delete` by an `if exists?`
condition. But it's unnecessary and especially annoying when trying to
use a file storage API.
@adamcrown adamcrown changed the title Fix file delete being called twice on remove. Fix file delete being called twice on remove Aug 23, 2014
it "should only delete the file once when the file is removed" do
@event.remove_image = true
expect_any_instance_of(CarrierWave::SanitizedFile).to receive(:delete).exactly(1).times
expect(@event.save).to be_true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line should be expect(@event.save).to be true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSpec 2.14 is still being used in Carrierwave so be_true works just fine. It's only in Rspec 3 that be true or be_truthy is preferred. You can see that be_true is used throughout the entire file. So I'm just sticking to the convention. I can change it if need be of course but it should probably be changed everywhere at once for consistency.

bensie added a commit that referenced this pull request Nov 19, 2014
Fix file delete being called twice on remove
@bensie bensie merged commit b6cf5d3 into carrierwaveuploader:master Nov 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants