This commit is contained in:
Senad Uka
2020-07-15 11:57:21 +02:00
parent 4c49a5db03
commit da8e187430
135 changed files with 1952 additions and 1115 deletions

View File

@@ -54,14 +54,16 @@ RSpec.describe AccountsController, type: :controller do
end
it "enqueues hubspot form submission job" do
ENV["HUBSPOT_FORM_GUID"] = "form_guid"
expect {
post :create, params: params
}.to have_enqueued_job(SubmitHubspotFormJob).with(
"John",
"Doe",
"test_user+1@test.com",
"Test Dev account",
i_m_interested_in: "DirectME"
first_name: "John",
last_name: "Doe",
email: "test_user+1@test.com",
company: "Test Dev account",
i_m_interested_in: "DirectME",
form_guid: "form_guid"
)
end
end

View File

@@ -0,0 +1,106 @@
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
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
end

View File

@@ -30,21 +30,6 @@ RSpec.describe Api::ContractTemplatesController, type: :controller do
expect(response).to be_successful
end
it 'returns electronic signature legal text when present' do
ct = create(:contract_template, name: 'ct1', project_id: project.id)
ct.signature_legal_text = "some electronic signature legal text"
ct.save
sign_in_to_api(current_user)
get :show, params: { id: ct.id }
expect(response).to be_successful
expect(response.body).to include("signature_legal_text")
expect(response.body).to include(ct.signature_legal_text.body.as_json)
end
end
private

View File

@@ -1,42 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::MedicalReleasesController, type: :controller do
let(:current_user) { create(:user) }
let(:project) { create(:project, name: 'first', account: current_user.primary_account) }
describe '#index' do
it 'returns a succesful response' do
create(:medical_release, person_first_name: 'John', person_last_name: 'Lee', project_id: project.id)
create(:medical_release, person_first_name: 'Jane', person_last_name: 'Lee', project_id: project.id)
sign_in_to_api(current_user)
get :index, params: { project_id: project.id }
expect(response).to be_successful
expect(response.body).to include 'John'
expect(response.body).to include 'Jane'
end
end
describe '#show' do
it 'returns a succesful response' do
release1 = create(:medical_release, person_first_name: 'John', person_last_name: 'Lee', project_id: project.id)
release2 = create(:medical_release, person_first_name: 'Jane', person_last_name: 'Lee', project_id: project.id)
sign_in_to_api(current_user)
get :show, params: { id: release1 }
expect(response).to be_successful
expect(response.body).to include 'John'
expect(response.body).not_to include 'Jane'
get :show, params: { id: release2 }
expect(response).to be_successful
expect(response.body).not_to include 'John'
expect(response.body).to include 'Jane'
end
end
end

View File

@@ -1,42 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::MiscReleasesController, type: :controller do
let(:current_user) { create(:user) }
let(:project) { create(:project, name: 'first', account: current_user.primary_account) }
describe '#index' do
it 'returns a succesful response' do
create(:misc_release, person_first_name: 'John', person_last_name: 'Lee', project_id: project.id)
create(:misc_release, person_first_name: 'Jane', person_last_name: 'Lee', project_id: project.id)
sign_in_to_api(current_user)
get :index, params: { project_id: project.id }
expect(response).to be_successful
expect(response.body).to include 'John'
expect(response.body).to include 'Jane'
end
end
describe '#show' do
it 'returns a succesful response' do
release1 = create(:misc_release, person_first_name: 'John', person_last_name: 'Lee', project_id: project.id)
release2 = create(:misc_release, person_first_name: 'Jane', person_last_name: 'Lee', project_id: project.id)
sign_in_to_api(current_user)
get :show, params: { id: release1 }
expect(response).to be_successful
expect(response.body).to include 'John'
expect(response.body).not_to include 'Jane'
get :show, params: { id: release2 }
expect(response).to be_successful
expect(response.body).not_to include 'John'
expect(response.body).to include 'Jane'
end
end
end

View File

@@ -18,14 +18,6 @@ releases = [
{
type: :material_release,
obligatory_attribute: :name
},
{
type: :medical_release,
obligatory_attribute: :person_name
},
{
type: :misc_release,
obligatory_attribute: :person_name
}
]

View File

@@ -110,33 +110,6 @@ RSpec.describe Api::SyncController, type: :controller do
expect(guardian_photo).to include('id', 'type', 'attributes')
expect(photo_attributes).to include('filename', 'content_type', 'url', 'thumbnail_url')
end
it 'contains misc releases' do
create_default_data
get :index
misc_releases = attributes_for_type('misc_releases')
expect(misc_releases.first).to include('id')
end
it 'contains misc releases' do
create_default_data
get :index
medical_releases = attributes_for_type('medical_releases')
expect(medical_releases.first).to include('id')
end
it 'contains signature legal text for contract templates' do
create_default_data_with_signature_legal_text
get :index
contract_templates = attributes_for_type('contract_templates')
expect(contract_templates.first).to include('signature_legal_text')
expect(contract_templates.first['signature_legal_text']).to eq ContractTemplate.first.signature_legal_text.as_json
end
end
private
@@ -147,8 +120,6 @@ RSpec.describe Api::SyncController, type: :controller do
create(:talent_release, project: project)
create(:location_release, project: project)
create(:material_release, project: project)
create(:medical_release, project: project)
create(:misc_release, project: project)
end
def create_default_data_with_guardian_info
@@ -156,13 +127,6 @@ RSpec.describe Api::SyncController, type: :controller do
create(:appearance_release, :minor_with_guardian_photo, project: project)
end
def create_default_data_with_signature_legal_text
create_default_data
ct = create(:contract_template, name: "with signature legal text", project: Project.first)
ct.signature_legal_text = "legal text example"
ct.save
end
def response_body_json
JSON.parse(response.body)
end

View File

@@ -1,36 +0,0 @@
require "rails_helper"
RSpec.describe ApprovalsController, type: :controller do
render_views
let(:user) { create(:user) }
let(:account) { user.primary_account }
let(:project) { create(:project, account: user.primary_account) }
before do
sign_in user
end
describe "#new" do
let!(:medical_release) { create(:medical_release, project: project) }
it "responds successfully" do
get :new, params: { medical_release_id: medical_release }
expect(response).to be_successful
end
end
describe "#create" do
it "changes approval status successfully" do
medical_release = create(:medical_release, project: project)
expect(MedicalRelease.last.approved?).to eq false
post :create, params: { medical_release_id: medical_release }
expect(response).to redirect_to [project, :medical_releases]
expect(MedicalRelease.last.approved?).to eq true
end
end
end

View File

@@ -0,0 +1,43 @@
require "rails_helper"
RSpec.describe CastingCallInterviewsController, type: :controller do
render_views
let(:user) { create(:user) }
let(:account) { user.primary_account }
let(:project) { create(:project, account: user.primary_account) }
let(:casting_call) { create(:casting_call, project: project, title: "My Interview") }
before do
sign_in(user)
end
describe "#index" do
it "returns a successful response" do
get :index, params: { project_id: project }
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")
get :index, params: { project_id: project }
expect(response.body).to have_content("John Doe")
expect(response.body).not_to have_content("Jane Doe")
end
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") }
it "shows files of casting call interview" do
get :show, params: { project_id: project, id: casting_call_interview.id }
expect(response.body).to have_content("Filename")
expect(response.body).to have_content("location_photo.png")
end
end
end

View File

@@ -0,0 +1,126 @@
require 'rails_helper'
RSpec.describe CastingCallsController, type: :controller do
render_views
let(:user) { create(:user) }
let(:account) { user.primary_account }
let(:project) { create(:project, account: user.primary_account) }
before do
sign_in user
end
describe "#index" do
it "responds successfully" do
get :index, params: { project_id: project }
expect(response).to be_successful
end
it "renders content" do
create(:casting_call, project: project)
get :index, params: { project_id: project }
expect(response.body).to have_link "Create Casting Call"
expect(response.body).to have_content "Active"
end
context "when there are many records" do
it "paginates the table" do
create_list(:casting_call, 20, project: project)
get :index, params: { project_id: project }
expect(response.body).to have_link("2", href: project_casting_calls_path(project, page: 2))
end
end
end
describe "#new" do
it "responds successfully" do
get :new, params: { project_id: project }
expect(response).to be_successful
expect(assigns(:casting_call)).to be_a_new(CastingCall)
expect(response).to render_template(:new)
end
end
describe "#create" do
it "does create a new record" do
expect {
post :create, params: { project_id: project.id, casting_call: casting_call_params }
}.to change(CastingCall, :count)
end
it "logs an event" do
expect {
post :create, params: { project_id: project.id, casting_call: casting_call_params }
}.to have_enqueued_job(TrackAnalyticsJob).with(user, account, :track_create_casting_call, user_agent: "Rails Testing", user_ip: "0.0.0.0")
end
it "submits data to hubspot form" do
expect {
post :create, params: { project_id: project.id, casting_call: casting_call_params }
}.to have_enqueued_job(SubmitHubspotFormJob)
end
end
describe "#update" do
let!(:casting_call) { create(:casting_call, project: project, description: "My description" ) }
it "updates casting call request" do
patch :update, params: { project_id: project.id, id: casting_call.id, casting_call: update_params }
expect(casting_call.reload.description).to eq("This is updated description")
end
end
describe "#show" do
let!(:casting_call) { create(:casting_call, project: project, description: "Casting Call Request") }
it "responds successfully" do
get :show, params: { project_id: project.id, id: casting_call.id }
expect(response).to be_successful
expect(assigns(:casting_call)).to eq(casting_call)
end
it "renders content" do
get :show, params: { project_id: project.id, id: casting_call.id }
expect(response.body).to have_content "Casting Call Request"
expect(response.body).to have_content "Active"
end
end
describe "#cancel" do
let!(:casting_call) { create(:casting_call, project: project, description: "Casting Call to be Cancelled") }
it "responds with redirect" do
post :cancel, params: { project_id: project.id, id: casting_call.id }
expect(response).to be_redirect
expect(response).to redirect_to(project_casting_calls_path(project))
expect(flash.notice).not_to be_nil
end
it "updates the status to 'Cancelled'" do
expect {
post :cancel, params: { project_id: project.id, id: casting_call.id }
}.to change { casting_call.reload.status }.from("Active").to("Cancelled")
end
end
private
def casting_call_params
attributes_for(:casting_call).except(:status, :user_email)
end
def update_params
{ description: "This is updated description" }
end
end

View File

@@ -0,0 +1,58 @@
require "rails_helper"
RSpec.describe InterviewDownloadsController, 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") }
before do
sign_in current_user
end
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)
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
}.to change(Download, :count).by(1)
expect(Download.last.status).to eq('not_started')
end
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"))
post :create, params: { project_id: project.id, casting_call_interview_id: casting_call_interview.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"))
end
end
context "When there are existing jobs" do
let(:appearance_release_download) { create(:download, project_id: project.id, name: "#{project.name.parameterize}_appearance-releases") }
let(:acquired_media_release_download) { create(:download, project_id: project.id, name: "#{project.name.parameterize}_acquired-media-releases", release_type: "AcquiredMediaRelease") }
before do
allow(Download).to receive_message_chain(:unfinished_desc_order, :offset).and_return([acquired_media_release_download, appearance_release_download])
allow(ProjectsChannel).to receive(:broadcast_download_generation_update)
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"
post :create, params: { project_id: project.id, casting_call_interview_id: casting_call_interview.id }, format: :js
expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(be_kind_of(Download), broadcast_message)
end
end
end
end

View File

@@ -0,0 +1,44 @@
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,28 @@
require 'rails_helper'
RSpec.describe Public::CastingCallsController, type: :controller do
render_views
describe "#show" do
let(:casting_call) { create(:casting_call) }
it "responds successfully" do
get :show, params: { token: casting_call.token }
expect(response).to be_successful
expect(assigns(:casting_call)).to eq(casting_call)
end
it "shows casting call details" do
get :show, params: { token: casting_call.token }
expect(response.body).to have_content(casting_call.title)
expect(response.body).to have_content(casting_call.description)
expect(response.body).to have_content(casting_call.project_description)
expect(response.body).to have_content(casting_call.interview_instructions)
expect(response.body).to have_content(casting_call.interview_requirements)
expect(response.body).to have_content(casting_call.questions)
expect(response.body).to have_link("Schedule an Audition")
end
end
end

View File

@@ -71,7 +71,7 @@ RSpec.describe TaskRequestsController, type: :controller do
it "submits data to hubspot form" do
expect {
post :create, params: { project_id: project.id, task_request: task_request_params }
}.to have_enqueued_job(SubmitHubspotTaskRequestFormJob)
}.to have_enqueued_job(SubmitHubspotFormJob)
end
end

View File

@@ -0,0 +1,13 @@
FactoryBot.define do
factory :casting_call_interview do
association :casting_call
performer_name 'John Doe'
zoom_meeting_url 'https://us04web.zoom.us/j/1111111111?pwd=aDZCS1dzZ2lWdDZJcHBhVnNIclB4QT03'
interview_date { 10.days.from_now }
interviewed_at { nil }
trait :with_files do
files { [Rack::Test::UploadedFile.new('spec/fixtures/files/location_photo.png', 'image/png')] }
end
end
end

View File

@@ -0,0 +1,15 @@
FactoryBot.define do
factory :casting_call do
association :project
user_email 'test@email.com'
description "Casting call description"
project_description "Casting call project description"
interview_instructions "Interview instructions"
interview_requirements "Interview requirements"
questions "Questions"
trait :cancelled do
cancelled_at { Time.zone.now }
end
end
end

View File

@@ -7,7 +7,6 @@ FactoryBot.define do
body "This is a test contract template."
guardian_clause "Is the signer a minor?"
fee "$0.00"
accessibility "public_template"
trait :archived do
archived_at Time.zone.now

View File

@@ -49,18 +49,12 @@ FactoryBot.define do
predefined_client_name "nat_geo"
end
factory :project_with_contract_template_public do
factory :project_with_contract_template do
after(:build) do |project, _|
project.contract_templates << build(:contract_template, project: nil)
end
end
factory :project_with_contract_template_private do
after(:build) do |project, _|
project.contract_templates << build(:contract_template, project: nil, accessibility: "private_template")
end
end
factory :project_with_directories do
after(:build) do |project, _|
project.directories << build(:directory, project: nil, name: "Shared")

View File

@@ -21,7 +21,6 @@ RSpec.feature 'User creates task request', type: :feature do
click_on 'Create Task request'
expect(page).to have_content task_created_message
expect(page).to have_link("Back")
end
scenario 'user can view task request details' do
@@ -90,4 +89,4 @@ RSpec.feature 'User creates task request', type: :feature do
def task_created_message
t 'task_requests.create.success_message'
end
end
end

View File

@@ -35,24 +35,6 @@ RSpec.feature 'User manages contract templates', type: :feature do
expect(page).to have_content(create_contract_template_success_message)
end
scenario 'creating new release template, all release types accept signature legal text' do
all_release_types = ['Acquired Media', 'Appearance', 'Location', 'Material', 'Medical', 'Misc', 'Talent']
all_release_types.each do |release_type|
visit new_project_contract_template_path(project)
dropdown_selection = "#{release_type} Release"
select dropdown_selection, from: 'Release type'
fill_in 'Name', with: "My #{release_type} template"
fill_in_trix signature_legal_text_field, with: 'LL'
expect do
click_on 'Create Release Template'
end.to change(ContractTemplate, :count).by(1)
end
end
scenario 'medical release template has a guardian clause field' do
visit new_project_contract_template_path(project)
@@ -240,7 +222,7 @@ RSpec.feature 'User manages contract templates', type: :feature do
click_on 'Manage'
accept_alert do
click_on 'Delete'
click_on 'Archive'
end
expect(page).to have_content('The release template has been archived')
@@ -291,7 +273,7 @@ RSpec.feature 'User manages contract templates', type: :feature do
visit project_contract_templates_path(project)
click_on 'Manage'
expect(page).to have_content('Delete')
expect(page).to have_content('Archive')
end
it 'does not show create release button on splash page' do
@@ -328,10 +310,6 @@ RSpec.feature 'User manages contract templates', type: :feature do
'contract_template_guardian_clause_trix_input_contract_template'
end
def signature_legal_text_field
'contract_template_signature_legal_text'
end
def create_contract_template_success_message
'The release template has been created'
end
@@ -351,8 +329,4 @@ RSpec.feature 'User manages contract templates', type: :feature do
def create_release_template
t 'contract_templates.splash.actions.create_template'
end
def signature_legal_text_trix_field
'Signature legal text'
end
end

View File

@@ -41,13 +41,6 @@ feature "User managing acquired_media releases" do
expect(AcquiredMediaRelease.last.categories).to include("Still Photograph")
expect(page).to have_content("Your release was successfully submitted. Thank you.")
end
scenario "creating a release, if contract template contains signature legal language, it is shown" do
contract_template = create(:contract_template, project: project, signature_legal_text: dummy_signature_legal_text)
visit new_account_project_contract_template_acquired_media_release_path(project.account, project, contract_template)
expect(page).to have_content dummy_signature_legal_text
end
end
context "when signed in" do
@@ -364,8 +357,4 @@ feature "User managing acquired_media releases" do
def destroy_release_alert
t "acquired_media_releases.destroy.alert"
end
def dummy_signature_legal_text
'Some signature legal language'
end
end

View File

@@ -137,13 +137,6 @@ feature 'User managing appearance releases' do
expect(page).to have_content(successful_submission_message)
expect(AppearanceRelease.last.guardian_2_first_name).to eq 'Second'
end
scenario "creating a release, if contract template contains signature legal language, it is shown" do
contract_template = create(:contract_template, project: project, signature_legal_text: dummy_signature_legal_text)
visit new_account_project_contract_template_appearance_release_path(project.account, project, contract_template)
expect(page).to have_content dummy_signature_legal_text
end
end
context 'when signed in' do
@@ -713,8 +706,4 @@ feature 'User managing appearance releases' do
def guardian_2_photo_heading
t 'appearance_releases.form.photos.guardian_2_photo.heading'
end
def dummy_signature_legal_text
'Some signature legal language'
end
end

View File

@@ -0,0 +1,114 @@
require "rails_helper"
feature "User managing casting calls" do
let(:current_user) { create(:user) }
let(:project) { create(:project, account: current_user.primary_account) }
before :each do
sign_in current_user
end
scenario "casting calls table is visible" do
visit project_casting_calls_path(project)
expect(page).to have_content "Created On"
expect(page).to have_content "Title"
expect(page).to have_content "Status"
end
scenario "sees list of casting calls" do
visit project_casting_calls_path(project)
expect(page).to have_content no_casting_calls_label
casting_call = create(:casting_call, project: project)
visit project_casting_calls_path(project)
expect(page).not_to have_content no_casting_calls_label
expect(page).to have_content casting_call.created_at.try(:strftime, '%D')
expect(page).to have_content casting_call.title
expect(page).to have_content casting_call.status
end
scenario "can create casting call requests" do
visit project_casting_calls_path(project)
expect(page).to have_content no_casting_calls_label
click_on add_new_casting_call_label
fill_in title_field, with: "Title"
fill_in description_field, with: "Description"
fill_in project_description_field, with: "Project Description"
fill_in interview_instructions_field, with: "Interview instructions"
fill_in interview_requirements_field, with: "Interview requirements"
fill_in questions_field, with: "Questions"
click_on "Create Casting call"
expect(page).to have_content("Your casting call request was successfully submitted. Thank you. A chat window will pop up on the lower right in a few seconds.")
end
scenario "can update casting call requests" do
create(:casting_call, title: "Title", project: project)
visit project_casting_calls_path(project)
click_on manage_button
click_on "Edit"
fill_in title_field, with: "New Title"
click_on "Update Casting call"
expect(page).to have_content("The casting call request has been updated")
end
scenario "can cancel a casting call request" do
create(:casting_call, title: "Title", project: project)
visit project_casting_calls_path(project)
click_on manage_button
click_on "Cancel"
expect(page).to have_content("The casting call request has been cancelled")
end
private
def no_casting_calls_label
"Casting calls will appear here"
end
def manage_button
t "casting_calls.casting_call.actions.manage"
end
def add_new_casting_call_label
t "casting_calls.index.actions.new"
end
def title_field
t "casting_calls.form.labels.title"
end
def description_field
t "casting_calls.form.labels.description"
end
def project_description_field
t "casting_calls.form.labels.project_description"
end
def interview_instructions_field
t "casting_calls.form.labels.interview_instructions"
end
def interview_requirements_field
t "casting_calls.form.labels.interview_requirements"
end
def questions_field
t "casting_calls.form.labels.questions"
end
end

View File

@@ -71,13 +71,6 @@ feature "User managing location releases" do
expect(page).to have_content("Your release was successfully submitted. Thank you.")
expect(LocationRelease.last.photos.attached?).to eq true
end
scenario "creating a release, if contract template contains signature legal language, it is shown" do
contract_template = create(:contract_template, project: project, signature_legal_text: dummy_signature_legal_text)
visit new_account_project_contract_template_location_release_path(project.account, project, contract_template)
expect(page).to have_content dummy_signature_legal_text
end
end
context "when signed in" do
@@ -382,8 +375,4 @@ feature "User managing location releases" do
select "Other", from: "Restriction"
fill_in "Describe other restrictions", with: "Test"
end
def dummy_signature_legal_text
'Some signature legal language'
end
end

View File

@@ -84,13 +84,6 @@ feature "User managing material releases" do
click_button submit_release_button
expect(page).to have_content success_submit_message
end
scenario "creating a release, if contract template contains signature legal language, it is shown" do
contract_template = create(:contract_template, project: project, signature_legal_text: dummy_signature_legal_text)
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
expect(page).to have_content dummy_signature_legal_text
end
end
context "when signed in" do
@@ -389,8 +382,4 @@ feature "User managing material releases" do
click_button submit_release_button
expect(page).not_to have_content success_submit_message
end
def dummy_signature_legal_text
'Some signature legal language'
end
end

View File

@@ -168,13 +168,6 @@ feature "User managing medical releases" do
expect(page).to have_content(successful_submission_message)
end
scenario "creating a release, if contract template contains signature legal language, it is shown" do
contract_template = create(:contract_template, project: project, signature_legal_text: dummy_signature_legal_text)
visit new_account_project_contract_template_medical_release_path(project.account, project, contract_template)
expect(page).to have_content dummy_signature_legal_text
end
end
context "when signed in as account manager" do
@@ -182,18 +175,6 @@ feature "User managing medical releases" do
sign_in current_user
end
scenario "Approved releases have checkmark and non-approved releases don't have checkmarks" do
create(:medical_release_with_contract_template, :native, project: project)
visit project_medical_releases_path(project)
expect(page).to have_css('i.fa.fa-check-circle.fa-2x', count: 0)
create(:medical_release_with_contract_template, :native, project: project, approved_by_user_email: "some@email.com", approved_at: DateTime.now)
visit project_medical_releases_path(project)
expect(page).to have_css('i.fa.fa-check-circle.fa-2x', count: 1)
end
scenario "Download All is visible" do
create(:medical_release_with_contract_template, :native, project: project)
create(:medical_release_with_contract_template, :non_native, project: project)
@@ -212,15 +193,6 @@ feature "User managing medical releases" do
expect(page).to have_link("Download", exact: true, count: 2)
end
scenario "Review action in Manage menu is visible" do
create(:medical_release_with_contract_template, :native, project: project)
create(:medical_release_with_contract_template, :non_native, project: project)
visit project_medical_releases_path(project)
expect(page).to have_link(review_action, exact: true)
end
scenario "Downloading PDF of native medical release is possible" do
native_release = create(:medical_release_with_contract_template, :native, project: project)
@@ -229,64 +201,6 @@ feature "User managing medical releases" do
click_link *view_release_pdf_link_for(native_release)
expect(content_type).to eq('application/pdf')
end
scenario "Reviewing release" do
create(:medical_release_with_contract_template, :native, project: project)
visit project_medical_releases_path(project)
click_link review_action
expect(page).to have_content review_page_heading
expect(page).to have_content approve_button
end
scenario 'When viewing the contract PDF of approved release there is page for office use only' do
medical_release = create(:medical_release_with_contract_template,
:native,
project: project,
person_first_name: 'Jane',
person_last_name: 'Doe',
approved_by_user_name: "Big Joe",
approved_by_user_email: "some@email.com",
approved_at: DateTime.now)
sign_in(current_user)
visit project_medical_releases_path(project)
click_link *view_release_pdf_link_for(medical_release)
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_body).to have_content for_office_use_only.upcase
expect(pdf_body).to have_content producer_label
expect(pdf_body).to have_content production_label
expect(pdf_body).to have_content employee_issued_to_label
expect(pdf_body).to have_content issued_by_label
expect(pdf_body).to have_content date_issued
expect(pdf_body).to have_content 'Big Joe'
end
scenario 'When viewing the contract PDF of not approved release there is no page for office use only' do
medical_release = create(:medical_release_with_contract_template,
:native,
project: project,
person_first_name: 'Jane',
person_last_name: 'Doe')
sign_in(current_user)
visit project_medical_releases_path(project)
click_link *view_release_pdf_link_for(medical_release)
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_body).not_to have_content for_office_use_only.upcase
expect(pdf_body).not_to have_content producer_label
expect(pdf_body).not_to have_content production_label
expect(pdf_body).not_to have_content employee_issued_to_label
expect(pdf_body).not_to have_content issued_by_label
expect(pdf_body).not_to have_content date_issued
expect(pdf_body).not_to have_content 'Big Joe'
end
end
context "when the user is manager(project manager)" do
@@ -314,15 +228,6 @@ feature "User managing medical releases" do
expect(page).to have_link("Download", exact: true, count: 0)
end
scenario "Review action in Manage menu is not visible" do
create(:medical_release_with_contract_template, :native, project: project)
create(:medical_release_with_contract_template, :non_native, project: project)
visit project_medical_releases_path(project)
expect(page).not_to have_link(review_action, exact: true)
end
scenario "Downloading PDF of native medical release is not possible" do
native_release = create(:medical_release_with_contract_template, :native, project: project)
@@ -367,15 +272,6 @@ feature "User managing medical releases" do
expect(page).to have_link("Download", exact: true, count: 0)
end
scenario "Review action in Manage menu is not visible" do
create(:medical_release_with_contract_template, :native, project: project)
create(:medical_release_with_contract_template, :non_native, project: project)
visit project_medical_releases_path(project)
expect(page).not_to have_link(review_action, exact: true)
end
scenario "Downloading PDF of native medical release is not possible" do
native_release = create(:medical_release_with_contract_template, :native, project: project)
@@ -551,44 +447,4 @@ feature "User managing medical releases" do
def answer_field_for_question(number)
"medical_release[question_#{number}_answer]"
end
def dummy_signature_legal_text
'Some signature legal language'
end
def review_action
t 'medical_releases.medical_release.actions.review'
end
def review_page_heading
t 'approvals.new.heading'
end
def approve_button
t 'approvals.new.actions.approve'
end
def for_office_use_only
t 'contracts.for_office_use_only.heading'
end
def producer_label
t 'contracts.for_office_use_only.description_labels.producer'
end
def production_label
t 'contracts.for_office_use_only.description_labels.production'
end
def employee_issued_to_label
t 'contracts.for_office_use_only.description_labels.employee_issued_to'
end
def issued_by_label
t 'contracts.for_office_use_only.description_labels.issued_by'
end
def date_issued
t 'contracts.for_office_use_only.description_labels.date_issued'
end
end

View File

@@ -48,13 +48,6 @@ feature "User managing misc releases" do
expect(field).to be_visible
end
end
scenario "creating a release, if contract template contains signature legal language, it is shown" do
contract_template = create(:contract_template, project: project, signature_legal_text: dummy_signature_legal_text)
visit new_account_project_contract_template_misc_release_path(project.account, project, contract_template)
expect(page).to have_content dummy_signature_legal_text
end
end
context "when signed in as account manager" do
@@ -206,8 +199,4 @@ feature "User managing misc releases" do
def person_is_minor_checkbox
'misc_release_minor'
end
def dummy_signature_legal_text
'Some signature legal language'
end
end

View File

@@ -126,13 +126,6 @@ feature "User managing talent releases" do
expect(TalentRelease.last.guardian_2_photo.attached?).to eq true
expect(TalentRelease.last.guardian_2_name).to eq "Second Guardian"
end
scenario "creating a release, if contract template contains signature legal language, it is shown" do
contract_template = create(:contract_template, project: project, signature_legal_text: dummy_signature_legal_text)
visit new_account_project_contract_template_talent_release_path(project.account, project, contract_template)
expect(page).to have_content dummy_signature_legal_text
end
end
context "when signed in" do
@@ -562,8 +555,4 @@ feature "User managing talent releases" do
fill_in guardian_address_state_field, with: "NY"
fill_in guardian_address_zip_field, with: '1000'
end
def dummy_signature_legal_text
'Some signature legal language'
end
end

View File

@@ -11,7 +11,7 @@ describe GenerateContractsZipJob do
dir = Rails.root.join("spec", "fixtures", "files")
files = ["contract.pdf", "AppearanceRelease.pdf"]
# Attachments in the test environment do not persist to cloud storage
# Therefore we want to stub calls to `open` with a cloud storage URL
# Therefore we want to stub calls to `open` with a cloud storage URL
allow_any_instance_of(ReleaseContractCollectionService).to receive(:open).and_return(StringIO.new("file data"))
allow_any_instance_of(ReleaseContractCollectionService).to receive(:build).and_yield(dir, files)
end
@@ -35,38 +35,6 @@ describe GenerateContractsZipJob do
expect(download.file).to be_attached
end
it "generates ZIP containing CSV file with all releases data for all release types" do
release_types = %w[AcquiredMediaRelease AppearanceRelease LocationRelease MaterialRelease MedicalRelease MiscRelease MusicRelease TalentRelease]
create_releases_for_all_types
release_types.each do |type|
lowercase_plural = type.constantize.model_name.plural
GenerateContractsZipJob.perform_now(project, download, type, project.public_send(lowercase_plural).ids)
generated_zip = download.file.blob.download
csv_file_name = "#{project.name.parameterize}_#{lowercase_plural.gsub('_', '-')}.csv"
Zip::InputStream.open(StringIO.new(generated_zip)) do |io|
while entry = io.get_next_entry
next unless entry.name == csv_file_name
csv_file = entry.get_input_stream.read
release_class = Object.const_get type
release_headers = release_class.csv_headers
release_headers.each do |header|
expect(csv_file).to match header
end
end
dummy_zip_file_name = "#{project.name.parameterize}_#{lowercase_plural.gsub('_', '-')}.zip"
if File.exist?(file_fixture(dummy_zip_file_name))
File.delete(file_fixture(dummy_zip_file_name))
end
end
end
end
context "When there are errors" do
let(:error) { StandardError.new("Contracts or contract templates not found.") }
@@ -74,10 +42,10 @@ describe GenerateContractsZipJob do
allow(ProjectsChannel).to receive(:broadcast_download_generation_update).with(download, I18n.t("contract_downloads.download.failure"))
allow_any_instance_of(ReleaseContractCollectionService).to receive(:build).and_raise(StandardError, "Contracts or contract templates not found")
end
it "updates status to 'failure' and sends user a notification" do
GenerateContractsZipJob.perform_now(project, download, "AppearanceRelease", project.appearance_releases.ids)
expect(download.status).to eq "failure"
expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(download, I18n.t("contract_downloads.download.failure"))
end
@@ -88,21 +56,6 @@ describe GenerateContractsZipJob do
# Delete the file created in fixture.
# Or the tests will fail on next run due to already existing files in existing zip.
path = Rails.root.join("spec", "fixtures", "files")
if File.exists? "#{path}/my-video-project_appearance-releases.zip"
File.delete("#{path}/my-video-project_appearance-releases.zip")
end
end
private
def create_releases_for_all_types
create(:acquired_media_release_with_contract_template, :native, project: project)
create(:appearance_release_with_contract_template, :native, project: project, person_name: "John Doe")
create(:location_release_with_contract_template, :native, project: project)
create(:material_release_with_contract_template, :native, project: project)
create(:medical_release_with_contract_template, :native, project: project)
create(:misc_release_with_contract_template, :native, project: project)
create(:music_release_with_contract_template, project: project)
create(:talent_release_with_contract_template, :native, project: project)
File.delete("#{path}/my-video-project_appearance-releases.zip") if File.exists? "#{path}/my-video-project_appearance-releases.zip"
end
end

View File

@@ -0,0 +1,60 @@
require "rails_helper"
describe GenerateInterviewFilesZipJob do
let(:project) { create(:project) }
let(:download) { create(:download, project: project, release_type: "CastingCallInterview", name: "my-title_john-doe") }
let(:casting_call) { create(:casting_call, project: project, title: "My Title") }
let(:casting_call_interview) { create(:casting_call_interview, casting_call: casting_call, performer_name: "John Doe") }
before do
dir = Rails.root.join("spec", "fixtures", "files")
files = ["contract.pdf", "AppearanceRelease.pdf"]
# Attachments in the test environment do not persist to cloud storage
# Therefore we want to stub calls to `open` with a cloud storage URL
allow_any_instance_of(InterviewFilesCollectionService).to receive(:open).and_return(StringIO.new("file data"))
allow_any_instance_of(InterviewFilesCollectionService).to receive(:build).and_yield(dir, files)
end
describe ".perform_later" do
it "enqueues a background job for generating zip file" do
expect {
GenerateInterviewFilesZipJob.perform_later(project, download, casting_call_interview)
}.to have_enqueued_job
end
end
describe ".perform_now" do
it "updates a download record and creates attachment for it" do
GenerateInterviewFilesZipJob.perform_now(project, download, casting_call_interview)
expect(download.project).to eq project
expect(download.release_type).to eq "CastingCallInterview"
expect(download.name).to eq "my-title_john-doe"
expect(download.status).to eq "success"
expect(download.file).to be_attached
end
context "When there are errors" do
let(:error) { StandardError.new("Casting Call Interview files not found.") }
before do
allow(ProjectsChannel).to receive(:broadcast_download_generation_update).with(download, I18n.t("interview_downloads.download.failure"))
allow_any_instance_of(InterviewFilesCollectionService).to receive(:build).and_raise(StandardError, "Casting Call Interview files not found.")
end
it "updates status to 'failure' and sends user a notification" do
GenerateInterviewFilesZipJob.perform_now(project, download, casting_call_interview)
expect(download.status).to eq "failure"
expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(download, I18n.t("interview_downloads.download.failure"))
end
end
end
after do
# Delete the file created in fixture.
# Or the tests will fail on next run due to already existing files in existing zip.
path = Rails.root.join("spec", "fixtures", "files")
File.delete("#{path}/my-title_john-doe.zip") if File.exists? "#{path}/my-title_john-doe.zip"
end
end

View File

@@ -11,7 +11,7 @@ RSpec.describe SubmitHubspotFormJob, type: :job do
allow(Hubspot::Form).to receive(:new).and_return(form)
allow(form).to receive(:submit).and_return(true)
SubmitHubspotFormJob.perform_now("John", "Doe", "email@test.com", "My Account")
SubmitHubspotFormJob.perform_now(first_name: "John", last_name: "Doe", email: "email@test.com", company: "My Account", form_guid: ENV["HUBSPOT_FORM_GUID"])
expect(Hubspot::Form).to have_received(:new).with("guid" => "hubspot_form_guid")
expect(form).to have_received(:submit).with(
@@ -27,7 +27,7 @@ RSpec.describe SubmitHubspotFormJob, type: :job do
allow(Hubspot::Form).to receive(:new).and_return(form)
allow(form).to receive(:submit).and_return(true)
SubmitHubspotFormJob.perform_now("John", "Doe", "email@test.com", "My Account", additional_param_one: "Foo", additional_param_two: "Bar")
SubmitHubspotFormJob.perform_now(first_name: "John", last_name: "Doe", email: "email@test.com", company: "My Account", form_guid: ENV["HUBSPOT_FORM_GUID"], additional_param_one: "Foo", additional_param_two: "Bar")
expect(form).to have_received(:submit).with(
first_name: "John",
@@ -35,7 +35,7 @@ RSpec.describe SubmitHubspotFormJob, type: :job do
email: "email@test.com",
company: "My Account",
additional_param_one: "Foo",
additional_param_two: "Bar",
additional_param_two: "Bar"
)
end
@@ -46,7 +46,7 @@ RSpec.describe SubmitHubspotFormJob, type: :job do
allow(Hubspot::Form).to receive(:new).and_return(form)
allow(form).to receive(:submit)
SubmitHubspotFormJob.perform_now("John", "Doe", "email@test.com", "My Account")
SubmitHubspotFormJob.perform_now(first_name: "John", last_name: "Doe", email: "email@test.com", company: "My Account", form_guid: ENV["HUBSPOT_FORM_GUID"])
expect(form).not_to have_received(:submit)
end

View File

@@ -1,36 +0,0 @@
require 'rails_helper'
RSpec.describe SubmitHubspotTaskRequestFormJob, type: :job do
describe '#perform_now' do
before do
ENV["HUBSPOT_TASK_REQUEST_FORM_GUID"] = "hubspot_task_request_form_guid"
end
it 'submits to the Hubspot API with the right params' do
form = double(:form)
allow(Hubspot::Form).to receive(:new).and_return(form)
allow(form).to receive(:submit).and_return(true)
SubmitHubspotTaskRequestFormJob.perform_now("email@test.com", "https://example.com/admin/task_requests/1")
expect(Hubspot::Form).to have_received(:new).with("guid" => "hubspot_task_request_form_guid")
expect(form).to have_received(:submit).with(
email: "email@test.com",
taskme_url: "https://example.com/admin/task_requests/1"
)
end
context 'when HUBSPOT_TASK_REQUEST_FORM_GUID is not available' do
it 'does not submit to the API' do
ENV["HUBSPOT_TASK_REQUEST_FORM_GUID"] = nil
form = double(:form)
allow(Hubspot::Form).to receive(:new).and_return(form)
allow(form).to receive(:submit)
SubmitHubspotTaskRequestFormJob.perform_now("email@test.com", "https://example.com/admin/task_requests/1")
expect(form).not_to have_received(:submit)
end
end
end
end

View File

@@ -135,7 +135,9 @@ RSpec.describe Account do
MedicalRelease,
MiscRelease,
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,
CastingCallInterview
]
Rails.application.eager_load!
ActiveRecord::Base.descendants.each do |model|

View File

@@ -0,0 +1,12 @@
require 'rails_helper'
RSpec.describe CastingCallInterview, type: :model do
describe "associations" do
it { is_expected.to belong_to(:casting_call) }
it { is_expected.to have_secure_token(:token) }
end
describe "validations" do
it { is_expected.to validate_presence_of(:performer_name) }
end
end

View File

@@ -0,0 +1,11 @@
require 'rails_helper'
RSpec.describe CastingCall, type: :model do
describe "associations" do
it { is_expected.to belong_to(:project) }
end
describe "validations" do
it { is_expected.to have_secure_token(:token) }
end
end

View File

@@ -19,6 +19,7 @@ RSpec.describe Project, type: :model do
it { is_expected.to have_many(:broadcasts).dependent(:destroy) }
it { is_expected.to have_many(:downloads).dependent(:destroy) }
it { is_expected.to have_many(:zoom_meetings).dependent(:destroy) }
it { is_expected.to have_many(:casting_calls).dependent(:destroy) }
end
describe "nested attributes" do
@@ -36,7 +37,7 @@ RSpec.describe Project, type: :model do
describe "#import_contract_templates" do
it "imports contract templates from other projects within the account" do
existing_project = create(:project_with_contract_template_public)
existing_project = create(:project_with_contract_template)
new_project = create(:project, name: "New Project", account: existing_project.account)
expect {

View File

@@ -0,0 +1,91 @@
require "rails_helper"
describe CastingCallPolicy do
subject { described_class }
let(:user_context) { build(:user_context, user: user, account: user.primary_account) }
context "for an associate" do
let(:user) { create(:user, :associate, admin: false) }
permissions :index? do
it { is_expected.to permit(user_context, subject) }
end
permissions :create? do
it { is_expected.to permit(user_context, subject) }
end
permissions :show? do
it { is_expected.to permit(user_context, subject) }
end
permissions :destroy? do
it { is_expected.to permit(user_context, subject) }
end
permissions :update? do
it { is_expected.to permit(user_context, subject) }
end
permissions :cancel? do
it { is_expected.to permit(user_context, subject) }
end
end
context "for a project manager" do
let(:user) { create(:user, :manager, admin: false) }
permissions :index? do
it { is_expected.to permit(user_context, subject) }
end
permissions :create? do
it { is_expected.to permit(user_context, subject) }
end
permissions :show? do
it { is_expected.to permit(user_context, subject) }
end
permissions :destroy? do
it { is_expected.to permit(user_context, subject) }
end
permissions :update? do
it { is_expected.to permit(user_context, subject) }
end
permissions :cancel? do
it { is_expected.to permit(user_context, subject) }
end
end
context "for account managers" do
let(:user) { create(:user, :account_manager, admin: false) }
permissions :index? do
it { is_expected.to permit(user_context, subject) }
end
permissions :create? do
it { is_expected.to permit(user_context, subject) }
end
permissions :show? do
it { is_expected.to permit(user_context, subject) }
end
permissions :destroy? do
it { is_expected.to permit(user_context, subject) }
end
permissions :update? do
it { is_expected.to permit(user_context, subject) }
end
permissions :cancel? do
it { is_expected.to permit(user_context, subject) }
end
end
end

View File

@@ -75,17 +75,14 @@ describe ContractTemplatePolicy do
end
permissions ".scope" do
let!(:member_project_public_template) do
create(:project_with_contract_template_public, name: "Member Project Public Template", members: user, account: account)
end
let!(:member_project_private_template) do
create(:project_with_contract_template_private, name: "Member Project Private Template", members: user, account: account)
let!(:member_project) do
create(:project_with_contract_template, name: "Member Project", members: user, account: account)
end
let!(:non_member_project) do
create(:project_with_contract_template_public, name: "Non-Member Project", account: account)
create(:project_with_contract_template, name: "Non-Member Project", account: account)
end
let!(:outside_project) do
create(:project_with_contract_template_public, name: "Outside Project", account: build(:account))
create(:project_with_contract_template, name: "Outside Project", account: build(:account))
end
let(:account) { build(:account) }
@@ -96,8 +93,7 @@ describe ContractTemplatePolicy do
context "for an account manager" do
let(:user) { create(:user, :account_manager, primary_account: account)}
it { is_expected.to include(member_project_public_template.contract_templates.first) }
it { is_expected.to include(member_project_private_template.contract_templates.first) }
it { is_expected.to include(member_project.contract_templates.first) }
it { is_expected.to include(non_member_project.contract_templates.first) }
it { is_expected.not_to include(outside_project.contract_templates.first) }
end
@@ -105,17 +101,15 @@ describe ContractTemplatePolicy do
context "for manager" do
let(:user) { create(:user, :manager, primary_account: account) }
it { is_expected.to include(member_project_public_template.contract_templates.first) }
it { is_expected.to include(member_project_private_template.contract_templates.first) }
it { is_expected.to include(member_project.contract_templates.first) }
it { is_expected.not_to include(non_member_project.contract_templates.first) }
it { is_expected.not_to include(outside_project.contract_templates.first) }
end
context "for associate" do
let(:user) { create(:user, :associate, primary_account: account) }
it { is_expected.to include(member_project_public_template.contract_templates.first) }
it { is_expected.not_to include(member_project_private_template.contract_templates.first) }
it { is_expected.to include(member_project.contract_templates.first) }
it { is_expected.not_to include(non_member_project.contract_templates.first) }
it { is_expected.not_to include(outside_project.contract_templates.first) }
end