Sha256: 95f0686872d0d2955f336b27e41c7e65951c57d3496ee89289c52b23b84f2349

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require "rails_helper"

module Archangel
  RSpec.describe AssetUploader, type: :uploader do
    subject(:resource) { described_class.new }

    let(:asset) { create(:asset) }
    let(:uploader) { described_class.new(asset, :file) }

    it "uses default image" do
      expect(resource.default_url).to include("assets/archangel/fallback/asset")
    end

    it "allows certain extensions" do
      expect(resource.extension_whitelist).to eq %w[gif jpeg jpg png]
    end

    context "with image file" do
      before do
        described_class.enable_processing = true

        uploader.store!(fixture_file_upload(uploader_test_image, "image/gif"))
      end

      after do
        described_class.enable_processing = false

        uploader.remove!
      end

      it "is an image file" do
        expect(uploader).to be_image
      end

      it "scales a small image to be no larger than 64 by 64 pixels" do
        expect(uploader.small).to be_no_larger_than(64, 64)
      end

      it "scales a tiny image to be no larger than 32 by 32 pixels" do
        expect(uploader.tiny).to be_no_larger_than(32, 32)
      end

      it "makes the image with 666 permissions" do
        expect(uploader).to have_permissions(0o666)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 spec/unit/uploaders/archangel/asset_uploader_spec.rb