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

Complete encoding feature with EncodedContent update

Signed-off-by: Diego de Araújo Martinez Camarinha's avatarDiego Araújo <diegoamc@protonmail.ch>
parent cba67268
require 'open-uri'
class ContentsController < ApplicationController
before_action :set_content, only: [:show]
protect_from_forgery with: :null_session, only: :zencoder_callback
......@@ -28,6 +30,15 @@ class ContentsController < ApplicationController
end
def zencoder_callback
@encoded_content = EncodedContent.find_by(job_id: params[:job][:id])
@encoded_content.output_id = params[:outputs].first[:id]
@encoded_content.state = params[:outputs].first[:state]
@encoded_content.width = params[:outputs].first[:width]
@encoded_content.height = params[:outputs].first[:height]
@encoded_content.duration = params[:outputs].first[:duration_in_ms]
@encoded_content.file_size = params[:outputs].first[:file_size_in_bytes]
@encoded_content.video = open(params[:outputs].first[:url])
@encoded_content.save
end
private
......
......@@ -13,4 +13,5 @@ Feature: Send uploaded video to zencoder
When the zencoder job finishes
Then an encoded content should have been created
And I should receive a successful notification
And the encoded content should have been updated
......@@ -23,6 +23,11 @@ Then(/^an encoded content should have been created$/) do
end
Then(/^I should receive a successful notification$/) do
`zencoder_fetcher -u #{ZencoderSettings.notifications.url} #{ZencoderSettings.api_key} -c 1`
`zencoder_fetcher -u #{ZencoderSettings.notifications.url} #{ZencoderSettings.api_key} -c 1 -m 0 -n 1 --loop`
expect($?.success?).to eq true
end
Then(/^the encoded content should have been updated$/) do
expect(EncodedContent.find_by(content_id: @content.id).output_id).to_not be_nil
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