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 issue encountered when trying to reopen a file stored remotely #2185

Merged
merged 5 commits into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/carrierwave/processing/rmagick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def destroy_image(image)
end

def rmagick_image
::Magick::Image.read(current_path).first
::Magick::Image.from_blob(self.read).first
end

end # RMagick
Expand Down
32 changes: 32 additions & 0 deletions spec/processing/rmagick_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,38 @@
end
end

describe "#rmagick_image", focus: true do
Copy link
Member

Choose a reason for hiding this comment

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

focus: true needs to be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops :)

it "returns a ::Magick::Image" do
expect{instance.send(:rmagick_image)}.to_not raise_exception
expect(instance.send(:rmagick_image).class).to eq(::Magick::Image)
end

context "with a remotely stored file" do
class RemoteFile < CarrierWave::SanitizedFile
def initialize local_path
@local_path = local_path
end

def current_path
"foo/bar.jpg"
end

def read
File.read @local_path
end
end

before do
allow(instance).to receive(:file).and_return(RemoteFile.new(landscape_file_copy_path))
end

it "returns a ::Magick::Image" do
expect{instance.send(:rmagick_image)}.to_not raise_exception
expect(instance.send(:rmagick_image).class).to eq(::Magick::Image)
end
end
end

describe "test errors" do
context "invalid image file" do
before do
Expand Down