Commit 4f7184e7 authored by marcheing's avatar marcheing Committed by Diego de Araújo Martinez Camarinha

Complete coverage of attributions on zencoder callback

Signed-off-by: Diego de Araújo Martinez Camarinha's avatarDiego Araújo <diegoamc@protonmail.ch>
parent dcaee07f
......@@ -86,14 +86,25 @@ RSpec.describe ContentsController, type: :controller do
describe 'POST #zencoder_callback' do
let!(:job_id) { '1' }
let!(:outputs) { [{id: '2', state: 'finished', width: '640', height: '320', duration_in_ms: '5000',
file_size_in_bytes: '1024', url: 'http://test.com'}] }
let!(:output) { { id: '2', state: 'finished', width: '640', height: '320', duration_in_ms: '5000',
file_size_in_bytes: '1024', url: 'http://test.com' } }
let!(:outputs) { [output] }
let!(:video_file_mock) { instance_double('video_file') }
context 'when the content is found' do
let(:encoded_video) { build(:encoded_video) }
before do
expect(EncodedContent).to receive(:find_by).with(job_id: job_id).and_return(encoded_video)
expect(subject).to receive(:open).with(outputs.first[:url])
expect(subject).to receive(:open).with(outputs.first[:url]).and_return(video_file_mock)
expect(encoded_video).to receive(:save).and_return(true)
expect(encoded_video).to receive(:output_id=).with(output[:id])
expect(encoded_video).to receive(:state=).with(output[:state])
expect(encoded_video).to receive(:width=).with(output[:width])
expect(encoded_video).to receive(:height=).with(output[:height])
expect(encoded_video).to receive(:duration=).with(output[:duration_in_ms])
expect(encoded_video).to receive(:file_size=).with(output[:file_size_in_bytes])
expect(encoded_video).to receive(:video=).with(video_file_mock)
post :zencoder_callback, params: { job: { id: job_id}, outputs: outputs }
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment