Cast me sync
This commit is contained in:
@@ -1,124 +0,0 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Admin::CastingCallInterviewsController, type: :controller do
|
||||
|
||||
let!(:current_user) { create(:user, :admin) }
|
||||
|
||||
before do
|
||||
sign_in(current_user)
|
||||
end
|
||||
|
||||
describe "#index" do
|
||||
it "returns a successful response" do
|
||||
get :index
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
end
|
||||
|
||||
describe "#new" do
|
||||
it "returns a successful response" do
|
||||
get :new
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it "assigns user, accounts" do
|
||||
get :new
|
||||
|
||||
expect(assigns(:casting_call_interview)).not_to be_nil
|
||||
expect(assigns(:accounts)).to eq Account.all
|
||||
end
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
it "does create a new record" do
|
||||
expect {
|
||||
post :create, params: { casting_call_interview: casting_call_interview_params }
|
||||
}.to change(CastingCallInterview, :count)
|
||||
end
|
||||
|
||||
it "does not create new record if zoom meeting url is not valid" do
|
||||
expect {
|
||||
post :create, params: {
|
||||
casting_call_interview: casting_call_interview_params
|
||||
.except(:zoom_meeting_url)
|
||||
.merge(zoom_meeting_url: "malformed_url")
|
||||
}
|
||||
}.to change(CastingCallInterview, :count).by(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#edit" do
|
||||
let(:casting_call_interview) { create(:casting_call_interview) }
|
||||
|
||||
it "returns a successful response" do
|
||||
get :edit, params: { id: casting_call_interview }
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it "assigns casting call interview" do
|
||||
get :edit, params: { id: casting_call_interview }
|
||||
|
||||
expect(assigns(:casting_call_interview)).to eq casting_call_interview
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
let(:casting_call_interview) { create(:casting_call_interview) }
|
||||
|
||||
it "redirects to casting call interviews page" do
|
||||
patch :update, params: { id: casting_call_interview, casting_call_interview: update_params }
|
||||
|
||||
expect(response).to be_redirect
|
||||
expect(response).to redirect_to admin_casting_call_interviews_path
|
||||
end
|
||||
|
||||
it "sets a flash notice" do
|
||||
patch :update, params: { id: casting_call_interview, casting_call_interview: update_params }
|
||||
|
||||
expect(flash.notice).to eq "The casting call interview has been updated"
|
||||
end
|
||||
|
||||
it "updates casting call interview" do
|
||||
patch :update, params: { id: casting_call_interview, casting_call_interview: update_params }
|
||||
|
||||
expect(casting_call_interview.reload.zoom_meeting_url).to eq new_zoom_meeting_url
|
||||
end
|
||||
end
|
||||
|
||||
describe "#complete" do
|
||||
let(:casting_call_interview) { create(:casting_call_interview) }
|
||||
|
||||
it "sets interviewed_at on casting call interview" do
|
||||
expect(casting_call_interview.interviewed_at).to be_nil
|
||||
|
||||
post :complete, params: { id: casting_call_interview }
|
||||
|
||||
expect(casting_call_interview.reload.interviewed_at).not_to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def casting_call_interview_params
|
||||
casting_call = create(:casting_call)
|
||||
|
||||
attributes_for(:casting_call_interview).except(:interviewed_at).merge(casting_call_id: casting_call.id)
|
||||
end
|
||||
|
||||
def update_params
|
||||
{
|
||||
zoom_meeting_url: new_zoom_meeting_url
|
||||
}
|
||||
end
|
||||
|
||||
def new_zoom_meeting_url
|
||||
"https://s01web.zoom.us/j/11111?pwd=Ab123Cq34"
|
||||
end
|
||||
|
||||
def invalid_meeting_url_flash_error
|
||||
t 'casting_call_interviews.validation_errors.invalid_meeting_url'
|
||||
end
|
||||
end
|
||||
124
spec/controllers/admin/casting_submissions_controller_spec.rb
Normal file
124
spec/controllers/admin/casting_submissions_controller_spec.rb
Normal file
@@ -0,0 +1,124 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Admin::CastingSubmissionsController, type: :controller do
|
||||
|
||||
let!(:current_user) { create(:user, :admin) }
|
||||
|
||||
before do
|
||||
sign_in(current_user)
|
||||
end
|
||||
|
||||
describe "#index" do
|
||||
it "returns a successful response" do
|
||||
get :index
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
end
|
||||
|
||||
describe "#new" do
|
||||
it "returns a successful response" do
|
||||
get :new
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it "assigns user, accounts" do
|
||||
get :new
|
||||
|
||||
expect(assigns(:casting_submission)).not_to be_nil
|
||||
expect(assigns(:accounts)).to eq Account.all
|
||||
end
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
it "does create a new record" do
|
||||
expect {
|
||||
post :create, params: { casting_submission: casting_submission_params }
|
||||
}.to change(CastingSubmission, :count)
|
||||
end
|
||||
|
||||
it "does not create new record if zoom meeting url is not valid" do
|
||||
expect {
|
||||
post :create, params: {
|
||||
casting_submission: casting_submission_params
|
||||
.except(:zoom_meeting_url)
|
||||
.merge(zoom_meeting_url: "malformed_url")
|
||||
}
|
||||
}.to change(CastingSubmission, :count).by(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#edit" do
|
||||
let(:casting_submission) { create(:casting_submission) }
|
||||
|
||||
it "returns a successful response" do
|
||||
get :edit, params: { id: casting_submission }
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it "assigns casting submission" do
|
||||
get :edit, params: { id: casting_submission }
|
||||
|
||||
expect(assigns(:casting_submission)).to eq casting_submission
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
let(:casting_submission) { create(:casting_submission) }
|
||||
|
||||
it "redirects to casting submissions page" do
|
||||
patch :update, params: { id: casting_submission, casting_submission: update_params }
|
||||
|
||||
expect(response).to be_redirect
|
||||
expect(response).to redirect_to admin_casting_submissions_path
|
||||
end
|
||||
|
||||
it "sets a flash notice" do
|
||||
patch :update, params: { id: casting_submission, casting_submission: update_params }
|
||||
|
||||
expect(flash.notice).to eq "The casting submission has been updated"
|
||||
end
|
||||
|
||||
it "updates casting submission" do
|
||||
patch :update, params: { id: casting_submission, casting_submission: update_params }
|
||||
|
||||
expect(casting_submission.reload.zoom_meeting_url).to eq new_zoom_meeting_url
|
||||
end
|
||||
end
|
||||
|
||||
describe "#complete" do
|
||||
let(:casting_submission) { create(:casting_submission) }
|
||||
|
||||
it "sets interviewed_at on casting submission" do
|
||||
expect(casting_submission.interviewed_at).to be_nil
|
||||
|
||||
post :complete, params: { id: casting_submission }
|
||||
|
||||
expect(casting_submission.reload.interviewed_at).not_to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def casting_submission_params
|
||||
casting_call = create(:casting_call)
|
||||
|
||||
attributes_for(:casting_submission).except(:interviewed_at).merge(casting_call_id: casting_call.id)
|
||||
end
|
||||
|
||||
def update_params
|
||||
{
|
||||
zoom_meeting_url: new_zoom_meeting_url
|
||||
}
|
||||
end
|
||||
|
||||
def new_zoom_meeting_url
|
||||
"https://s01web.zoom.us/j/11111?pwd=Ab123Cq34"
|
||||
end
|
||||
|
||||
def invalid_meeting_url_flash_error
|
||||
t 'casting_submissions.validation_errors.invalid_meeting_url'
|
||||
end
|
||||
end
|
||||
@@ -1,12 +1,12 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe InterviewDownloadsController, type: :controller do
|
||||
RSpec.describe CastingSubmissionDownloadsController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:current_user) { create(:user) }
|
||||
let(:project) { create(:project, :discovery_client, account: current_user.primary_account) }
|
||||
let(:casting_call) { create(:casting_call, project: project, title: "My Title") }
|
||||
let(:casting_call_interview) { create(:casting_call_interview, casting_call: casting_call, performer_name: "John Doe") }
|
||||
let(:casting_submission) { create(:casting_submission, casting_call: casting_call, performer_name: "John Doe") }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
@@ -15,13 +15,13 @@ RSpec.describe InterviewDownloadsController, type: :controller do
|
||||
describe "#create" do
|
||||
it "enqueues zip file generation job" do
|
||||
expect {
|
||||
post :create, params: { project_id: project.id, casting_call_interview_id: casting_call_interview.id }, format: :js
|
||||
}.to have_enqueued_job(GenerateInterviewFilesZipJob)
|
||||
post :create, params: { project_id: project.id, casting_submission_id: casting_submission.id }, format: :js
|
||||
}.to have_enqueued_job(GenerateCastingSubmissionFilesZipJob)
|
||||
end
|
||||
|
||||
it "creates a download record with 'not_started' status" do
|
||||
expect {
|
||||
post :create, params: { project_id: project.id, casting_call_interview_id: casting_call_interview.id }, format: :js
|
||||
post :create, params: { project_id: project.id, casting_submission_id: casting_submission.id }, format: :js
|
||||
}.to change(Download, :count).by(1)
|
||||
|
||||
expect(Download.last.status).to eq('not_started')
|
||||
@@ -29,11 +29,11 @@ RSpec.describe InterviewDownloadsController, type: :controller do
|
||||
|
||||
context "When there is no existing job" do
|
||||
it "shows a notification to user" do
|
||||
allow(ProjectsChannel).to receive(:broadcast_download_generation_update).with(be_kind_of(Download), I18n.t("interview_downloads.download.pending", release_type: "Casting Call Interview"))
|
||||
allow(ProjectsChannel).to receive(:broadcast_download_generation_update).with(be_kind_of(Download), I18n.t("casting_submission_downloads.download.pending", release_type: "CastingSubmission"))
|
||||
|
||||
post :create, params: { project_id: project.id, casting_call_interview_id: casting_call_interview.id }, format: :js
|
||||
post :create, params: { project_id: project.id, casting_submission_id: casting_submission.id }, format: :js
|
||||
|
||||
expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(be_kind_of(Download), I18n.t("interview_downloads.download.pending", release_type: "Casting Call Interview"))
|
||||
expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(be_kind_of(Download), I18n.t("casting_submission_downloads.download.pending", release_type: "CastingSubmission"))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,9 +47,9 @@ RSpec.describe InterviewDownloadsController, type: :controller do
|
||||
end
|
||||
|
||||
it "shows names of other contracts in the notification, which are in progress" do
|
||||
broadcast_message = "<p>Your Casting Call Interview files are being prepared for download. You will be notified when it's ready.\n</p>\n<p class=\"mt-3\">The following downloads are also in progress:</p> \n<ul>\n <li>Acquired Media Release contracts (as of less than a minute ago)\n </li>\n <li>Appearance Release contracts (as of less than a minute ago)\n </li>\n</ul>\n"
|
||||
broadcast_message = "<p>Your Casting Submission files are being prepared for download. You will be notified when it's ready.\n</p>\n<p class=\"mt-3\">The following downloads are also in progress:</p> \n<ul>\n <li>Acquired Media Release contracts (as of less than a minute ago)\n </li>\n <li>Appearance Release contracts (as of less than a minute ago)\n </li>\n</ul>\n"
|
||||
|
||||
post :create, params: { project_id: project.id, casting_call_interview_id: casting_call_interview.id }, format: :js
|
||||
post :create, params: { project_id: project.id, casting_submission_id: casting_submission.id }, format: :js
|
||||
|
||||
expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(be_kind_of(Download), broadcast_message)
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe CastingCallInterviewsController, type: :controller do
|
||||
RSpec.describe CastingSubmissionsController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:user) { create(:user) }
|
||||
@@ -19,9 +19,9 @@ RSpec.describe CastingCallInterviewsController, type: :controller do
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it "only shows completed interviews" do
|
||||
create(:casting_call_interview, casting_call: casting_call, interviewed_at: Time.zone.now, performer_name: "John Doe")
|
||||
create(:casting_call_interview, casting_call: casting_call, interviewed_at: nil, performer_name: "Jane Doe")
|
||||
it "only shows completed submissions" do
|
||||
create(:casting_submission, casting_call: casting_call, interviewed_at: Time.zone.now, performer_name: "John Doe")
|
||||
create(:casting_submission, casting_call: casting_call, interviewed_at: nil, performer_name: "Jane Doe")
|
||||
|
||||
get :index, params: { project_id: project }
|
||||
|
||||
@@ -31,10 +31,10 @@ RSpec.describe CastingCallInterviewsController, type: :controller do
|
||||
end
|
||||
|
||||
describe "#show" do
|
||||
let!(:casting_call_interview) { create(:casting_call_interview, :with_files, casting_call: casting_call, interviewed_at: Time.zone.now, performer_name: "Jane Doe") }
|
||||
let!(:casting_submission) { create(:casting_submission, :with_files, casting_call: casting_call, interviewed_at: Time.zone.now, performer_name: "Jane Doe") }
|
||||
|
||||
it "shows files of casting call interview" do
|
||||
get :show, params: { project_id: project, id: casting_call_interview.id }
|
||||
it "shows files of casting submission" do
|
||||
get :show, params: { project_id: project, id: casting_submission.id }
|
||||
|
||||
expect(response.body).to have_content("Filename")
|
||||
expect(response.body).to have_content("location_photo.png")
|
||||
@@ -1,44 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Public::CastingCallInterviewsController, type: :controller do
|
||||
render_views
|
||||
|
||||
describe "#show" do
|
||||
let(:casting_call_interview) { create(:casting_call_interview) }
|
||||
|
||||
it "responds successfully" do
|
||||
get :show, params: { token: casting_call_interview.token }
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(assigns(:casting_call_interview)).to eq(casting_call_interview)
|
||||
end
|
||||
|
||||
it "shows casting call interview details" do
|
||||
get :show, params: { token: casting_call_interview.token }
|
||||
|
||||
expect(response.body).to have_content(casting_call_interview.performer_name)
|
||||
expect(response.body).to have_content(casting_call_interview.interview_date)
|
||||
expect(response.body).to have_link("Start Interview")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
let(:casting_call_interview) { create(:casting_call_interview) }
|
||||
|
||||
it "responds successfully" do
|
||||
patch :update, params: { token: casting_call_interview.token, casting_call_interview: casting_call_interview_params }
|
||||
|
||||
expect(response).to redirect_to casting_call_interview_url(token: casting_call_interview.token)
|
||||
expect(flash.notice).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def casting_call_interview_params
|
||||
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
|
||||
file = Rack::Test::UploadedFile.new(path, "application/pdf")
|
||||
|
||||
{ files: [file]}
|
||||
end
|
||||
end
|
||||
44
spec/controllers/public/casting_submissions_controller.rb
Normal file
44
spec/controllers/public/casting_submissions_controller.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Public::CastingSubmissionsController, type: :controller do
|
||||
render_views
|
||||
|
||||
describe "#show" do
|
||||
let(:casting_submission) { create(:casting_submission) }
|
||||
|
||||
it "responds successfully" do
|
||||
get :show, params: { token: casting_submission.token }
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(assigns(:casting_submission)).to eq(casting_submission)
|
||||
end
|
||||
|
||||
it "shows casting call interview details" do
|
||||
get :show, params: { token: casting_submission.token }
|
||||
|
||||
expect(response.body).to have_content(casting_submission.performer_name)
|
||||
expect(response.body).to have_content(casting_submission.interview_date)
|
||||
expect(response.body).to have_link("Start Interview")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
let(:casting_submission) { create(:casting_submission) }
|
||||
|
||||
it "responds successfully" do
|
||||
patch :update, params: { token: casting_submission.token, casting_submission: casting_submission_params }
|
||||
|
||||
expect(response).to redirect_to casting_submission_url(token: casting_submission.token)
|
||||
expect(flash.notice).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def casting_submission_params
|
||||
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
|
||||
file = Rack::Test::UploadedFile.new(path, "application/pdf")
|
||||
|
||||
{ files: [file]}
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
FactoryBot.define do
|
||||
factory :casting_call_interview do
|
||||
factory :casting_submission do
|
||||
association :casting_call
|
||||
performer_name 'John Doe'
|
||||
zoom_meeting_url 'https://us04web.zoom.us/j/1111111111?pwd=aDZCS1dzZ2lWdDZJcHBhVnNIclB4QT03'
|
||||
@@ -1,71 +0,0 @@
|
||||
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
|
||||
|
||||
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
|
||||
end
|
||||
71
spec/features/admin_managing_casting_submissions_spec.rb
Normal file
71
spec/features/admin_managing_casting_submissions_spec.rb
Normal file
@@ -0,0 +1,71 @@
|
||||
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 "admin cannot create casting submission with invalid zoom url", js: true do
|
||||
visit admin_casting_submissions_path
|
||||
cc = create(:casting_call, title: "SpecialCastingCall")
|
||||
|
||||
click_link create_casting_submission_button
|
||||
expect(page).to have_content new_casting_submission_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_submission_form
|
||||
end.to change(CastingSubmission, :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_submission_form
|
||||
end.to change(CastingSubmission, :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_submission_form
|
||||
end.to change(CastingSubmission, :count).by(1)
|
||||
expect(page).to have_content create_casting_submission_button
|
||||
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 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
|
||||
end
|
||||
@@ -38,11 +38,11 @@ feature "User managing casting calls" do
|
||||
expect(page).to have_content no_casting_calls_label
|
||||
click_on add_new_casting_call_label
|
||||
|
||||
fill_in title_field, with: "Title"
|
||||
fill_in title_field, with: "Casting Title"
|
||||
fill_in description_field, with: "Description"
|
||||
fill_in project_description_field, with: "Project Description"
|
||||
fill_in interview_instructions_field, with: "Interview instructions"
|
||||
fill_in interview_requirements_field, with: "Interview requirements"
|
||||
fill_in interview_instructions_field, with: "Welcome Message"
|
||||
fill_in interview_requirements_field, with: "Goodbye Message"
|
||||
fill_in questions_field, with: "Questions"
|
||||
|
||||
click_on "Create Casting call"
|
||||
@@ -89,26 +89,26 @@ feature "User managing casting calls" do
|
||||
end
|
||||
|
||||
def title_field
|
||||
t "casting_calls.form.labels.title"
|
||||
t "helpers.label.casting_call.title"
|
||||
end
|
||||
|
||||
def description_field
|
||||
t "casting_calls.form.labels.description"
|
||||
t "helpers.label.casting_call.description"
|
||||
end
|
||||
|
||||
def project_description_field
|
||||
t "casting_calls.form.labels.project_description"
|
||||
t "helpers.label.casting_call.project_description"
|
||||
end
|
||||
|
||||
def interview_instructions_field
|
||||
t "casting_calls.form.labels.interview_instructions"
|
||||
t "helpers.label.casting_call.interview_instructions"
|
||||
end
|
||||
|
||||
def interview_requirements_field
|
||||
t "casting_calls.form.labels.interview_requirements"
|
||||
t "helpers.label.casting_call.interview_requirements"
|
||||
end
|
||||
|
||||
def questions_field
|
||||
t "casting_calls.form.labels.questions"
|
||||
t "helpers.label.casting_call.questions"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,52 +1,52 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe GenerateInterviewFilesZipJob do
|
||||
describe GenerateCastingSubmissionFilesZipJob do
|
||||
let(:project) { create(:project) }
|
||||
let(:download) { create(:download, project: project, release_type: "CastingCallInterview", name: "my-title_john-doe") }
|
||||
let(:download) { create(:download, project: project, release_type: "CastingSubmission", name: "my-title_john-doe") }
|
||||
let(:casting_call) { create(:casting_call, project: project, title: "My Title") }
|
||||
let(:casting_call_interview) { create(:casting_call_interview, casting_call: casting_call, performer_name: "John Doe") }
|
||||
let(:casting_submission) { create(:casting_submission, casting_call: casting_call, performer_name: "John Doe") }
|
||||
|
||||
before do
|
||||
dir = Rails.root.join("spec", "fixtures", "files")
|
||||
files = ["contract.pdf", "AppearanceRelease.pdf"]
|
||||
# Attachments in the test environment do not persist to cloud storage
|
||||
# Therefore we want to stub calls to `open` with a cloud storage URL
|
||||
allow_any_instance_of(InterviewFilesCollectionService).to receive(:open).and_return(StringIO.new("file data"))
|
||||
allow_any_instance_of(InterviewFilesCollectionService).to receive(:build).and_yield(dir, files)
|
||||
allow_any_instance_of(CastingSubmissionFilesCollectionService).to receive(:open).and_return(StringIO.new("file data"))
|
||||
allow_any_instance_of(CastingSubmissionFilesCollectionService).to receive(:build).and_yield(dir, files)
|
||||
end
|
||||
|
||||
describe ".perform_later" do
|
||||
it "enqueues a background job for generating zip file" do
|
||||
expect {
|
||||
GenerateInterviewFilesZipJob.perform_later(project, download, casting_call_interview)
|
||||
GenerateCastingSubmissionFilesZipJob.perform_later(project, download, casting_submission)
|
||||
}.to have_enqueued_job
|
||||
end
|
||||
end
|
||||
|
||||
describe ".perform_now" do
|
||||
it "updates a download record and creates attachment for it" do
|
||||
GenerateInterviewFilesZipJob.perform_now(project, download, casting_call_interview)
|
||||
GenerateCastingSubmissionFilesZipJob.perform_now(project, download, casting_submission)
|
||||
|
||||
expect(download.project).to eq project
|
||||
expect(download.release_type).to eq "CastingCallInterview"
|
||||
expect(download.release_type).to eq "CastingSubmission"
|
||||
expect(download.name).to eq "my-title_john-doe"
|
||||
expect(download.status).to eq "success"
|
||||
expect(download.file).to be_attached
|
||||
end
|
||||
|
||||
context "When there are errors" do
|
||||
let(:error) { StandardError.new("Casting Call Interview files not found.") }
|
||||
let(:error) { StandardError.new("Casting Submission files not found.") }
|
||||
|
||||
before do
|
||||
allow(ProjectsChannel).to receive(:broadcast_download_generation_update).with(download, I18n.t("interview_downloads.download.failure"))
|
||||
allow_any_instance_of(InterviewFilesCollectionService).to receive(:build).and_raise(StandardError, "Casting Call Interview files not found.")
|
||||
allow(ProjectsChannel).to receive(:broadcast_download_generation_update).with(download, I18n.t("casting_submission_downloads.download.failure"))
|
||||
allow_any_instance_of(CastingSubmissionFilesCollectionService).to receive(:build).and_raise(StandardError, "Casting Submission files not found.")
|
||||
end
|
||||
|
||||
it "updates status to 'failure' and sends user a notification" do
|
||||
GenerateInterviewFilesZipJob.perform_now(project, download, casting_call_interview)
|
||||
GenerateCastingSubmissionFilesZipJob.perform_now(project, download, casting_submission)
|
||||
|
||||
expect(download.status).to eq "failure"
|
||||
expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(download, I18n.t("interview_downloads.download.failure"))
|
||||
expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(download, I18n.t("casting_submission_downloads.download.failure"))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -137,7 +137,7 @@ RSpec.describe Account do
|
||||
MatchingRequest,
|
||||
ActionMailbox::InboundEmail, # This is Rails model, we are not using it and it is NOT added to the Account#storage_total calculation
|
||||
CastingCall,
|
||||
CastingCallInterview
|
||||
CastingSubmission
|
||||
]
|
||||
Rails.application.eager_load!
|
||||
ActiveRecord::Base.descendants.each do |model|
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CastingCallInterview, type: :model do
|
||||
subject { build(:casting_call_interview) }
|
||||
RSpec.describe CastingSubmission, type: :model do
|
||||
subject { build(:casting_submission) }
|
||||
|
||||
describe "associations" do
|
||||
it { is_expected.to belong_to(:casting_call) }
|
||||
it { is_expected.to have_secure_token(:token) }
|
||||
Reference in New Issue
Block a user