617 lines
22 KiB
Ruby
617 lines
22 KiB
Ruby
require "rails_helper"
|
|
|
|
feature "User managing location releases" do
|
|
let(:current_user) { create(:user, :manager) }
|
|
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
|
|
|
|
context "when signed out" do
|
|
scenario "United States is default country" do
|
|
contract_template = create(:contract_template, project: project)
|
|
|
|
visit new_account_project_contract_template_location_release_path(project.account, project, contract_template)
|
|
expect(country_field_value).to eq "US"
|
|
end
|
|
|
|
scenario "creating a release without photos", js: true do
|
|
contract_template = create(:contract_template, project: project)
|
|
|
|
visit new_account_project_contract_template_location_release_path(project.account, project, contract_template)
|
|
|
|
by "filling out the form" do
|
|
fill_in location_name_field, with: "Benny's Burritos"
|
|
fill_in location_address_street_1, with: "Location's street address"
|
|
fill_in location_address_city, with: "Location's city"
|
|
fill_in location_address_state, with: "Location's state"
|
|
fill_in location_address_zip, with: "Location's zip"
|
|
fill_in person_first_name_field, with: "Jane"
|
|
fill_in person_last_name_field, with: "Doe"
|
|
fill_in person_phone_field, with: "555-555-5555"
|
|
fill_in person_email_field, with: "jane.doe@test.com"
|
|
fill_in person_company_field, with: "BIG"
|
|
fill_in person_title_field, with: "Ms."
|
|
fill_in person_address_street1_field, with: "100 Broadway"
|
|
fill_in person_address_city, with: "Person's City"
|
|
fill_in person_address_state, with: "Person's State"
|
|
fill_in person_address_zip, with: "Person's Zip"
|
|
fill_in filming_hours_field, with: "04:00 - 22:00"
|
|
draw_signature file_fixture("signature.png"), "location_release_signature_base64"
|
|
end
|
|
|
|
click_button submit_release_button
|
|
|
|
expect(page).to have_content("Your release was successfully submitted. Thank you.")
|
|
end
|
|
|
|
scenario "creating a release with photos", js: true do
|
|
contract_template = create(:contract_template, project: project)
|
|
|
|
visit new_account_project_contract_template_location_release_path(project.account, project, contract_template)
|
|
|
|
fill_in location_name_field, with: "Benny's Burritos"
|
|
fill_in location_address_street_1, with: "Location's street address"
|
|
fill_in location_address_city, with: "Location's city"
|
|
fill_in location_address_state, with: "Location's state"
|
|
fill_in location_address_zip, with: "Location's zip"
|
|
fill_in person_first_name_field, with: "Jane"
|
|
fill_in person_last_name_field, with: "Doe"
|
|
fill_in person_phone_field, with: "555-555-5555"
|
|
fill_in person_email_field, with: "jane.doe@test.com"
|
|
fill_in person_company_field, with: "BIG"
|
|
fill_in person_title_field, with: "Ms."
|
|
fill_in person_address_street1_field, with: "100 Broadway"
|
|
fill_in person_address_city, with: "Person's City"
|
|
fill_in person_address_state, with: "Person's State"
|
|
fill_in person_address_zip, with: "Person's Zip"
|
|
fill_in filming_hours_field, with: "04:00 - 22:00"
|
|
draw_signature file_fixture("signature.png"), "location_release_signature_base64"
|
|
|
|
drop_file Rails.root.join(file_fixture("location_photo.png")), type: :dropzone
|
|
click_button submit_release_button
|
|
|
|
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
|
|
|
|
scenario "signing amendment for a not-signed amendment release", js: true do
|
|
contract_template = create(:location_release_contract_template, :with_amendment_clause, project: project)
|
|
release = create(:location_release, contract_template: contract_template, project: project)
|
|
|
|
expect(release.amendment_signed?).to be_falsey
|
|
|
|
visit new_account_project_contract_template_location_release_amendment_path(project.account, project, contract_template, release)
|
|
|
|
expect(page).to have_content amendments_heading.upcase
|
|
|
|
fill_in amendment_signer_name_field, with: 'Big Signer'
|
|
draw_signature file_fixture("signature.png"), amendment_signature_field
|
|
|
|
click_button sign_amendment_button
|
|
|
|
expect(page).to have_content signed_successfully_message
|
|
expect(LocationRelease.find(release.id).amendment_signed?).to be_truthy
|
|
end
|
|
|
|
scenario "opening signing amendment page for a signed amendment release shows already signed message", js: true do
|
|
contract_template = create(:location_release_contract_template, :with_amendment_clause, project: project)
|
|
release = create(:location_release, :amendment_signed, contract_template: contract_template, project: project)
|
|
|
|
expect(release.amendment_signed?).to be_truthy
|
|
|
|
visit new_account_project_contract_template_location_release_amendment_path(project.account, project, contract_template, release)
|
|
|
|
expect(page).not_to have_content amendments_heading
|
|
expect(page).not_to have_content signed_successfully_message
|
|
expect(page).to have_content already_signed_message
|
|
end
|
|
|
|
scenario "amendment signing form has copy URL button" do
|
|
contract_template = create(:location_release_contract_template, :with_amendment_clause, project: project)
|
|
release = create(:location_release, contract_template: contract_template, project: project)
|
|
|
|
visit new_account_project_contract_template_location_release_amendment_path(project.account, project, contract_template, release)
|
|
|
|
expect(page).to have_content copy_url_button
|
|
end
|
|
end
|
|
|
|
context "when signed in" do
|
|
before do
|
|
set_window_size_permanently_to(1000, 1000)
|
|
sign_in current_user
|
|
end
|
|
|
|
scenario "listing all releases, table have correct headers", js:true do
|
|
ct = create(:contract_template, :with_amendment_clause, project: project)
|
|
create(:location_release, :native, project: project, contract_template: ct)
|
|
visit project_location_releases_path(project)
|
|
|
|
table_headers.each { |s| expect(page).to have_content s }
|
|
end
|
|
|
|
scenario "creating a release", js: true do
|
|
visit new_project_location_release_path(project)
|
|
|
|
by "attaching only a contract" do
|
|
attach_file contract_field, Rails.root.join(file_fixture("contract.pdf")), visible: false
|
|
click_button create_release_button
|
|
|
|
expect(page).to have_invalid_field(location_name_field)
|
|
end
|
|
|
|
by "attaching photos" do
|
|
drop_file Rails.root.join(file_fixture("location_photo.png")), type: :dropzone
|
|
click_button create_release_button
|
|
|
|
expect(page).to have_invalid_field(location_name_field)
|
|
end
|
|
|
|
by "filling out the remaining information" do
|
|
fill_in_release_fields name: "Test Location Release"
|
|
fill_in filming_hours_field, with: "04:00 - 22:00"
|
|
click_button create_release_button
|
|
expect(page).to have_content(create_release_notice)
|
|
expect(page).to have_photo("location_photo.png", visible: :all)
|
|
|
|
click_on manage_button
|
|
expect(page).to have_link("Download")
|
|
end
|
|
end
|
|
|
|
scenario "updating an existing release", js: true do
|
|
location_release = create(:location_release_with_photo, :non_native, project: project)
|
|
|
|
visit project_location_releases_path(project)
|
|
click_on manage_button
|
|
click_link *update_location_release_link(location_release)
|
|
|
|
within ".dropzone" do
|
|
expect(page).to have_photo("location_photo.png", attr: "alt")
|
|
end
|
|
|
|
fill_in_release_fields name: "New release name"
|
|
select "Other", from: "Applicable Media"
|
|
fill_in "Describe other applicable media", with: "New Test"
|
|
click_on update_release_button
|
|
|
|
expect(page).to have_content(update_release_notice)
|
|
expect(page).to have_content("New release name")
|
|
end
|
|
|
|
scenario "deleting an existing release", js: true do
|
|
location_release = create(:location_release, project: project)
|
|
|
|
visit project_location_releases_path(project)
|
|
click_on manage_button
|
|
|
|
accept_alert do
|
|
click_link *destroy_location_release_link(location_release)
|
|
end
|
|
|
|
expect(page).to have_content(destroy_release_alert)
|
|
expect(page).not_to have_content(location_release.name)
|
|
end
|
|
|
|
scenario "searching for a release", js: true do
|
|
create(:location_release, name: "Cheers", project: project)
|
|
create(:location_release, name: "Cipriani", project: project)
|
|
|
|
visit project_location_releases_path(project)
|
|
|
|
within "form#search" do
|
|
fill_in "Search", with: "Cheers"
|
|
click_on "button"
|
|
end
|
|
|
|
expect(page).to have_content("Cheers")
|
|
expect(page).not_to have_content("Cipriani")
|
|
expect(page).to have_field("Search", with: "Cheers")
|
|
end
|
|
|
|
scenario "adding photos to an existing release", js: true do
|
|
create(:location_release, name: "Apple MacBook Air", project: project)
|
|
|
|
visit project_location_releases_path(project)
|
|
|
|
expect(page).to have_content("Needs Photo")
|
|
|
|
click_on manage_button
|
|
click_on "Photos"
|
|
|
|
expect(page).to have_content("Add Photos")
|
|
expect(page).to have_content("Apple MacBook Air")
|
|
|
|
drop_file Rails.root.join(file_fixture("location_photo.png")), type: :dropzone
|
|
click_on "Save Changes"
|
|
|
|
expect(page).to have_content("The release has been updated")
|
|
expect(page).to have_photo("location_photo.png", visible: :all)
|
|
end
|
|
|
|
scenario "signing amendment for a not-signed amendment release", js: true do
|
|
contract_template = create(:location_release_contract_template, :with_amendment_clause, project: project)
|
|
release = create(:location_release, name: "Test Loc", contract_template: contract_template, project: project)
|
|
|
|
expect(release.amendment_signed?).to be_falsey
|
|
|
|
visit project_location_releases_path(project)
|
|
|
|
expect(page).to have_content "Test Loc"
|
|
|
|
click_on manage_button
|
|
|
|
expect(page).to have_link sign_amendment_link
|
|
|
|
new_window = window_opened_by { click_link sign_amendment_link }
|
|
within_window new_window do
|
|
expect(page).to have_content amendments_heading.upcase
|
|
|
|
fill_in amendment_signer_name_field, with: 'Big Signer'
|
|
draw_signature file_fixture("signature.png"), amendment_signature_field
|
|
|
|
click_button sign_amendment_button
|
|
|
|
expect(page).to have_content signed_successfully_message
|
|
expect(LocationRelease.find(release.id).amendment_signed?).to be_truthy
|
|
end
|
|
end
|
|
|
|
scenario "signed amendment release does not have sign amendment option in manage dropdown", js: true do
|
|
contract_template = create(:location_release_contract_template, :with_amendment_clause, project: project)
|
|
release = create(:location_release, :amendment_signed, name: "Test Loc", contract_template: contract_template, project: project)
|
|
|
|
expect(release.amendment_signed?).to be_truthy
|
|
|
|
visit project_location_releases_path(project)
|
|
|
|
expect(page).to have_content "Test Loc"
|
|
|
|
click_on manage_button
|
|
|
|
expect(page).not_to have_link sign_amendment_link
|
|
end
|
|
|
|
scenario "signed amendment release have checked box in location releases index table", js: true do
|
|
contract_template = create(:location_release_contract_template, :with_amendment_clause, project: project)
|
|
not_signed_release = create(:location_release, name: "Not Yet Loc", contract_template: contract_template, project: project)
|
|
expect(not_signed_release.amendment_signed?).to be_falsey
|
|
|
|
visit project_location_releases_path(project)
|
|
|
|
expect(page).to have_content "Not Yet Loc"
|
|
expect(page).to have_css('i.fa.fa-square-o', count: 1)
|
|
expect(page).to have_css('i.fa.fa-check-square', count: 0)
|
|
|
|
signed_release = create(:location_release, :amendment_signed, name: "Signed A Loc", contract_template: contract_template, project: project)
|
|
expect(signed_release.amendment_signed?).to be_truthy
|
|
|
|
visit project_location_releases_path(project)
|
|
|
|
expect(page).to have_content "Signed A Loc"
|
|
|
|
expect(page).to have_css('i.fa.fa-square-o', count: 1)
|
|
expect(page).to have_css('i.fa.fa-check-square-o', count: 1)
|
|
end
|
|
|
|
scenario "amendment signing form has copy URL button when user is signed in", js: true do
|
|
contract_template = create(:location_release_contract_template, :with_amendment_clause, project: project)
|
|
release = create(:location_release, contract_template: contract_template, project: project)
|
|
|
|
visit new_account_project_contract_template_location_release_amendment_path(project.account, project, contract_template, release)
|
|
|
|
expect(page).to have_content copy_url_button
|
|
end
|
|
end
|
|
|
|
scenario "viewing the contract PDF when amendment is not yet signed" do
|
|
location_release = create(:location_release_with_contract_template_and_photo,
|
|
:native,
|
|
project: project,
|
|
name: "Benny's Burritos",
|
|
filming_hours: "06:00 - 20:00",
|
|
tag_list: "Restaurant",
|
|
notes: [
|
|
build(:note,
|
|
content: "Note 1",
|
|
user: build(:user, email: "jane.doe@test.com"),
|
|
email: "jane.doe@test.com",
|
|
created_at: DateTime.new(2020, 2, 21, 12, 0, 0),),
|
|
build(:note,
|
|
content: "Note 2",
|
|
user: build(:user, email: "john.doe@test.com"),
|
|
email: "john.doe@test.com",
|
|
created_at: DateTime.new(2020, 2, 20, 11, 0, 0),),
|
|
])
|
|
|
|
sign_in(current_user)
|
|
visit project_location_releases_path(project)
|
|
click_link *view_release_pdf_link_for(location_release)
|
|
|
|
expect(content_type).to eq("application/pdf")
|
|
expect(content_disposition).to include("inline")
|
|
expect(pdf_filename).to include("benny-s-burritos")
|
|
|
|
expect(pdf_body).not_to have_content amendment_page_heading
|
|
expect(pdf_body).to have_content("Benny's Burritos")
|
|
expect(pdf_body).to have_content("NOTES")
|
|
expect(pdf_body).to have_content("Note 1")
|
|
expect(pdf_body).to have_content("jane.doe@test.com")
|
|
expect(pdf_body).to have_content("2/21/20 12:00 PM")
|
|
expect(pdf_body).to have_content("Note 2")
|
|
expect(pdf_body).to have_content("john.doe@test.com")
|
|
expect(pdf_body).to have_content("2/20/20 11:00 AM")
|
|
expect(pdf_body).to have_content("TAGS")
|
|
expect(pdf_body).to have_content("Restaurant")
|
|
expect(pdf_body).to have_content photos_heading.upcase
|
|
expect(pdf_body).to have_content("location_photo.png")
|
|
expect(pdf_body).to have_content("Filming Hours")
|
|
expect(pdf_body).to have_content("06:00 - 20:00")
|
|
end
|
|
|
|
scenario "viewing the contract PDF when amendment is signed" do
|
|
contract_template = create(:location_release_contract_template, :with_amendment_clause, project: project)
|
|
location_release = create(:location_release,
|
|
:amendment_signed,
|
|
:native,
|
|
contract_template: contract_template,
|
|
project: project,
|
|
name: "Test Loc")
|
|
|
|
sign_in(current_user)
|
|
visit project_location_releases_path(project)
|
|
click_link *view_release_pdf_link_for(location_release)
|
|
|
|
expect(content_type).to eq("application/pdf")
|
|
expect(content_disposition).to include("inline")
|
|
expect(pdf_filename).to include("test-loc")
|
|
|
|
expect(pdf_body).to have_content("Test Loc")
|
|
|
|
expect(pdf_body).to have_content amendment_page_heading.upcase
|
|
expect(pdf_body).to have_content amendment_clause_label
|
|
expect(pdf_body).to have_content amendment_signer_name_label
|
|
expect(pdf_body).to have_content amendment_signature_label
|
|
|
|
expect(pdf_body).to have_content contract_template.amendment_clause.to_plain_text
|
|
expect(pdf_body).to have_content location_release.amendment_signer_name
|
|
end
|
|
|
|
context "when the user is account manager" do
|
|
end
|
|
|
|
context "when the user is project manager" do
|
|
end
|
|
|
|
context "when the user is associate" do
|
|
let(:current_user) { create(:user, :associate) }
|
|
|
|
before do
|
|
sign_in current_user
|
|
end
|
|
|
|
scenario "should not show download" do
|
|
create(:location_release_with_contract_template, name: "Cheers", project: project)
|
|
|
|
visit project_location_releases_path(project)
|
|
|
|
click_on manage_button
|
|
expect(page).not_to have_link("Download", exact: true)
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def country_field_value
|
|
find_field("location_release[person_address_country]").value
|
|
end
|
|
|
|
def photos_heading(photos_count = 1)
|
|
t 'contracts.photos.heading', count: photos_count
|
|
end
|
|
|
|
def location_name_field
|
|
"location_release[name]"
|
|
end
|
|
|
|
def location_address_street_1
|
|
"location_release[address_street1]"
|
|
end
|
|
|
|
def location_address_city
|
|
"location_release[address_city]"
|
|
end
|
|
|
|
def location_address_state
|
|
"location_release[address_state]"
|
|
end
|
|
|
|
def location_address_zip
|
|
"location_release[address_zip]"
|
|
end
|
|
|
|
def contract_field
|
|
"location_release[contract]"
|
|
end
|
|
|
|
def person_first_name_field
|
|
"location_release[person_first_name]"
|
|
end
|
|
|
|
def person_last_name_field
|
|
"location_release[person_last_name]"
|
|
end
|
|
|
|
def person_address_street1_field
|
|
"location_release[person_address_street1]"
|
|
end
|
|
|
|
def person_address_city
|
|
"location_release[person_address_city]"
|
|
end
|
|
|
|
def person_address_state
|
|
"location_release[person_address_state]"
|
|
end
|
|
|
|
def person_address_zip
|
|
"location_release[person_address_zip]"
|
|
end
|
|
|
|
def person_phone_field
|
|
"location_release[person_phone]"
|
|
end
|
|
|
|
def person_email_field
|
|
"location_release[person_email]"
|
|
end
|
|
|
|
def person_company_field
|
|
"location_release[person_company]"
|
|
end
|
|
|
|
def person_title_field
|
|
"location_release[person_title]"
|
|
end
|
|
|
|
def filming_hours_field
|
|
"location_release[filming_hours]"
|
|
end
|
|
|
|
def have_photo(filename, attr: "src", visible: true)
|
|
have_selector("img[#{attr}*='#{filename}']", visible: visible)
|
|
end
|
|
|
|
def import_location_release_link(project)
|
|
["Import Release", href: new_project_location_release_path(project)]
|
|
end
|
|
|
|
def update_location_release_link(location_release)
|
|
["Edit", href: edit_location_release_path(location_release)]
|
|
end
|
|
|
|
def destroy_location_release_link(location_release)
|
|
["Delete", href: location_release_path(location_release)]
|
|
end
|
|
|
|
def fill_in_release_fields(data)
|
|
fill_in "location_release[name]", with: data[:name]
|
|
end
|
|
|
|
def create_release_button
|
|
t "helpers.submit.location_release.create"
|
|
end
|
|
|
|
def submit_release_button
|
|
t("shared.submit_release_long")
|
|
end
|
|
|
|
def create_release_notice
|
|
t "location_releases.create.notice"
|
|
end
|
|
|
|
def update_release_button
|
|
t "helpers.submit.location_release.update"
|
|
end
|
|
|
|
def update_release_notice
|
|
t "location_releases.update.notice"
|
|
end
|
|
|
|
def destroy_release_alert
|
|
t "location_releases.destroy.alert"
|
|
end
|
|
|
|
def view_release_pdf_link_for(location_release)
|
|
["Download", href: location_release_contracts_path(location_release, format: "pdf")]
|
|
end
|
|
|
|
def fill_in_exploitable_rights
|
|
select "Other", from: "Applicable Media"
|
|
fill_in "Describe other applicable media", with: "Test"
|
|
select "Other", from: "Territory"
|
|
fill_in "Describe other territory", with: "Test"
|
|
select "Other", from: "Term"
|
|
fill_in "Describe other term", with: "Test"
|
|
select "Other", from: "Restriction"
|
|
fill_in "Describe other restrictions", with: "Test"
|
|
end
|
|
|
|
def dummy_signature_legal_text
|
|
'Some signature legal language'
|
|
end
|
|
|
|
def amendments_heading
|
|
t 'public.amendments.new.amendment.heading'
|
|
end
|
|
|
|
def signed_contract_preview
|
|
t 'public.amendments.new.signed_contract_preview'
|
|
end
|
|
|
|
def amendment_signer_name_field
|
|
'location_release[amendment_signer_name]'
|
|
end
|
|
|
|
def amendment_signature_field
|
|
'location_release_amendment_signature_base64'
|
|
end
|
|
|
|
def sign_amendment_button
|
|
t 'shared.submit_release_long'
|
|
end
|
|
|
|
def already_signed_message
|
|
t 'public.amendments.create.amendment_already_signed_message'
|
|
end
|
|
|
|
def signed_successfully_message
|
|
t 'public.amendments.create.amendment_signed_message'
|
|
end
|
|
|
|
def manage_button
|
|
t 'location_releases.location_release.actions.manage'
|
|
end
|
|
|
|
def sign_amendment_link
|
|
t 'location_releases.location_release.actions.sign_amendment'
|
|
end
|
|
|
|
def copy_url_button
|
|
t 'public.amendments.new.copy_url'
|
|
end
|
|
|
|
def amendment_page_heading
|
|
t 'contracts.amendment_page.heading'
|
|
end
|
|
|
|
def amendment_signer_name_label
|
|
t 'contracts.amendment_page.description_labels.amendment_signer_name'
|
|
end
|
|
|
|
def amendment_clause_label
|
|
t 'contracts.amendment_page.description_labels.amendment_clause'
|
|
end
|
|
|
|
def amendment_signature_label
|
|
t 'contracts.amendment_page.description_labels.amendment_signature'
|
|
end
|
|
|
|
def table_headers
|
|
[
|
|
t('location_releases.index.table_headers.approved'),
|
|
t('location_releases.index.table_headers.location_info'),
|
|
t('location_releases.index.table_headers.owner_info'),
|
|
t('location_releases.index.table_headers.notes'),
|
|
t('location_releases.index.table_headers.tags'),
|
|
t('location_releases.index.table_headers.signed_at'),
|
|
t('location_releases.index.table_headers.amendment_signed')
|
|
]
|
|
end
|
|
end
|