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
|
||||
Reference in New Issue
Block a user