Commit 29b33a82 authored by marcheing's avatar marcheing

Check for profile before allowing user to send content

parent bca58fbf
Pipeline #3696519 passed with stage
in 16 minutes and 37 seconds
class ContentsController < ApplicationController
before_action :set_content, only: [:show]
before_action :find_last_encoded_video, only: [:show]
before_action :check_profile, only: [:new, :create]
protect_from_forgery with: :null_session, only: :zencoder_callback
# GET /contents/1
......@@ -61,4 +62,8 @@ class ContentsController < ApplicationController
@encoded_video = @content.encoded_contents.last
redirect_to root_path, notice: I18n.t('video_has_not_finished_encoding') unless @encoded_video.state == 'finished'
end
def check_profile
redirect_to new_profile_path, notice: I18n.t('need_complete_profile_to_send_content') if current_user.profile.nil?
end
end
......@@ -20,6 +20,7 @@ en:
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
need_complete_profile_to_send_content: You need a complete profile to be able to send contents
contents:
content_details:
by: By
......
......@@ -20,6 +20,7 @@ pt-BR:
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
need_complete_profile_to_send_content: Você precisa de um perfil completo cadastrado para enviar conteúdos
contents:
content_details:
by: Por
......
......@@ -72,6 +72,10 @@ RSpec.describe ContentsController, type: :controller do
end
describe 'GET #new' do
before do
expect_any_instance_of(User).to receive(:profile).and_return build :profile
end
it 'responds with ok' do
get :new
expect(response.status).to eq 200
......@@ -80,6 +84,11 @@ RSpec.describe ContentsController, type: :controller do
describe 'POST #create' do
let(:video) { build(:video, with: :with_file_name) }
before do
expect_any_instance_of(User).to receive(:profile).and_return build :profile
end
context 'with valid params' do
before do
expect_any_instance_of(Content).to receive(:save).and_return true
......
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