Cast me sync

This commit is contained in:
Senad Uka
2020-07-17 04:50:04 +02:00
parent 96b31b71cf
commit e3acdb4d0e
53 changed files with 678 additions and 635 deletions

View File

@@ -11,6 +11,7 @@ $body-color: #4A4A4A;
$primary: #6F89FF; $primary: #6F89FF;
$blue: #0092ff; $blue: #0092ff;
$red: #F9002B; $red: #F9002B;
$dark-red: #CE004A;
$green: #51B61B; $green: #51B61B;
$teal: #32C498; $teal: #32C498;
$purple: #5139EE; $purple: #5139EE;

View File

@@ -69,6 +69,13 @@ label {
} }
} }
&.cast-me {
span:last-child {
background-color: $dark-red;
color: $white;
}
}
&.disabled { &.disabled {
span:last-child { span:last-child {
background-color: $gray-500 !important; background-color: $gray-500 !important;

View File

@@ -1,61 +0,0 @@
class Admin::CastingCallInterviewsController < Admin::ApplicationController
before_action :set_casting_call_interview, only: [:edit, :update, :show, :complete]
before_action :build_casting_call_interview, only: [:new, :create]
before_action :set_accounts, only: %i[new create edit]
def index
@casting_call_interviews = casting_call_interviews.order_by_recent.paginate(page: params[:page])
end
def create
@casting_call_interview.attributes = casting_call_interview_params
if @casting_call_interview.save
redirect_to [:admin, :casting_call_interviews], notice: t(".notice")
else
render :new
end
end
def update
if @casting_call_interview.update(casting_call_interview_params)
redirect_to [:admin, :casting_call_interviews], notice: t(".notice")
else
render :edit
end
end
def complete
if @casting_call_interview.update(interviewed_at: Time.zone.now)
redirect_to [:admin, :casting_call_interviews], notice: t(".notice")
else
redirect_to [:admin, :casting_call_interviews], notice: t(".alert")
end
end
private
def set_accounts
@accounts = accounts
end
def casting_call_interview_params
params.require(:casting_call_interview).permit(:casting_call_id, :performer_name, :interview_date, :zoom_meeting_url)
end
def casting_call_interviews
policy_scope CastingCallInterview
end
def set_casting_call_interview
@casting_call_interview = authorize policy_scope(CastingCallInterview).find(params[:id])
end
def accounts
policy_scope Account
end
def build_casting_call_interview
@casting_call_interview = authorize policy_scope(CastingCallInterview).build
end
end

View File

@@ -0,0 +1,61 @@
class Admin::CastingSubmissionsController < Admin::ApplicationController
before_action :set_casting_submission, only: [:edit, :update, :show, :complete]
before_action :build_casting_submission, only: [:new, :create]
before_action :set_accounts, only: %i[new create edit]
def index
@casting_submissions = casting_submissions.order_by_recent.paginate(page: params[:page])
end
def create
@casting_submission.attributes = casting_submission_params
if @casting_submission.save
redirect_to [:admin, :casting_submissions], notice: t(".notice")
else
render :new
end
end
def update
if @casting_submission.update(casting_submission_params)
redirect_to [:admin, :casting_submissions], notice: t(".notice")
else
render :edit
end
end
def complete
if @casting_submission.update(interviewed_at: Time.zone.now)
redirect_to [:admin, :casting_submissions], notice: t(".notice")
else
redirect_to [:admin, :casting_submissions], notice: t(".alert")
end
end
private
def set_accounts
@accounts = accounts
end
def casting_submission_params
params.require(:casting_submission).permit(:casting_call_id, :performer_name, :interview_date, :zoom_meeting_url)
end
def casting_submissions
policy_scope CastingSubmission
end
def set_casting_submission
@casting_submission = authorize policy_scope(CastingSubmission).find(params[:id])
end
def accounts
policy_scope Account
end
def build_casting_submission
@casting_submission = authorize policy_scope(CastingSubmission).build
end
end

View File

@@ -1,28 +0,0 @@
class CastingCallInterviewsController < ApplicationController
before_action :set_project
before_action :set_casting_call_interview, only: [:show]
include ProjectLayout
def index
@casting_call_interviews = casting_call_interviews.completed.order_by_recent.paginate(page: params[:page])
end
def show
@files = @casting_call_interview.files.paginate(page: params[:page])
end
private
def set_project
@project = policy_scope(Project).find(params[:project_id])
end
def set_casting_call_interview
@casting_call_interview = authorize casting_call_interviews.find(params[:id])
end
def casting_call_interviews
authorize policy_scope(CastingCallInterview)
end
end

View File

@@ -0,0 +1,30 @@
class CastingSubmissionDownloadsController < ApplicationController
include ProjectContext
before_action :set_project, only: [:create]
before_action :set_casting_submission, only: :create
include ProjectLayout
def create
download = @project.downloads.create!(name: @casting_submission.zip_file_name, release_type: "CastingSubmission")
other_downloads_in_progress = @project.downloads.unfinished_desc_order.offset(1)
if other_downloads_in_progress.any?
in_progress_downloads_details = render_to_string "_other_pending_downloads", locals: { downloads: other_downloads_in_progress, release_type: "CastingSubmission" }, :layout => false
ProjectsChannel.broadcast_download_generation_update(download, in_progress_downloads_details)
else
ProjectsChannel.broadcast_download_generation_update(download, I18n.t("casting_submission_downloads.download.pending", release_type: "CastingSubmission"))
end
GenerateCastingSubmissionFilesZipJob.perform_later(@project, download, @casting_submission)
end
private
def set_casting_submission
authorize(Download)
@casting_submission = policy_scope(@project.casting_submissions).find(params[:casting_submission_id])
end
end

View File

@@ -0,0 +1,28 @@
class CastingSubmissionsController < ApplicationController
before_action :set_project
before_action :set_casting_submission, only: [:show]
include ProjectLayout
def index
@casting_submissions = casting_submissions.completed.order_by_recent.paginate(page: params[:page])
end
def show
@files = @casting_submission.files.paginate(page: params[:page])
end
private
def set_project
@project = policy_scope(Project).find(params[:project_id])
end
def set_casting_submission
@casting_submission = authorize casting_submissions.find(params[:id])
end
def casting_submissions
authorize policy_scope(CastingSubmission)
end
end

View File

@@ -1,30 +0,0 @@
class InterviewDownloadsController < ApplicationController
include ProjectContext
before_action :set_project, only: [:create]
before_action :set_casting_call_interview, only: :create
include ProjectLayout
def create
download = @project.downloads.create!(name: @casting_call_interview.zip_file_name, release_type: "CastingCallInterview")
other_downloads_in_progress = @project.downloads.unfinished_desc_order.offset(1)
if other_downloads_in_progress.any?
in_progress_downloads_details = render_to_string "_other_pending_downloads", locals: { downloads: other_downloads_in_progress, release_type: "CastingCallInterview" }, :layout => false
ProjectsChannel.broadcast_download_generation_update(download, in_progress_downloads_details)
else
ProjectsChannel.broadcast_download_generation_update(download, I18n.t("interview_downloads.download.pending", release_type: "Casting Call Interview"))
end
GenerateInterviewFilesZipJob.perform_later(@project, download, @casting_call_interview)
end
private
def set_casting_call_interview
authorize(Download)
@casting_call_interview = policy_scope(@project.casting_call_interviews).find(params[:casting_call_interview_id])
end
end

View File

@@ -1,25 +0,0 @@
class Public::CastingCallInterviewsController < Public::BaseController
skip_after_action :verify_authorized
before_action :set_casting_call_interview, only: [:show, :update]
def show
end
def update
if @casting_call_interview.update(casting_call_interview_params)
redirect_to casting_call_interview_url(token: @casting_call_interview.token), notice: t(".notice")
else
render :show
end
end
private
def set_casting_call_interview
@casting_call_interview = CastingCallInterview.find_by_token(params[:token])
end
def casting_call_interview_params
params.require(:casting_call_interview).permit(files: [])
end
end

View File

@@ -0,0 +1,25 @@
class Public::CastingSubmissionsController < Public::BaseController
skip_after_action :verify_authorized
before_action :set_casting_submission, only: [:show, :update]
def show
end
def update
if @casting_submission.update(casting_submission_params)
redirect_to casting_submission_url(token: @casting_submission.token), notice: t(".notice")
else
render :show
end
end
private
def set_casting_submission
@casting_submission = CastingSubmission.find_by_token(params[:token])
end
def casting_submission_params
params.require(:casting_submission).permit(files: [])
end
end

View File

@@ -1,4 +1,4 @@
class GenerateInterviewFilesZipJob < ApplicationJob class GenerateCastingSubmissionFilesZipJob < ApplicationJob
queue_as :default queue_as :default
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
include ActionView::Helpers::UrlHelper include ActionView::Helpers::UrlHelper
@@ -6,12 +6,12 @@ class GenerateInterviewFilesZipJob < ApplicationJob
before_perform do |job| before_perform do |job|
@project = job.arguments.first @project = job.arguments.first
@download = job.arguments.second @download = job.arguments.second
@casting_call_interview = job.arguments.third @casting_submission = job.arguments.third
@download.update!(status: :pending) @download.update!(status: :pending)
end end
def perform(project, download, casting_call_interview) def perform(project, download, casting_submission)
::InterviewFilesCollectionService.new(casting_call_interview.files, @download.name).build do |dir, files| ::CastingSubmissionFilesCollectionService.new(casting_submission.files, @download.name).build do |dir, files|
zipfile_name = "#{dir}/#{@download.name}.zip" zipfile_name = "#{dir}/#{@download.name}.zip"
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
files.each do |attachment| files.each do |attachment|
@@ -24,11 +24,11 @@ class GenerateInterviewFilesZipJob < ApplicationJob
rescue StandardError => e rescue StandardError => e
Raven.extra_context( Raven.extra_context(
message: "Failed to generate download for project (##{project.id})", message: "Failed to generate download for project (##{project.id})",
release_type: "CastingCallInterview" release_type: "CastingSubmission"
) )
@download.failure! @download.failure!
ProjectsChannel.broadcast_download_generation_update(@download, I18n.t("interview_downloads.download.failure")) ProjectsChannel.broadcast_download_generation_update(@download, I18n.t("casting_submission_downloads.download.failure"))
end end
after_perform do |job| after_perform do |job|
@@ -37,7 +37,7 @@ class GenerateInterviewFilesZipJob < ApplicationJob
downloads_folder_link = link_to("Files > Downloads", project_downloads_path(I18n.locale, @project)) downloads_folder_link = link_to("Files > Downloads", project_downloads_path(I18n.locale, @project))
download_button = link_to("Download", rails_blob_path(@download.file, disposition: "attachment", only_path: true), class: "btn btn-success", target: :_blank) download_button = link_to("Download", rails_blob_path(@download.file, disposition: "attachment", only_path: true), class: "btn btn-success", target: :_blank)
ProjectsChannel.broadcast_download_generation_update(@download, I18n.t("interview_downloads.download.success", downloads_folder_link: downloads_folder_link, download_button: download_button, release_type: "Casting Call Interview")) ProjectsChannel.broadcast_download_generation_update(@download, I18n.t("casting_submission_downloads.download.success", downloads_folder_link: downloads_folder_link, download_button: download_button, release_type: "Casting Submission"))
end end
end end
end end

View File

@@ -5,7 +5,7 @@ class Account < ApplicationRecord
has_many :users, through: :account_auths has_many :users, through: :account_auths
has_many :projects, dependent: :destroy has_many :projects, dependent: :destroy
has_many :casting_calls, through: :projects has_many :casting_calls, through: :projects
has_many :casting_call_interviews, through: :projects has_many :casting_submissions, through: :projects
has_many :videos, through: :projects has_many :videos, through: :projects
has_many :contract_templates, through: :projects has_many :contract_templates, through: :projects
@@ -62,7 +62,7 @@ class Account < ApplicationRecord
MiscRelease.where(project: projects), MiscRelease.where(project: projects),
MatchingRequest.where(project: projects), MatchingRequest.where(project: projects),
CastingCall.where(project: projects), CastingCall.where(project: projects),
self.casting_call_interviews, self.casting_submissions,
self self
])).sum(:byte_size).to_f ])).sum(:byte_size).to_f
end end

View File

@@ -1,6 +1,6 @@
class CastingCall < ApplicationRecord class CastingCall < ApplicationRecord
belongs_to :project belongs_to :project
has_many :casting_call_interviews, dependent: :destroy has_many :casting_submissions, dependent: :destroy
has_secure_token has_secure_token

View File

@@ -1,4 +1,4 @@
class CastingCallInterview < ApplicationRecord class CastingSubmission < ApplicationRecord
belongs_to :casting_call belongs_to :casting_call
has_many_attached :files has_many_attached :files
@@ -33,6 +33,6 @@ class CastingCallInterview < ApplicationRecord
private private
def invalid_meeting_url_message def invalid_meeting_url_message
I18n.t('casting_call_interviews.validation_errors.invalid_meeting_url') I18n.t('casting_submissions.validation_errors.invalid_meeting_url')
end end
end end

View File

@@ -16,7 +16,7 @@ class Project < ApplicationRecord
has_many :medical_releases, dependent: :destroy has_many :medical_releases, dependent: :destroy
has_many :misc_releases, dependent: :destroy has_many :misc_releases, dependent: :destroy
has_many :casting_calls, dependent: :destroy has_many :casting_calls, dependent: :destroy
has_many :casting_call_interviews, through: :casting_calls has_many :casting_submissions, through: :casting_calls
has_many :videos, dependent: :destroy has_many :videos, dependent: :destroy
has_many :imports, dependent: :destroy has_many :imports, dependent: :destroy
has_many :contract_templates, dependent: :destroy has_many :contract_templates, dependent: :destroy

View File

@@ -1,4 +1,4 @@
class CastingCallInterviewPolicy < ApplicationPolicy class CastingSubmissionPolicy < ApplicationPolicy
def index? def index?
true true
end end

View File

@@ -41,7 +41,7 @@ class ProjectPolicy < ApplicationPolicy
show? show?
end end
def show_casting_call_interview_results? def show_casting_submission_results?
show? show?
end end
end end

View File

@@ -1,4 +1,4 @@
class InterviewFilesCollectionService class CastingSubmissionFilesCollectionService
def initialize(files, folder_name) def initialize(files, folder_name)
@files = files @files = files
@folder_name = folder_name @folder_name = folder_name
@@ -21,4 +21,4 @@ class InterviewFilesCollectionService
private private
attr_reader :files, :folder_name attr_reader :files, :folder_name
end end

View File

@@ -11,7 +11,7 @@
<%= link_to fa_icon("tasks fw", text: "Task Requests"), [:admin, :task_requests], class: class_string("nav-link", "active" => controller_name == "task_requests") %> <%= link_to fa_icon("tasks fw", text: "Task Requests"), [:admin, :task_requests], class: class_string("nav-link", "active" => controller_name == "task_requests") %>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<%= link_to fa_icon("video-camera fw", text: "Casting Call Interviews"), [:admin, :casting_call_interviews], class: class_string("nav-link", "active" => controller_name == "casting_call_interviews") %> <%= link_to fa_icon("video-camera fw", text: "Casting Submissions"), [:admin, :casting_submissions], class: class_string("nav-link", "active" => controller_name == "casting_submissions") %>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<%= link_to fa_icon("bug fw", text: "Errors"), "https://sentry.io/bigmedia/", class: "nav-link", target: :_blank %> <%= link_to fa_icon("bug fw", text: "Errors"), "https://sentry.io/bigmedia/", class: "nav-link", target: :_blank %>

View File

@@ -1,6 +0,0 @@
<div class="card shadow-sm">
<%= card_header text: "Edit Casting Call Interview", close_action_path: [:admin, :casting_call_interviews] %>
<div class="card-body">
<%= render "form", model: [:admin, @casting_call_interview], casting_call_interview: @casting_call_interview %>
</div>
</div>

View File

@@ -1,6 +0,0 @@
<div class="card shadow-sm">
<%= card_header text: t(".heading"), close_action_path: [:admin, :casting_call_interviews] %>
<div class="card-body">
<%= render "form", model: [:admin, @casting_call_interview], casting_call_interview: @casting_call_interview, casting_calls: @casting_calls %>
</div>
</div>

View File

@@ -1,24 +1,24 @@
<tr id="<%= dom_id(casting_call_interview) %>"> <tr id="<%= dom_id(casting_submission) %>">
<td> <td>
<%= casting_call_interview.casting_call.project.account.name.titleize %> <%= casting_submission.casting_call.project.account.name.titleize %>
</td> </td>
<td> <td>
<%= casting_call_interview.casting_call.title.titleize %> <%= casting_submission.casting_call.title.titleize %>
</td> </td>
<td> <td>
<%= casting_call_interview.performer_name %> <%= casting_submission.performer_name %>
</td> </td>
<td> <td>
<%= casting_call_interview.interview_date %> <%= casting_submission.interview_date %>
</td> </td>
<td class="text-right"> <td class="text-right">
<div class="btn-group"> <div class="btn-group">
<%= button_tag "Manage", class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %> <%= button_tag "Manage", class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %>
<div class="dropdown-menu dropdown-menu-right"> <div class="dropdown-menu dropdown-menu-right">
<%= link_to fa_icon("video-camera", text: "View"), casting_call_interview_url(token: casting_call_interview.token), target: "_blank", class: "dropdown-item" %> <%= link_to fa_icon("video-camera", text: "View"), casting_submission_url(token: casting_submission.token), target: "_blank", class: "dropdown-item" %>
<%= link_to fa_icon("pencil", text: "Edit"), [:edit, :admin, casting_call_interview], class: "dropdown-item" %> <%= link_to fa_icon("pencil", text: "Edit"), [:edit, :admin, casting_submission], class: "dropdown-item" %>
<% unless casting_call_interview.interviewed_at.present? %> <% unless casting_submission.interviewed_at.present? %>
<%= link_to fa_icon("check", text: "Complete"), [:complete, :admin, casting_call_interview], method: :post, class: "dropdown-item" %> <%= link_to fa_icon("check", text: "Complete"), [:complete, :admin, casting_submission], method: :post, class: "dropdown-item" %>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@@ -1,4 +1,4 @@
<%= errors_summary_for casting_call_interview %> <%= errors_summary_for casting_submission %>
<%= bootstrap_form_with model: model, local: true do |form| %> <%= bootstrap_form_with model: model, local: true do |form| %>
<%= form.text_field :performer_name, required: true %> <%= form.text_field :performer_name, required: true %>
@@ -7,9 +7,9 @@
<%= form.text_field :zoom_meeting_url %> <%= form.text_field :zoom_meeting_url %>
<div class="row align-items-center text-center mt-4"> <div class="row align-items-center text-center mt-4">
<%= link_to t("shared.cancel"), [:admin, :casting_call_interviews], class: "col-3 text-reset" %> <%= link_to t("shared.cancel"), [:admin, :casting_submissions], class: "col-3 text-reset" %>
<div class="col-9"> <div class="col-9">
<%= form.submit class: class_string("btn btn-block", ["btn-success", "btn-primary"] => casting_call_interview.new_record?), data: { disable_with: t("shared.disable_with") } %> <%= form.submit class: class_string("btn btn-block", ["btn-success", "btn-primary"] => casting_submission.new_record?), data: { disable_with: t("shared.disable_with") } %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@@ -0,0 +1,6 @@
<div class="card shadow-sm">
<%= card_header text: "Edit Casting Submission", close_action_path: [:admin, :casting_submissions] %>
<div class="card-body">
<%= render "form", model: [:admin, @casting_submission], casting_submission: @casting_submission %>
</div>
</div>

View File

@@ -1,6 +1,6 @@
<div class="d-flex flex-row justify-content-between align-items-center mb-3"> <div class="d-flex flex-row justify-content-between align-items-center mb-3">
<% if policy(CastingCall).new? %> <% if policy(CastingCall).new? %>
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, :admin, :casting_call_interview], class: "btn btn-primary mb-3" %> <%= link_to fa_icon("plus", text: t(".actions.new")), [:new, :admin, :casting_submission], class: "btn btn-primary mb-3" %>
<% end %> <% end %>
</div> </div>
@@ -16,8 +16,8 @@
</tr> </tr>
</thead> </thead>
<tbody id="users"> <tbody id="users">
<% if @casting_call_interviews.any? %> <% if @casting_submissions.any? %>
<%= render @casting_call_interviews %> <%= render @casting_submissions %>
<% else %> <% else %>
<tr> <tr>
<td colspan="20" class="py-4 text-center text-muted"><%= t(".empty") %></td> <td colspan="20" class="py-4 text-center text-muted"><%= t(".empty") %></td>
@@ -27,6 +27,6 @@
</table> </table>
</div> </div>
<div id="casting_call_interviews_pagination" class="mt-3"> <div id="casting_submissions_pagination" class="mt-3">
<%= will_paginate @casting_call_interviews %> <%= will_paginate @casting_submissions %>
</div> </div>

View File

@@ -0,0 +1,6 @@
<div class="card shadow-sm">
<%= card_header text: t(".heading"), close_action_path: [:admin, :casting_submissions] %>
<div class="card-body">
<%= render "form", model: [:admin, @casting_submission], casting_submission: @casting_submission, casting_calls: @casting_calls %>
</div>
</div>

View File

@@ -1,27 +0,0 @@
<tr id="<%= dom_id(casting_call_interview) %>">
<td>
<%= casting_call_interview.casting_call.project.account.name.titleize %>
</td>
<td>
<%= casting_call_interview.casting_call.title&.titleize %>
</td>
<td>
<%= casting_call_interview.performer_name %>
</td>
<td>
<%= casting_call_interview.interviewed_at %>
</td>
<td class="text-right">
<div class="btn-group">
<%= button_tag "Manage", class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %>
<div class="dropdown-menu dropdown-menu-right">
<% if policy(CastingCallInterview).show? %>
<%= link_to fa_icon("video-camera", text: "View"), [@project, casting_call_interview], target: "_blank", class: "dropdown-item" %>
<% end %>
<% if policy(CastingCallInterview).download? %>
<%= link_to fa_icon("download", text: "Download"), [@project, :interview_downloads, casting_call_interview_id: casting_call_interview.id], method: :post, remote: true, class: "dropdown-item" %>
<% end %>
</div>
</div>
</td>
</tr>

View File

@@ -6,12 +6,14 @@
<strong><%= t '.info_message' %></strong> <strong><%= t '.info_message' %></strong>
</div> </div>
<%= form.text_field :title, label: t('.labels.title') %> <%= form.text_field :title %>
<%= form.text_area :description, label: t('.labels.description') %> <%= form.text_area :description %>
<%= form.text_area :project_description, label: t('.labels.project_description') %> <%= form.text_area :project_description %>
<%= form.text_area :interview_instructions, label: t('.labels.interview_instructions') %> <%= field_set_tag "Chatbot" do %>
<%= form.text_area :interview_requirements, label: t('.labels.interview_requirements') %> <%= form.text_area :interview_instructions, rows: 6 %>
<%= form.text_area :questions, label: t('.labels.questions') %> <%= form.text_area :questions, rows: 8 %>
<%= form.text_area :interview_requirements, rows: 6 %>
<% end %>
<div class="row align-items-center text-center mt-4"> <div class="row align-items-center text-center mt-4">
<%= link_to t("shared.cancel"), [project, :casting_calls], class: "col-3 text-reset" %> <%= link_to t("shared.cancel"), [project, :casting_calls], class: "col-3 text-reset" %>
@@ -19,4 +21,4 @@
<%= form.submit class: class_string("btn btn-block", ["btn-success", "btn-primary"] => casting_call.new_record?), data: { disable_with: t("shared.disable_with") } %> <%= form.submit class: class_string("btn btn-block", ["btn-success", "btn-primary"] => casting_call.new_record?), data: { disable_with: t("shared.disable_with") } %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@@ -6,7 +6,7 @@
<% if download.release_type == "reports"%> <% if download.release_type == "reports"%>
<li><%= download.release_type.titleize %> (as of <%= time_ago_in_words(download.created_at) %> ago) <li><%= download.release_type.titleize %> (as of <%= time_ago_in_words(download.created_at) %> ago)
</li> </li>
<% elsif download.release_type == "CastingCallInterview"%> <% elsif download.release_type == "CastingSubmission"%>
<li><%= download.release_type.titleize %> files (as of <%= time_ago_in_words(download.created_at) %> ago) <li><%= download.release_type.titleize %> files (as of <%= time_ago_in_words(download.created_at) %> ago)
</li> </li>
<% else %> <% else %>

View File

@@ -0,0 +1,27 @@
<tr id="<%= dom_id(casting_submission) %>">
<td>
<%= casting_submission.casting_call.project.account.name.titleize %>
</td>
<td>
<%= casting_submission.casting_call.title&.titleize %>
</td>
<td>
<%= casting_submission.performer_name %>
</td>
<td>
<%= casting_submission.interviewed_at %>
</td>
<td class="text-right">
<div class="btn-group">
<%= button_tag "Manage", class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %>
<div class="dropdown-menu dropdown-menu-right">
<% if policy(CastingSubmission).show? %>
<%= link_to fa_icon("video-camera", text: "View"), [@project, casting_submission], target: "_blank", class: "dropdown-item" %>
<% end %>
<% if policy(CastingSubmission).download? %>
<%= link_to fa_icon("download", text: "Download"), [@project, :casting_submission_downloads, casting_submission_id: casting_submission.id], method: :post, remote: true, class: "dropdown-item" %>
<% end %>
</div>
</div>
</td>
</tr>

View File

@@ -10,8 +10,8 @@
</tr> </tr>
</thead> </thead>
<tbody id="users"> <tbody id="users">
<% if @casting_call_interviews.any? %> <% if @casting_submissions.any? %>
<%= render @casting_call_interviews %> <%= render @casting_submissions %>
<% else %> <% else %>
<tr> <tr>
<td colspan="20" class="py-4 text-center text-muted"><%= t(".empty") %></td> <td colspan="20" class="py-4 text-center text-muted"><%= t(".empty") %></td>
@@ -21,6 +21,6 @@
</table> </table>
</div> </div>
<div id="casting_call_interviews_pagination" class="mt-3"> <div id="casting_submissions_pagination" class="mt-3">
<%= will_paginate @casting_call_interviews %> <%= will_paginate @casting_submissions %>
</div> </div>

View File

@@ -21,9 +21,9 @@
<%= link_to t("projects.show.tasks"), [@project, :tasks], class: "text-decoration-none text-reset stretched-link" %> <%= link_to t("projects.show.tasks"), [@project, :tasks], class: "text-decoration-none text-reset stretched-link" %>
<% end %> <% end %>
<% end %> <% end %>
<% if policy(Project).show_casting_call_interview_results? %> <% if policy(Project).show_casting_submission_results? %>
<%= render "folder_card" do %> <%= render "folder_card" do %>
<%= link_to t("projects.show.casting_call_interviews"), [@project, :casting_call_interviews], class: "text-decoration-none text-reset stretched-link" %> <%= link_to t("projects.show.casting_submissions"), [@project, :casting_submissions], class: "text-decoration-none text-reset stretched-link" %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>

View File

@@ -1,11 +1,11 @@
<div class="card shadow-sm"> <div class="card shadow-sm">
<%= card_header text: "Casting call interview details" %> <%= card_header text: "Casting submission details" %>
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<dl> <dl>
<%= description_list_pair_for @casting_call_interview, :performer_name, append: ":" %> <%= description_list_pair_for @casting_submission, :performer_name, append: ":" %>
<%= description_list_pair_for @casting_call_interview, :interview_date, append: ":" %> <%= description_list_pair_for @casting_submission, :interview_date, append: ":" %>
</dl> </dl>
</div> </div>
</div> </div>
@@ -16,14 +16,14 @@
<div class="card shadow-sm"> <div class="card shadow-sm">
<%= card_header text: t(".heading") %> <%= card_header text: t(".heading") %>
<div class="card-body"> <div class="card-body">
<%= errors_summary_for @casting_call_interview %> <%= errors_summary_for @casting_submission %>
<%= bootstrap_form_with model: @casting_call_interview, url: casting_call_interview_path(token: @casting_call_interview.token), local: true do |form| %> <%= bootstrap_form_with model: @casting_submission, url: casting_submission_path(token: @casting_submission.token), local: true do |form| %>
<div class="field d-none"> <div class="field d-none">
<%= form.label :files %> <%= form.label :files %>
<%= form.file_field :files, disable: true, direct_upload: true, multiple: true, id: "casting_call_interivew_files", hide_label: true %> <%= form.file_field :files, disable: true, direct_upload: true, multiple: true, id: "casting_call_interivew_files", hide_label: true %>
<% @casting_call_interview.files.each do |file| %> <% @casting_submission.files.each do |file| %>
<% unless file.persisted? %> <% unless file.persisted? %>
<%= hidden_field_tag "#{@casting_call_interview.model_name.param_key}[files][]", file.signed_id %> <%= hidden_field_tag "#{@casting_submission.model_name.param_key}[files][]", file.signed_id %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
@@ -32,8 +32,8 @@
data-accepted-files="audio/*,image/*,video/*" data-accepted-files="audio/*,image/*,video/*"
data-behavior="dropzone" data-behavior="dropzone"
data-file-input-id="casting_call_interivew_files" data-file-input-id="casting_call_interivew_files"
data-existing-files="<%= mock_photos_json(@casting_call_interview.files) %>" data-existing-files="<%= mock_photos_json(@casting_submission.files) %>"
data-placeholder="<%= dropzone_placeholder_message_for(@casting_call_interview) %>" data-placeholder="<%= dropzone_placeholder_message_for(@casting_submission) %>"
data-submit-button="#submit_folder"></div> data-submit-button="#submit_folder"></div>
<div class="mt-5"> <div class="mt-5">
@@ -45,7 +45,7 @@
</div> </div>
</div> </div>
<div class="row align-items-center justify-content-center mt-3"> <div class="row align-items-center justify-content-center mt-3">
<%= link_to "Start Interview", @casting_call_interview.join_zoom_meeting_url, target: "_blank", class: "btn btn-primary" %> <%= link_to "Start Interview", @casting_submission.join_zoom_meeting_url, target: "_blank", class: "btn btn-primary" %>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -70,6 +70,9 @@ en:
person_phone: Phone person_phone: Phone
person_photo: Photo person_photo: Photo
signed_on: Date signed_on: Date
casting_call:
interview_instructions: Welcome message
interview_requirements: Goodbye message
location_release: location_release:
person_company: Company person_company: Company
person_email: Email person_email: Email
@@ -97,22 +100,22 @@ en:
application: application:
header: header:
sign_out: Sign Out sign_out: Sign Out
casting_call_interviews: casting_submissions:
complete: complete:
notice: The casting call interview has been completed notice: The casting submission has been completed
create: create:
notice: The casting call interview has been created notice: The casting submission has been created
index: index:
actions: actions:
new: Create Casting Call Interview new: Create Casting Submission
empty: Casting call interviews will appear here empty: Casting submissions will appear here
mark_as_completed: mark_as_completed:
alert: Failed to mark casting call interview as completed alert: Failed to mark casting submission as completed
notice: The casting call interview has been marked as completed notice: The casting submission has been marked as completed
new: new:
heading: New Casting Call Interview heading: New Casting Submission
update: update:
notice: The casting call interview has been updated notice: The casting submission has been updated
task_requests: task_requests:
index: index:
empty: Task requests will appear here empty: Task requests will appear here
@@ -244,11 +247,11 @@ en:
bulk_taggings: bulk_taggings:
new_bulk_tag_modal: new_bulk_tag_modal:
submit: Add submit: Add
casting_call_interviews: casting_submissions:
index: index:
empty: Casting Call Interview results will appear here. empty: Casting Submission results will appear here.
show: show:
empty: Interview files and recorded meeetings will appear here. empty: Casting Submission files and recorded meeetings will appear here.
validation_errors: validation_errors:
invalid_meeting_url: Zoom Meeting URL is invalid invalid_meeting_url: Zoom Meeting URL is invalid
casting_calls: casting_calls:
@@ -264,13 +267,6 @@ en:
heading: Edit Casting Call heading: Edit Casting Call
form: form:
info_message: After submitting this casting call request, you'll be connected via chat with a ME Suite representative. info_message: After submitting this casting call request, you'll be connected via chat with a ME Suite representative.
labels:
description: Description
interview_instructions: Interview instructions
interview_requirements: Interview requirements
project_description: Project description
questions: Questions
title: Title
index: index:
actions: actions:
new: Create Casting Call new: Create Casting Call
@@ -278,11 +274,21 @@ en:
table_headers: table_headers:
casting_call_created_on: Created On casting_call_created_on: Created On
casting_call_status: Status casting_call_status: Status
casting_call_title: Title casting_call_title: Casting Title
new: new:
heading: New Casting Call heading: New Casting Call
update: update:
notice: The casting call request has been updated notice: The casting call request has been updated
casting_submission_downloads:
download:
failure: Your download could not be generated.
pending: "Your %{release_type} files are being prepared for download. You will be notified when it's ready."
success: "Your %{release_type} files are ready. Download now, or retrieve later in the %{downloads_folder_link} folder. %{download_button}"
casting_submissions:
index:
empty: Casting Submission results will appear here.
show:
empty: Casting Submission files and recorded meeetings will appear here.
contract_downloads: contract_downloads:
download: download:
failure: Your download could not be generated. failure: Your download could not be generated.
@@ -416,6 +422,10 @@ en:
notice: The release has been updated notice: The release has been updated
helpers: helpers:
help: help:
casting_call:
interview_instructions: This is the first message the chatbot, BiGGiE, will send. Please include all information and instructions you wish the person to read prior to starting the casting interview.
interview_requirements: Please enter a final message and include any post-interview instructions (for example, submitting a headshot, additional photos, videos, etc).
questions: Please list, one-by-one, all of the questions you wish the chatbot, BiGGiE, to ask the person.
contract_template: contract_template:
fee: Leave at $0.00 for no-fee fee: Leave at $0.00 for no-fee
guardian_clause: Leave blank if not required for this contract guardian_clause: Leave blank if not required for this contract
@@ -474,6 +484,13 @@ en:
person_last_name: Last name person_last_name: Last name
person_name: Name person_name: Name
person_phone: Phone number person_phone: Phone number
casting_call:
description: Casting search description
interview_instructions: Welcome message
interview_requirements: Goodbye message
project_description: Project description
questions: Questions
title: Casting search title
location_release: location_release:
address_city: City address_city: City
address_country: Country address_country: Country
@@ -723,8 +740,8 @@ en:
broadcast: broadcast:
create: Create Live Stream create: Create Live Stream
update: Save Changes update: Save Changes
casting_call_interview: casting_submission:
create: Create casting call interview create: Create Casting Submission
contract_template: contract_template:
create: Create Release Template create: Create Release Template
directory: directory:
@@ -757,11 +774,6 @@ en:
cards: Cards cards: Cards
heading: Import Releases heading: Import Releases
list: List list: List
interview_downloads:
download:
failure: Your download could not be generated.
pending: "Your %{release_type} files are being prepared for download. You will be notified when it's ready."
success: "Your %{release_type} files are ready. Download now, or retrieve later in the %{downloads_folder_link} folder. %{download_button}"
location_releases: location_releases:
create: create:
notice: The location release has been created notice: The location release has been created
@@ -993,7 +1005,7 @@ en:
show: show:
acquired_media_release: Acquired Media Releases (%{count}) acquired_media_release: Acquired Media Releases (%{count})
appearance_release: Appearance Releases (%{count}) appearance_release: Appearance Releases (%{count})
casting_call_interviews: Interviews casting_submissions: Casting Submissions
downloads: Downloads downloads: Downloads
location_release: Location Releases (%{count}) location_release: Location Releases (%{count})
material_release: Material Releases (%{count}) material_release: Material Releases (%{count})
@@ -1056,7 +1068,7 @@ en:
broadcasts: broadcasts:
show: show:
alert: That broadcast is no longer available alert: That broadcast is no longer available
casting_call_interviews: casting_submissions:
show: show:
heading: Files heading: Files
update: Upload update: Upload

View File

@@ -76,7 +76,7 @@ es:
share_stream: Share live stream link with clients share_stream: Share live stream link with clients
stream_from_mobile_app: Stream from ME Suite Mobile app, or via a professional camera stream_from_mobile_app: Stream from ME Suite Mobile app, or via a professional camera
stream_multiple_cameras: Stream multiple cameras at one time stream_multiple_cameras: Stream multiple cameras at one time
casting_call_interviews: casting_submissions:
validation_errors: validation_errors:
invalid_meeting_url: Zoom Meeting URL is invalid (ES) invalid_meeting_url: Zoom Meeting URL is invalid (ES)
contract_templates: contract_templates:
@@ -275,8 +275,8 @@ es:
broadcast: broadcast:
create: Create Live Stream (ES) create: Create Live Stream (ES)
update: Save Changes (ES) update: Save Changes (ES)
casting_call_interview: casting_submission:
create: Create casting call interview (ES) create: Create casting submission (ES)
create: 'Crear %{model}' create: 'Crear %{model}'
update: 'Actualizar %{model}' update: 'Actualizar %{model}'
location_releases: location_releases:

View File

@@ -32,7 +32,7 @@ Rails.application.routes.draw do
resource :masquerade, only: :create resource :masquerade, only: :create
end end
resources :task_requests, only: [:index, :edit, :update, :show] resources :task_requests, only: [:index, :edit, :update, :show]
resources :casting_call_interviews do resources :casting_submissions do
post :complete, on: :member post :complete, on: :member
end end
@@ -69,7 +69,7 @@ Rails.application.routes.draw do
resource :contract_downloads, only: [:create] resource :contract_downloads, only: [:create]
resources :downloads, only: [:index, :destroy] resources :downloads, only: [:index, :destroy]
resource :report_downloads, only: [:create] resource :report_downloads, only: [:create]
resource :interview_downloads, only: [:create] resource :casting_submission_downloads, only: [:create]
resources :videos, only: [:index, :new, :create, :edit, :update] do resources :videos, only: [:index, :new, :create, :edit, :update] do
collection do collection do
get :landing get :landing
@@ -115,7 +115,7 @@ Rails.application.routes.draw do
end end
end end
resources :tasks, only: :index resources :tasks, only: :index
resources :casting_call_interviews, only: [:index, :show] resources :casting_submissions, only: [:index, :show]
end end
resource :profile, only: [:show, :update] resource :profile, only: [:show, :update]
resources :videos, only: [] do resources :videos, only: [] do
@@ -145,7 +145,7 @@ Rails.application.routes.draw do
resource :zoom_meeting, only: [:show] resource :zoom_meeting, only: [:show]
end end
resources :casting_calls, param: :token, only: [:show] resources :casting_calls, param: :token, only: [:show]
resources :casting_call_interviews, param: :token, only: [:show, :update] resources :casting_submissions, param: :token, only: [:show, :update]
end end
RELEASES = [:acquired_media_releases, :appearance_releases, :talent_releases, :material_releases, :location_releases] RELEASES = [:acquired_media_releases, :appearance_releases, :talent_releases, :material_releases, :location_releases]

View File

@@ -0,0 +1,5 @@
class RenameCastingCallInterviewsToCastingSubmissions < ActiveRecord::Migration[6.0]
def change
rename_table :casting_call_interviews, :casting_submissions
end
end

View File

@@ -331,8 +331,8 @@ CREATE TABLE public.appearance_releases (
person_last_name character varying, person_last_name character varying,
guardian_first_name character varying, guardian_first_name character varying,
guardian_last_name character varying, guardian_last_name character varying,
identifier character varying,
guardian_email character varying, guardian_email character varying,
identifier character varying,
person_address_street2 character varying, person_address_street2 character varying,
person_address_city character varying, person_address_city character varying,
person_address_state character varying, person_address_state character varying,
@@ -569,42 +569,6 @@ CREATE SEQUENCE public.broadcasts_id_seq
ALTER SEQUENCE public.broadcasts_id_seq OWNED BY public.broadcasts.id; ALTER SEQUENCE public.broadcasts_id_seq OWNED BY public.broadcasts.id;
--
-- Name: casting_call_interviews; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.casting_call_interviews (
id bigint NOT NULL,
casting_call_id bigint,
performer_name character varying,
zoom_meeting_url character varying,
interview_date timestamp without time zone,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
token character varying,
interviewed_at timestamp without time zone
);
--
-- Name: casting_call_interviews_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.casting_call_interviews_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: casting_call_interviews_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.casting_call_interviews_id_seq OWNED BY public.casting_call_interviews.id;
-- --
-- Name: casting_calls; Type: TABLE; Schema: public; Owner: - -- Name: casting_calls; Type: TABLE; Schema: public; Owner: -
-- --
@@ -645,6 +609,42 @@ CREATE SEQUENCE public.casting_calls_id_seq
ALTER SEQUENCE public.casting_calls_id_seq OWNED BY public.casting_calls.id; ALTER SEQUENCE public.casting_calls_id_seq OWNED BY public.casting_calls.id;
--
-- Name: casting_submissions; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.casting_submissions (
id bigint NOT NULL,
casting_call_id bigint,
performer_name character varying,
zoom_meeting_url character varying,
interview_date timestamp without time zone,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
token character varying,
interviewed_at timestamp without time zone
);
--
-- Name: casting_submissions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.casting_submissions_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: casting_submissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.casting_submissions_id_seq OWNED BY public.casting_submissions.id;
-- --
-- Name: composers; Type: TABLE; Schema: public; Owner: - -- Name: composers; Type: TABLE; Schema: public; Owner: -
-- --
@@ -742,6 +742,15 @@ CREATE SEQUENCE public.contract_templates_id_seq
ALTER SEQUENCE public.contract_templates_id_seq OWNED BY public.contract_templates.id; 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: - -- Name: directories; Type: TABLE; Schema: public; Owner: -
-- --
@@ -1483,7 +1492,6 @@ CREATE TABLE public.settings (
-- --
CREATE SEQUENCE public.settings_id_seq CREATE SEQUENCE public.settings_id_seq
AS integer
START WITH 1 START WITH 1
INCREMENT BY 1 INCREMENT BY 1
NO MINVALUE NO MINVALUE
@@ -1519,7 +1527,6 @@ CREATE TABLE public.taggings (
-- --
CREATE SEQUENCE public.taggings_id_seq CREATE SEQUENCE public.taggings_id_seq
AS integer
START WITH 1 START WITH 1
INCREMENT BY 1 INCREMENT BY 1
NO MINVALUE NO MINVALUE
@@ -1550,7 +1557,6 @@ CREATE TABLE public.tags (
-- --
CREATE SEQUENCE public.tags_id_seq CREATE SEQUENCE public.tags_id_seq
AS integer
START WITH 1 START WITH 1
INCREMENT BY 1 INCREMENT BY 1
NO MINVALUE NO MINVALUE
@@ -1911,9 +1917,9 @@ CREATE TABLE public.zoom_meetings (
api_meeting_id character varying, api_meeting_id character varying,
created_at timestamp(6) without time zone NOT NULL, created_at timestamp(6) without time zone NOT NULL,
updated_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, zoom_user_id bigint,
project_id bigint, project_id bigint
status integer DEFAULT 0
); );
@@ -2053,13 +2059,6 @@ ALTER TABLE ONLY public.broadcast_recordings ALTER COLUMN id SET DEFAULT nextval
ALTER TABLE ONLY public.broadcasts ALTER COLUMN id SET DEFAULT nextval('public.broadcasts_id_seq'::regclass); ALTER TABLE ONLY public.broadcasts ALTER COLUMN id SET DEFAULT nextval('public.broadcasts_id_seq'::regclass);
--
-- Name: casting_call_interviews id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.casting_call_interviews ALTER COLUMN id SET DEFAULT nextval('public.casting_call_interviews_id_seq'::regclass);
-- --
-- Name: casting_calls id; Type: DEFAULT; Schema: public; Owner: - -- Name: casting_calls id; Type: DEFAULT; Schema: public; Owner: -
-- --
@@ -2067,6 +2066,13 @@ ALTER TABLE ONLY public.casting_call_interviews ALTER COLUMN id SET DEFAULT next
ALTER TABLE ONLY public.casting_calls ALTER COLUMN id SET DEFAULT nextval('public.casting_calls_id_seq'::regclass); ALTER TABLE ONLY public.casting_calls ALTER COLUMN id SET DEFAULT nextval('public.casting_calls_id_seq'::regclass);
--
-- Name: casting_submissions id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.casting_submissions ALTER COLUMN id SET DEFAULT nextval('public.casting_submissions_id_seq'::regclass);
-- --
-- Name: composers id; Type: DEFAULT; Schema: public; Owner: - -- Name: composers id; Type: DEFAULT; Schema: public; Owner: -
-- --
@@ -2388,14 +2394,6 @@ ALTER TABLE ONLY public.broadcasts
ADD CONSTRAINT broadcasts_pkey PRIMARY KEY (id); ADD CONSTRAINT broadcasts_pkey PRIMARY KEY (id);
--
-- Name: casting_call_interviews casting_call_interviews_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.casting_call_interviews
ADD CONSTRAINT casting_call_interviews_pkey PRIMARY KEY (id);
-- --
-- Name: casting_calls casting_calls_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- Name: casting_calls casting_calls_pkey; Type: CONSTRAINT; Schema: public; Owner: -
-- --
@@ -2404,6 +2402,14 @@ ALTER TABLE ONLY public.casting_calls
ADD CONSTRAINT casting_calls_pkey PRIMARY KEY (id); ADD CONSTRAINT casting_calls_pkey PRIMARY KEY (id);
--
-- Name: casting_submissions casting_submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.casting_submissions
ADD CONSTRAINT casting_submissions_pkey PRIMARY KEY (id);
-- --
-- Name: composers composers_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- Name: composers composers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
-- --
@@ -2420,6 +2426,14 @@ ALTER TABLE ONLY public.contract_templates
ADD CONSTRAINT contract_templates_pkey PRIMARY KEY (id); 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: - -- Name: directories directories_pkey; Type: CONSTRAINT; Schema: public; Owner: -
-- --
@@ -2821,20 +2835,6 @@ CREATE INDEX index_broadcasts_on_project_id ON public.broadcasts USING btree (pr
CREATE UNIQUE INDEX index_broadcasts_on_token ON public.broadcasts USING btree (token); CREATE UNIQUE INDEX index_broadcasts_on_token ON public.broadcasts USING btree (token);
--
-- Name: index_casting_call_interviews_on_casting_call_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_casting_call_interviews_on_casting_call_id ON public.casting_call_interviews USING btree (casting_call_id);
--
-- Name: index_casting_call_interviews_on_token; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_casting_call_interviews_on_token ON public.casting_call_interviews USING btree (token);
-- --
-- Name: index_casting_calls_on_project_id; Type: INDEX; Schema: public; Owner: - -- Name: index_casting_calls_on_project_id; Type: INDEX; Schema: public; Owner: -
-- --
@@ -2849,6 +2849,20 @@ CREATE INDEX index_casting_calls_on_project_id ON public.casting_calls USING btr
CREATE UNIQUE INDEX index_casting_calls_on_token ON public.casting_calls USING btree (token); CREATE UNIQUE INDEX index_casting_calls_on_token ON public.casting_calls USING btree (token);
--
-- Name: index_casting_submissions_on_casting_call_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_casting_submissions_on_casting_call_id ON public.casting_submissions USING btree (casting_call_id);
--
-- Name: index_casting_submissions_on_token; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_casting_submissions_on_token ON public.casting_submissions USING btree (token);
-- --
-- Name: index_composers_on_music_release_id; Type: INDEX; Schema: public; Owner: - -- Name: index_composers_on_music_release_id; Type: INDEX; Schema: public; Owner: -
-- --
@@ -3447,10 +3461,10 @@ ALTER TABLE ONLY public.bookmarks
-- --
-- Name: casting_call_interviews fk_rails_1583f69fbb; Type: FK CONSTRAINT; Schema: public; Owner: - -- Name: casting_submissions fk_rails_1583f69fbb; Type: FK CONSTRAINT; Schema: public; Owner: -
-- --
ALTER TABLE ONLY public.casting_call_interviews ALTER TABLE ONLY public.casting_submissions
ADD CONSTRAINT fk_rails_1583f69fbb FOREIGN KEY (casting_call_id) REFERENCES public.casting_calls(id); ADD CONSTRAINT fk_rails_1583f69fbb FOREIGN KEY (casting_call_id) REFERENCES public.casting_calls(id);
@@ -4063,6 +4077,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200702152130'), ('20200702152130'),
('20200706193123'), ('20200706193123'),
('20200706230803'), ('20200706230803'),
('20200707070522'); ('20200707070522'),
('20200714175331');

View File

@@ -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

View 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

View File

@@ -1,12 +1,12 @@
require "rails_helper" require "rails_helper"
RSpec.describe InterviewDownloadsController, type: :controller do RSpec.describe CastingSubmissionDownloadsController, type: :controller do
render_views render_views
let(:current_user) { create(:user) } let(:current_user) { create(:user) }
let(:project) { create(:project, :discovery_client, account: current_user.primary_account) } 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) { 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 before do
sign_in current_user sign_in current_user
@@ -15,13 +15,13 @@ RSpec.describe InterviewDownloadsController, type: :controller do
describe "#create" do describe "#create" do
it "enqueues zip file generation job" do it "enqueues zip file generation job" do
expect { 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 have_enqueued_job(GenerateInterviewFilesZipJob) }.to have_enqueued_job(GenerateCastingSubmissionFilesZipJob)
end end
it "creates a download record with 'not_started' status" do it "creates a download record with 'not_started' status" do
expect { 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) }.to change(Download, :count).by(1)
expect(Download.last.status).to eq('not_started') 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 context "When there is no existing job" do
it "shows a notification to user" 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
end end
@@ -47,9 +47,9 @@ RSpec.describe InterviewDownloadsController, type: :controller do
end end
it "shows names of other contracts in the notification, which are in progress" do 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) expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(be_kind_of(Download), broadcast_message)
end end

View File

@@ -1,6 +1,6 @@
require "rails_helper" require "rails_helper"
RSpec.describe CastingCallInterviewsController, type: :controller do RSpec.describe CastingSubmissionsController, type: :controller do
render_views render_views
let(:user) { create(:user) } let(:user) { create(:user) }
@@ -19,9 +19,9 @@ RSpec.describe CastingCallInterviewsController, type: :controller do
expect(response).to be_successful expect(response).to be_successful
end end
it "only shows completed interviews" do it "only shows completed submissions" do
create(:casting_call_interview, casting_call: casting_call, interviewed_at: Time.zone.now, performer_name: "John Doe") create(:casting_submission, 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") create(:casting_submission, casting_call: casting_call, interviewed_at: nil, performer_name: "Jane Doe")
get :index, params: { project_id: project } get :index, params: { project_id: project }
@@ -31,10 +31,10 @@ RSpec.describe CastingCallInterviewsController, type: :controller do
end end
describe "#show" do 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 it "shows files of casting submission" do
get :show, params: { project_id: project, id: casting_call_interview.id } get :show, params: { project_id: project, id: casting_submission.id }
expect(response.body).to have_content("Filename") expect(response.body).to have_content("Filename")
expect(response.body).to have_content("location_photo.png") expect(response.body).to have_content("location_photo.png")

View File

@@ -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

View 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

View File

@@ -1,5 +1,5 @@
FactoryBot.define do FactoryBot.define do
factory :casting_call_interview do factory :casting_submission do
association :casting_call association :casting_call
performer_name 'John Doe' performer_name 'John Doe'
zoom_meeting_url 'https://us04web.zoom.us/j/1111111111?pwd=aDZCS1dzZ2lWdDZJcHBhVnNIclB4QT03' zoom_meeting_url 'https://us04web.zoom.us/j/1111111111?pwd=aDZCS1dzZ2lWdDZJcHBhVnNIclB4QT03'

View File

@@ -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

View 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

View File

@@ -38,11 +38,11 @@ feature "User managing casting calls" do
expect(page).to have_content no_casting_calls_label expect(page).to have_content no_casting_calls_label
click_on add_new_casting_call_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 description_field, with: "Description"
fill_in project_description_field, with: "Project Description" fill_in project_description_field, with: "Project Description"
fill_in interview_instructions_field, with: "Interview instructions" fill_in interview_instructions_field, with: "Welcome Message"
fill_in interview_requirements_field, with: "Interview requirements" fill_in interview_requirements_field, with: "Goodbye Message"
fill_in questions_field, with: "Questions" fill_in questions_field, with: "Questions"
click_on "Create Casting call" click_on "Create Casting call"
@@ -89,26 +89,26 @@ feature "User managing casting calls" do
end end
def title_field def title_field
t "casting_calls.form.labels.title" t "helpers.label.casting_call.title"
end end
def description_field def description_field
t "casting_calls.form.labels.description" t "helpers.label.casting_call.description"
end end
def project_description_field def project_description_field
t "casting_calls.form.labels.project_description" t "helpers.label.casting_call.project_description"
end end
def interview_instructions_field def interview_instructions_field
t "casting_calls.form.labels.interview_instructions" t "helpers.label.casting_call.interview_instructions"
end end
def interview_requirements_field def interview_requirements_field
t "casting_calls.form.labels.interview_requirements" t "helpers.label.casting_call.interview_requirements"
end end
def questions_field def questions_field
t "casting_calls.form.labels.questions" t "helpers.label.casting_call.questions"
end end
end end

View File

@@ -1,52 +1,52 @@
require "rails_helper" require "rails_helper"
describe GenerateInterviewFilesZipJob do describe GenerateCastingSubmissionFilesZipJob do
let(:project) { create(:project) } 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) { 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 before do
dir = Rails.root.join("spec", "fixtures", "files") dir = Rails.root.join("spec", "fixtures", "files")
files = ["contract.pdf", "AppearanceRelease.pdf"] files = ["contract.pdf", "AppearanceRelease.pdf"]
# Attachments in the test environment do not persist to cloud storage # Attachments in the test environment do not persist to cloud storage
# Therefore we want to stub calls to `open` with a cloud storage URL # 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(CastingSubmissionFilesCollectionService).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(:build).and_yield(dir, files)
end end
describe ".perform_later" do describe ".perform_later" do
it "enqueues a background job for generating zip file" do it "enqueues a background job for generating zip file" do
expect { expect {
GenerateInterviewFilesZipJob.perform_later(project, download, casting_call_interview) GenerateCastingSubmissionFilesZipJob.perform_later(project, download, casting_submission)
}.to have_enqueued_job }.to have_enqueued_job
end end
end end
describe ".perform_now" do describe ".perform_now" do
it "updates a download record and creates attachment for it" 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.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.name).to eq "my-title_john-doe"
expect(download.status).to eq "success" expect(download.status).to eq "success"
expect(download.file).to be_attached expect(download.file).to be_attached
end end
context "When there are errors" do 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 before do
allow(ProjectsChannel).to receive(:broadcast_download_generation_update).with(download, I18n.t("interview_downloads.download.failure")) allow(ProjectsChannel).to receive(:broadcast_download_generation_update).with(download, I18n.t("casting_submission_downloads.download.failure"))
allow_any_instance_of(InterviewFilesCollectionService).to receive(:build).and_raise(StandardError, "Casting Call Interview files not found.") allow_any_instance_of(CastingSubmissionFilesCollectionService).to receive(:build).and_raise(StandardError, "Casting Submission files not found.")
end end
it "updates status to 'failure' and sends user a notification" do 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(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 end
end end

View File

@@ -137,7 +137,7 @@ RSpec.describe Account do
MatchingRequest, MatchingRequest,
ActionMailbox::InboundEmail, # This is Rails model, we are not using it and it is NOT added to the Account#storage_total calculation ActionMailbox::InboundEmail, # This is Rails model, we are not using it and it is NOT added to the Account#storage_total calculation
CastingCall, CastingCall,
CastingCallInterview CastingSubmission
] ]
Rails.application.eager_load! Rails.application.eager_load!
ActiveRecord::Base.descendants.each do |model| ActiveRecord::Base.descendants.each do |model|

View File

@@ -1,7 +1,8 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe CastingCallInterview, type: :model do RSpec.describe CastingSubmission, type: :model do
subject { build(:casting_call_interview) } subject { build(:casting_submission) }
describe "associations" do describe "associations" do
it { is_expected.to belong_to(:casting_call) } it { is_expected.to belong_to(:casting_call) }
it { is_expected.to have_secure_token(:token) } it { is_expected.to have_secure_token(:token) }