Compare commits

...

4 Commits

Author SHA1 Message Date
Bilal
1d4b187223 fix MR comments 2020-07-21 16:33:02 +02:00
Bilal
ccbc2dc6b8 fix after rebase 2020-07-17 07:59:09 +02:00
Bilal
fe3faf5f23 adapt specs 2020-07-17 07:14:06 +02:00
Bilal
066f8f496e allow admin to upload interview recording 2020-07-17 07:14:06 +02:00
7 changed files with 85 additions and 35 deletions

View File

@@ -40,7 +40,7 @@ class Admin::CastingSubmissionsController < Admin::ApplicationController
end
def casting_submission_params
params.require(:casting_submission).permit(:casting_call_id, :performer_name, :interview_date, :zoom_meeting_url)
params.require(:casting_submission).permit(:casting_call_id, :performer_name, :interview_date, :zoom_meeting_url, :interview_recording)
end
def casting_submissions

View File

@@ -1,6 +1,7 @@
class CastingSubmission < ApplicationRecord
belongs_to :casting_call
has_many_attached :files
has_one_attached :interview_recording
has_secure_token

View File

@@ -6,6 +6,19 @@
<%= form.text_field :interview_date, class: "datepicker-control" %>
<%= form.text_field :zoom_meeting_url %>
<% unless casting_submission.new_record? %>
<%= form.file_field :interview_recording, data: { direct_upload_url: rails_direct_uploads_url, aws_bucket: ENV['AWS_BUCKET'], aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'], signer_url: multipart_signatures_url } %>
<% if casting_submission.interview_recording.attached? %>
<p>
<%= link_to casting_submission.interview_recording do %>
<%= fa_icon "file-text-o" %> <%= casting_submission.interview_recording.filename %>
<% end %>
<span class="text-muted"><%= fa_icon "long-arrow-left" %> <em>Current interview recording</em></span>
</p>
<% end %>
<% end %>
<div class="row align-items-center text-center mt-4">
<%= link_to t("shared.cancel"), [:admin, :casting_submissions], class: "col-3 text-reset" %>
<div class="col-9">

View File

@@ -9,20 +9,6 @@ SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
--
-- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: -
--
@@ -331,8 +317,8 @@ CREATE TABLE public.appearance_releases (
person_last_name character varying,
guardian_first_name character varying,
guardian_last_name character varying,
guardian_email character varying,
identifier character varying,
guardian_email character varying,
person_address_street2 character varying,
person_address_city character varying,
person_address_state character varying,
@@ -742,15 +728,6 @@ CREATE SEQUENCE public.contract_templates_id_seq
ALTER SEQUENCE public.contract_templates_id_seq OWNED BY public.contract_templates.id;
--
-- Name: data_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.data_migrations (
version character varying NOT NULL
);
--
-- Name: directories; Type: TABLE; Schema: public; Owner: -
--
@@ -1492,6 +1469,7 @@ CREATE TABLE public.settings (
--
CREATE SEQUENCE public.settings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1527,6 +1505,7 @@ CREATE TABLE public.taggings (
--
CREATE SEQUENCE public.taggings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1557,6 +1536,7 @@ CREATE TABLE public.tags (
--
CREATE SEQUENCE public.tags_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1917,9 +1897,9 @@ CREATE TABLE public.zoom_meetings (
api_meeting_id character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
status integer DEFAULT 0,
zoom_user_id bigint,
project_id bigint
project_id bigint,
status integer DEFAULT 0
);
@@ -2426,14 +2406,6 @@ ALTER TABLE ONLY public.contract_templates
ADD CONSTRAINT contract_templates_pkey PRIMARY KEY (id);
--
-- Name: data_migrations data_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.data_migrations
ADD CONSTRAINT data_migrations_pkey PRIMARY KEY (version);
--
-- Name: directories directories_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

View File

@@ -2,6 +2,7 @@ FactoryBot.define do
factory :casting_call do
association :project
user_email 'test@email.com'
title 'Casting Call Title'
description "Casting call description"
project_description "Casting call project description"
interview_instructions "Interview instructions"

View File

@@ -9,5 +9,9 @@ FactoryBot.define do
trait :with_files do
files { [Rack::Test::UploadedFile.new('spec/fixtures/files/location_photo.png', 'image/png')] }
end
trait :with_interview_recording do
interview_recording { Rack::Test::UploadedFile.new('spec/fixtures/files/video_file.mp4', 'video/mp4') }
end
end
end

View File

@@ -39,6 +39,45 @@ feature "Admin managing casting submissions" do
expect(page).to have_content create_casting_submission_button
end
scenario "when creating new casting call interview - interview recording field is not visible" do
visit admin_casting_submissions_path
click_on create_casting_submission_button
expect(page).to have_content new_casting_submission_heading
expect(page).not_to have_field interview_recording_field
end
scenario "admin can upload interview recording video when editing casting call interview" do
cc = create(:casting_call)
cci = create(:casting_submission, casting_call: cc)
expect(CastingSubmission.last.interview_recording).not_to be_attached
visit edit_admin_casting_submission_path(cci)
expect(page).to have_content edit_casting_submission_heading
expect(page).to have_field interview_recording_field
expect(page).not_to have_content current_interview_recording_label
attach_file interview_recording_field, Rails.root.join(file_fixture('video_file.mp4'))
click_on update_casting_submission_button
expect(page).to have_content casting_submission_updated_message
expect(CastingSubmission.last.interview_recording).to be_attached
end
scenario "when editing casting call interview with already uploaded interview video, interview recording file name link is shown below file field" do
cc = create(:casting_call)
cci = create(:casting_submission, :with_interview_recording, casting_call: cc)
expect(CastingSubmission.last.interview_recording).to be_attached
visit edit_admin_casting_submission_path(cci)
expect(page).to have_content edit_casting_submission_heading
expect(page).to have_content current_interview_recording_label
expect(page).to have_link CastingSubmission.last.interview_recording.attachment.blob.filename.to_s
end
private
def create_casting_submission_button
@@ -49,6 +88,14 @@ feature "Admin managing casting submissions" do
t 'admin.casting_submissions.new.heading'
end
def edit_casting_submission_heading
'Edit Casting Submission'
end
def update_casting_submission_button
'Update Casting submission'
end
def submit_casting_submission_form
t 'helpers.submit.casting_submission.create'
end
@@ -68,4 +115,16 @@ feature "Admin managing casting submissions" do
def casting_call_field
'casting_submission[casting_call_id]'
end
def casting_submission_updated_message
t 'admin.casting_submissions.update.notice'
end
def interview_recording_field
'casting_submission[interview_recording]'
end
def current_interview_recording_label
'Current interview recording'
end
end