Skip to content

Commit

Permalink
Merge pull request #2349 from artygus/master
Browse files Browse the repository at this point in the history
MiniMagick: use read method to get file data
  • Loading branch information
mshibuya authored Dec 24, 2018
2 parents 0b2e085 + 091e462 commit 0dc4277
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
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

0 comments on commit 0dc4277

Please sign in to comment.