master
1require "rails_helper"
2
3describe ReProcessPhotoJob, type: :job do
4 subject { ReProcessPhotoJob.new }
5
6 describe "#perform" do
7 let(:file_storage) { double(store: true) }
8 let(:blob_storage) { double(download: true) }
9 let(:photo) { create(:photo) }
10 let(:key) { "uploads/photo/image/#{photo.id}/#{photo.image}" }
11 let(:file) { double }
12 let(:temp_file) { double }
13
14 before :each do
15 allow(subject).to receive(:file_storage).and_return(file_storage)
16 allow(subject).to receive(:blob_storage).and_return(blob_storage)
17 end
18
19 it "processes the original file" do
20 allow(blob_storage).to receive(:download).with(key).and_yield(file)
21 allow(file_storage).to receive(:store).with(file).and_return(temp_file)
22 allow(ProcessPhotoJob).to receive(:perform_later)
23
24 subject.perform(photo)
25
26 expect(ProcessPhotoJob).
27 to have_received(:perform_later).
28 with(photo, temp_file)
29 end
30 end
31end