Sha256: c1965a25288730cd75d3a77939a8fa794f3683538ffe2734d02136151a77da31

Contents?: true

Size: 821 Bytes

Versions: 3

Compression:

Stored size: 821 Bytes

Contents

require 'rails_helper'

RSpec.describe Peoplefinder::ImageUploader, type: :uploader do
  include CarrierWave::Test::Matchers
  let(:person) { create(:person, image: File.open(sample_image)) }

  before do
    described_class.enable_processing = true
  end

  it 'creates default image sizes' do
    expect(person.image.croppable).to be_no_larger_than(1024, 1024)
    expect(person.image.medium).to be_no_larger_than(512, 512)
  end

  it 'crops the medium image and leaves the croppable version intact' do
    person.assign_attributes(crop_x: 10, crop_y: 10, crop_w: 20, crop_h: 20)
    person.image.recreate_versions!

    expect(person.image.croppable).to be_no_larger_than(1024, 1024)
    expect(person.image.medium).to have_dimensions(20, 20)
  end

  after do
    described_class.enable_processing = false
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
peoplefinder-0.1.1 spec/uploaders/peoplefinder/image_uploader_spec.rb
peoplefinder-0.1.0 spec/uploaders/peoplefinder/image_uploader_spec.rb
peoplefinder-0.0.2 spec/uploaders/peoplefinder/image_uploader_spec.rb