Sha256: d9d3192945aa3b4b3e3e9f99afb2061ab69bd81feb612e905f6efc54d7893b00

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'
require 'carrierwave/test/matchers'

describe AttachmentUploader do
  include CarrierWave::Test::Matchers
  let(:support_dir) { File.expand_path(File.join(__FILE__, "../../support")) }
  
  before do
    @attachment = Attachment.create
    AttachmentUploader.enable_processing = true
    @uploader = AttachmentUploader.new(@attachment, :file)
  end
  after do
    AttachmentUploader.enable_processing = false
  end
  
  describe "PDF upload" do
    before do
      @pdf_fixture_path = "#{support_dir}/uploads/pdf-upload.pdf"
    end
    describe "prelims: " do
      specify "the fixture pdf should be present" do
        File.exists?(@pdf_fixture_path).should == true
      end
    end
    describe "storing the file: " do
      before do
        @uploader.store!(File.open(@pdf_fixture_path))
      end
      after do
        @uploader.remove!
      end
      subject { @uploader }
      it "should store the file" do
        @uploader.identifier.should == "pdf-upload.pdf"
        @uploader.current_path.should include "/uploads/", "/test_env/", "/attachments/", "/pdf-upload.pdf", "/#{@attachment.id}/"
      end
      its('file.content_type') { should include "/pdf" }
      describe "#thumb" do
        subject { @uploader.thumb }
        it "should have the correct size (pixels)" do
          subject.should be_no_larger_than(100,100)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
your_platform-1.0.1 spec/uploaders/attachment_uploader_spec.rb
your_platform-1.0.0 spec/uploaders/attachment_uploader_spec.rb
your_platform-0.0.2 spec/uploaders/attachment_uploader_spec.rb