Commit 0b5021fc authored by marcheing's avatar marcheing Committed by Rafael Reggiani Manzo

Search for encoded content on content show

parent 2d6beb84
......@@ -5,6 +5,8 @@ class ContentsController < ApplicationController
# GET /contents/1
# GET /contents/1.json
def show
@video = @content.encoded_contents.last
redirect_to root_path, notice: I18n.t('video_has_not_finished_encoding') unless @video.state == 'finished'
end
# GET /contents/new
......
......@@ -19,3 +19,4 @@ en:
register: Register
team_tooltip: Add here the team members and video actors.
soundtrack_tooltip: Be sure you have the permission to use the soundtrack.
video_has_not_finished_encoding: The requested video is not yet ready to be shown to public
......@@ -19,3 +19,4 @@ pt-BR:
register: Cadastrar
team_tooltip: Coloque aqui os membros da equipe e atores do vídeo.
soundtrack_tooltip: Tenha certeza que você possui permissão para usar a trilha sonora.
video_has_not_finished_encoding: O vídeo requisitado ainda não está pronto para ser exibido
......@@ -33,13 +33,30 @@ RSpec.describe ContentsController, type: :controller do
describe 'GET #show' do
let(:video) { build(:video, :with_file_name, id: 1) }
let(:encoded_video) { build(:encoded_video) }
context 'video found' do
before do
expect(Content).to receive(:find).with(video.id.to_s).and_return(video)
get :show, params: { id: video.id }
expect(video).to receive(:encoded_contents).and_return [encoded_video]
end
it { is_expected.to respond_with(:ok) }
context 'encoded video finished' do
before do
get :show, params: { id: video.id }
end
it { is_expected.to respond_with(:ok) }
end
context 'encoded video not finished' do
before do
expect(encoded_video).to receive(:state).and_return nil
get :show, params: { id: video.id }
end
it { is_expected.to respond_with(:redirect) }
end
end
context 'video not found' do
......
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