Sha256: e7dec6a71730c071afaf7f7658841182a6da3ab945b1859ac79122c17febe5a4

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require "spec_helper"
require_relative "../lib/carrierwave_dimensions/processor"

class TestUploader < CarrierWave::Uploader::Base
	include CarrierWave::MiniMagick

	process store_dimensions: {
		width_column: :image_width,
		height_column: :image_height
	}
end

class UploadModel
	attr_accessor :image_width, :image_height
end

describe CarrierwaveDimensions::Processor do
	describe "processing images" do
		subject do
			TestUploader.new(model, :remote_file)
		end

		let(:model) { UploadModel.new }
		let(:image_file) { nil }

		before(:each) do
			TestUploader.enable_processing = true
			subject.store!(File.open(image_file))
		end

		after(:each) do
			subject.remove!
			TestUploader.enable_processing = false
		end

		context "given a semi-transparent image" do
			let(:image_file) do
				File.new(File.join(File.dirname(__FILE__), "data/mac-mini.png"))
			end
			
			before(:each) do
				subject.recreate_versions!
			end

			it "should set the width on the model" do
				expect(subject.model.image_width).to eq 776
			end
			
			it "should set the height on the model" do
				expect(subject.model.image_height).to eq 325
			end
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carrierwave-dimensions-0.0.1 spec/processor_spec.rb