Sha256: 488a0682294e6509785dad63074ac66e2e1b7986cf9471d4173d4c494d622f5a

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe Applicants::VideoUrlUtility do
  let(:utility) { described_class.new url }
  let(:url)     { "http://ut-applicant-videos.s3-us-west-1.amazonaws.com/file.mp4?expiring=info&X-stuff=99" }

  describe '#strip_params' do
    it 'strips params' do
      expect(utility.strip_params).to eq "http://ut-applicant-videos.s3-us-west-1.amazonaws.com/file.mp4"
    end
  end

  describe '#temporary' do
    let(:presigner) { double Aws::S3::Presigner }

    it 'gets a temporary URL from Amazon' do
      expect(Aws::S3::Presigner).to receive(:new).and_return presigner
      expect(presigner).to receive(:presigned_url).with(:get_object,
        bucket:     'ut-applicant-videos',
        key:        'file.mp4',
        expires_in: 3600
      ).and_return 'temporary'

      expect(utility.temporary).to eq 'temporary'
    end
  end

  describe '#remove!' do
    let(:s3_object) { double Aws::S3::Object }

    it 'removes the object' do
      expect(Aws::S3::Object).to receive(:new)
        .with('ut-applicant-videos','file.mp4',anything)
        .and_return s3_object
      expect(s3_object).to receive :delete

      utility.remove!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
applicants-0.11.0 spec/lib/applicants/video_url_utility_spec.rb