diff --git a/lib/carrierwave/processing/mini_magick.rb b/lib/carrierwave/processing/mini_magick.rb index 8c51cb4e5..f9741aa99 100644 --- a/lib/carrierwave/processing/mini_magick.rb +++ b/lib/carrierwave/processing/mini_magick.rb @@ -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 diff --git a/spec/orm/activerecord_spec.rb b/spec/orm/activerecord_spec.rb index 94c074d11..167b66901 100644 --- a/spec/orm/activerecord_spec.rb +++ b/spec/orm/activerecord_spec.rb @@ -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 diff --git a/spec/processing/mini_magick_spec.rb b/spec/processing/mini_magick_spec.rb index 87486bbea..f1020a298 100644 --- a/spec/processing/mini_magick_spec.rb +++ b/spec/processing/mini_magick_spec.rb @@ -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