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

MiniMagick: use read method to get file data #2349

Merged
merged 2 commits into from
Dec 24, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 1 addition & 5 deletions lib/carrierwave/processing/mini_magick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,7 @@ def dimension_from(value)
end

def mini_magick_image
if url
::MiniMagick::Image.open(url)
else
::MiniMagick::Image.open(current_path)
end
::MiniMagick::Image.read(self.read)
end

end # MiniMagick
Expand Down
24 changes: 24 additions & 0 deletions spec/orm/activerecord_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,30 @@ def reset_class(class_name)

expect(@event.reload.image).to be_blank
end

context "with CarrierWave::MiniMagick" do
before(:each) do
@uploader.send(:include, CarrierWave::MiniMagick)
end

it "has width and height" do
@event.image = stub_file('landscape.jpg')
expect(@event.image.width).to eq 640
expect(@event.image.height).to eq 480
end
end

context "with CarrierWave::MiniMagick", :rmagick => true do
before(:each) do
@uploader.send(:include, CarrierWave::RMagick)
end

it "has width and height" do
@event.image = stub_file('landscape.jpg')
expect(@event.image.width).to eq 640
expect(@event.image.height).to eq 480
end
end
end

describe '#image=' do
Expand Down
1 change: 0 additions & 1 deletion spec/processing/mini_magick_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
before do
FileUtils.cp(landscape_file_path, landscape_copy_file_path)
allow(instance).to receive(:cached?).and_return true
allow(instance).to receive(:url).and_return nil
allow(instance).to receive(:file).and_return(CarrierWave::SanitizedFile.new(landscape_copy_file_path))
end

Expand Down