139 lines
4.5 KiB
Ruby
139 lines
4.5 KiB
Ruby
require "rails_helper"
|
|
|
|
feature "Admin managing casting call interviews" 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 "admin cannot create casting call interview with invalid zoom url", js: true do
|
|
visit admin_casting_call_interviews_path
|
|
cc = create(:casting_call, title: "SpecialCastingCall")
|
|
|
|
click_link create_casting_call_interview_button
|
|
expect(page).to have_content new_casting_call_interview_heading
|
|
|
|
fill_in performer_name_field, with: "TestName"
|
|
select cc.title, from: casting_call_field
|
|
fill_in zoom_meeting_url_field, with: "malformed url"
|
|
|
|
expect do
|
|
click_on submit_casting_call_interview_form
|
|
end.to change(CastingCallInterview, :count).by(0)
|
|
expect(page).to have_content zoom_meeting_url_invalid_error
|
|
|
|
fill_in zoom_meeting_url_field, with: "https://similar.google.com/j/24324324?pwd=334kni3j4"
|
|
|
|
expect do
|
|
click_on submit_casting_call_interview_form
|
|
end.to change(CastingCallInterview, :count).by(0)
|
|
expect(page).to have_content zoom_meeting_url_invalid_error
|
|
|
|
fill_in zoom_meeting_url_field, with: "https://s01.zoom.us/j/343434?pwd=dawidj34ijij"
|
|
|
|
expect do
|
|
click_on submit_casting_call_interview_form
|
|
end.to change(CastingCallInterview, :count).by(1)
|
|
expect(page).to have_content create_casting_call_interview_button
|
|
end
|
|
|
|
scenario "when creating new casting call interview - interview recording field is not visible" do
|
|
visit admin_casting_call_interviews_path
|
|
|
|
click_on create_casting_call_interview_button
|
|
|
|
expect(page).to have_content new_casting_call_interview_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_call_interview, casting_call: cc)
|
|
|
|
expect(CastingCallInterview.last.interview_recording).not_to be_attached
|
|
|
|
visit edit_admin_casting_call_interview_path(cci)
|
|
|
|
expect(page).to have_content edit_casting_call_interview_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_call_interview_button
|
|
expect(page).to have_content casting_call_updated_message
|
|
expect(CastingCallInterview.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_call_interview, :with_interview_recording, casting_call: cc)
|
|
|
|
expect(CastingCallInterview.last.interview_recording).to be_attached
|
|
|
|
visit edit_admin_casting_call_interview_path(cci)
|
|
|
|
expect(page).to have_content edit_casting_call_interview_heading
|
|
expect(page).to have_content current_interview_recording_label
|
|
expect(page).to have_link CastingCallInterview.last.interview_recording.attachment.blob.filename.to_s
|
|
end
|
|
|
|
private
|
|
|
|
def create_casting_call_interview_button
|
|
t 'admin.casting_call_interviews.index.actions.new'
|
|
end
|
|
|
|
def new_casting_call_interview_heading
|
|
t 'admin.casting_call_interviews.new.heading'
|
|
end
|
|
|
|
def submit_casting_call_interview_form
|
|
t 'helpers.submit.casting_call_interview.create'
|
|
end
|
|
|
|
def zoom_meeting_url_invalid_error
|
|
t 'casting_call_interviews.validation_errors.invalid_meeting_url'
|
|
end
|
|
|
|
def performer_name_field
|
|
'casting_call_interview[performer_name]'
|
|
end
|
|
|
|
def zoom_meeting_url_field
|
|
'casting_call_interview[zoom_meeting_url]'
|
|
end
|
|
|
|
def casting_call_field
|
|
'casting_call_interview[casting_call_id]'
|
|
end
|
|
|
|
def create_casting_call_interview_button
|
|
'Create Casting Call Interview'
|
|
end
|
|
|
|
def update_casting_call_interview_button
|
|
'Update Casting call interview'
|
|
end
|
|
|
|
def edit_casting_call_interview_heading
|
|
'Edit Casting Call Interview'
|
|
end
|
|
|
|
def new_casting_call_interview_heading
|
|
'New Casting Call Interview'
|
|
end
|
|
|
|
def interview_recording_field
|
|
'casting_call_interview[interview_recording]'
|
|
end
|
|
|
|
def current_interview_recording_label
|
|
'Current interview recording'
|
|
end
|
|
|
|
def casting_call_updated_message
|
|
'The casting call interview has been updated'
|
|
end
|
|
end
|