Sha256: deef3d64197afaefad60566ee88ac91399013edc3a96bf2ab7b343580e1b2763

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'
require 'carrierwave/storage/sftp'

describe CarrierWave::Storage::SFTP::File do
  let(:uploader) do
    Class.new(CarrierWave::Uploader::Base) do
      storage :sftp
    end.tap do |u|
      allow(u).to receive(:store_path).and_return('uploads/test.jpg')
    end
  end

  let(:base) { CarrierWave::Storage::SFTP.new(uploader) }

  let(:file) do
    CarrierWave::Storage::SFTP::File.new(uploader, base, uploader.store_path)
  end

  let(:mime_type) { double('mime_type') }

  describe '#content_type' do
    it 'delegates to base file by default' do
      sanitized_file = CarrierWave::SanitizedFile.new(file)
      expect(CarrierWave::SanitizedFile).to receive(:new).with(file.path).
        and_return(sanitized_file)
      expect(sanitized_file).to receive(:content_type).and_return(mime_type)

      expect(file.content_type).to eq(mime_type)
    end

    it 'permits overriding the default value' do
      file.content_type = mime_type

      expect(file.content_type).to eq(mime_type)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carrierwave-ftp-0.4.1 spec/sftp_file_spec.rb