require "rails_helper" feature "Admin managing casting submissions" do let(:current_user) { create(:user, admin: true, email: "user@test.com") } let(:project) { create(:project, account: current_user.primary_account, name: "Test Project") } before do sign_in current_user 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 scenario "when admin opens view page for casting submission, it does not fail if zoom meeting URL is invalid" do cc = create(:casting_call) cci = create(:casting_submission, casting_call: cc, zoom_meeting_url: "anything") visit admin_casting_submissions_path click_on manage_button click_link view_link expect(page).to have_content casting_submission_details_header expect(page).to have_content interview_files_label expect(page).to have_content cci.performer_name end private def create_casting_submission_button t 'admin.casting_submissions.index.actions.new' end def new_casting_submission_heading 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 def zoom_meeting_url_invalid_error t 'casting_submissions.validation_errors.invalid_meeting_url' end def performer_name_field 'casting_submission[performer_name]' end def zoom_meeting_url_field 'casting_submission[zoom_meeting_url]' end 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 def manage_button 'Manage' end def view_link 'View' end def casting_submission_details_header 'Casting submission details' end def interview_files_label 'INTERVIEW FILES:' end end