Compare commits
15 Commits
add-amendm
...
show-owner
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d83cff8d2 | ||
|
|
a8944c6c4a | ||
|
|
7e571845d8 | ||
|
|
d1aa103d9c | ||
|
|
3242bebd6a | ||
|
|
6267f12cc4 | ||
|
|
78d182624d | ||
|
|
088994b90c | ||
|
|
fd7357045c | ||
|
|
6378d45274 | ||
|
|
708cc5e0a8 | ||
|
|
56d73d9844 | ||
|
|
580312bc52 | ||
|
|
0294a480ee | ||
|
|
a7b7e1ecf9 |
@@ -18,7 +18,7 @@ class AcquiredMediaRelease < ApplicationRecord
|
||||
|
||||
class << self
|
||||
def custom_csv_exportable_headers
|
||||
%i[name file_infos_count]
|
||||
%i[name file_infos_count owner_info]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ class AppearanceRelease < ApplicationRecord
|
||||
include SecondGuardianName
|
||||
include CsvExportable
|
||||
include Approvable
|
||||
include Amendmenable
|
||||
|
||||
class << self
|
||||
def custom_csv_exportable_headers
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
module CsvExportable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
COMMON_HEADERS = %i[approved? notes tags signed_at].freeze
|
||||
COMMON_VALUES = %w[clean_notes clean_tags signed_on].freeze
|
||||
COMMON_HEADERS = %i[approved notes tags signed_at].freeze
|
||||
COMMON_VALUES = %w[approved? clean_notes clean_tags signed_on].freeze
|
||||
|
||||
included do
|
||||
class << self
|
||||
@@ -29,11 +29,20 @@ module CsvExportable
|
||||
|
||||
private
|
||||
|
||||
def owner_info
|
||||
compact_contact_info(name: person_name, address: person_address, phone: person_phone, email: person_email)
|
||||
end
|
||||
|
||||
def contact_info
|
||||
owner_info
|
||||
end
|
||||
|
||||
def compact_contact_info(name: nil, address: nil, phone: nil, email: nil)
|
||||
contact_info = ''
|
||||
contact_info += "#{person_address}; " if person_address.present?
|
||||
contact_info += "P: #{person_phone}; " if person_phone.present?
|
||||
contact_info += "E: #{person_email}" if person_email.present?
|
||||
contact_info += "#{name}; " if name.present?
|
||||
contact_info += "#{address}; " if address.present?
|
||||
contact_info += "P: #{phone}; " if phone.present?
|
||||
contact_info += "E: #{email}" if email.present?
|
||||
contact_info.delete_suffix '; '
|
||||
end
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class LocationRelease < ApplicationRecord
|
||||
|
||||
class << self
|
||||
def custom_csv_exportable_headers
|
||||
%i[name address]
|
||||
%i[location_info owner_info amendment_signed_column]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -67,6 +67,18 @@ class LocationRelease < ApplicationRecord
|
||||
true
|
||||
end
|
||||
|
||||
def location_info
|
||||
compact_contact_info(name: name, address: address)
|
||||
end
|
||||
|
||||
def amendment_signed_column
|
||||
if amendment_signable?
|
||||
amendment_signed?
|
||||
else
|
||||
I18n.t('location_releases.csv.no_amendment_clause')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def end_date_after_start_date
|
||||
|
||||
@@ -20,7 +20,7 @@ class MaterialRelease < ApplicationRecord
|
||||
|
||||
class << self
|
||||
def custom_csv_exportable_headers
|
||||
%i[name]
|
||||
%i[name owner_info]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -34,8 +34,4 @@ class AppearanceReleasePolicy < ReleasePolicy
|
||||
def approve?
|
||||
review?
|
||||
end
|
||||
|
||||
def sign_amendment?
|
||||
user.manager? || user.account_manager?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
<%= fa_icon("warning", text: t(".no_media"), class: "text-danger") %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<%= contact_info_for(acquired_media_release.contact_person) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= notes_preview acquired_media_release.notes.order_by_recent %>
|
||||
</td>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<th><%= t '.table_headers.approved'%></th>
|
||||
<th><%= AcquiredMediaRelease.human_attribute_name(:name) %></th>
|
||||
<th><%= t(".table_headers.file_infos_count") %></th>
|
||||
<th><%= t(".table_headers.owner_info") %></th>
|
||||
<th><%= t(".table_headers.notes") %></th>
|
||||
<th><%= t(".table_headers.tags") %></th>
|
||||
<th><%= t(".table_headers.signed_at") %></th>
|
||||
|
||||
@@ -34,17 +34,6 @@
|
||||
<td>
|
||||
<%= appearance_release.signed_on %>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<% if appearance_release.amendment_signed? %>
|
||||
<i class="fa fa-check-square-o text-dark"
|
||||
data-toggle="tooltip"
|
||||
title="<%= t '.messages.amendment_signed_tooltip' %>"></i>
|
||||
<% elsif appearance_release.amendment_signable? %>
|
||||
<i class="fa fa-square-o"
|
||||
data-toggle="tooltip"
|
||||
title="<%= t '.messages.amendment_not_signed_tooltip' %>"></i>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="btn-group">
|
||||
<%= button_tag t(".actions.manage"), class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %>
|
||||
@@ -55,9 +44,6 @@
|
||||
<% if policy(appearance_release.tags).new? %>
|
||||
<%= link_to fa_icon("tags fw", text: "Tags"), [:new, appearance_release, :acts_as_taggable_on_tag], class: "dropdown-item", remote: true %>
|
||||
<% end %>
|
||||
<% if policy(appearance_release).sign_amendment? && appearance_release.amendment_signable? && !appearance_release.amendment_signed? %>
|
||||
<%= link_to fa_icon("file-text fw", text: t('.actions.sign_amendment')), [:new, appearance_release.project.account, appearance_release.project, appearance_release.contract_template, appearance_release, :amendment], class: "dropdown-item", target: "_blank" %>
|
||||
<% end %>
|
||||
<% if policy(Contract).show? && (appearance_release.contract.attached? || appearance_release.contract_template.present?) %>
|
||||
<%= link_to fa_icon("download fw", text: "Download"), [appearance_release, :contracts, format: "pdf"], class: "dropdown-item", target: "_blank" %>
|
||||
<% end %>
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
<th><%= t(".table_headers.notes") %></th>
|
||||
<th><%= t(".table_headers.tags") %></th>
|
||||
<th><%= t(".table_headers.signed_at") %></th>
|
||||
<th><%= t '.table_headers.amendment_signed' %></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<%= field_set_tag content_tag(:span, t(".release_info.heading"), class: "h6 text-muted text-uppercase") do %>
|
||||
<div class="form-row">
|
||||
<%= form.text_field :name, wrapper_class: "col-sm-6" %>
|
||||
<%= form.select :release_type, options_for_release_type_select(project, @release_type), { wrapper_class: "col-sm-6" }, data: { toggle: "collapse-select", target_show_values_mapping: { "#guardian_clause": %w(acquired_media appearance talent material misc medical), "#fee_field": %w(appearance talent location material acquired_media), "#exploitable_rights_fields": %w(appearance talent location material acquired_media), "#custom_fields": %w(medical misc), "#amendment_clause": %w(appearance location) } }, class: "form-control custom-select" %>
|
||||
<%= form.select :release_type, options_for_release_type_select(project, @release_type), { wrapper_class: "col-sm-6" }, data: { toggle: "collapse-select", target_show_values_mapping: { "#guardian_clause": %w(acquired_media appearance talent material misc medical), "#fee_field": %w(appearance talent location material acquired_media), "#exploitable_rights_fields": %w(appearance talent location material acquired_media), "#custom_fields": %w(medical misc), "#amendment_clause": %w(location) } }, class: "form-control custom-select" %>
|
||||
</div>
|
||||
<div class="form-row mb-3">
|
||||
<%= form.radio_button :accessibility, :public_template, label: "Public", wrapper_class: "mr-3" %>
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
<td>
|
||||
<%= material_release.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= contact_info_for(material_release.contact_person) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= notes_preview material_release.notes.order_by_recent %>
|
||||
</td>
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
<th><%= t '.table_headers.approved'%></th>
|
||||
<th></th>
|
||||
<th><%= MaterialRelease.human_attribute_name(:name) %></th>
|
||||
<th><%= t(".table_headers.owner_info") %>
|
||||
<th><%= t(".table_headers.notes") %></th>
|
||||
<th><%= t(".table_headers.tags") %></th>
|
||||
<th><%= t(".table_headers.signed_at") %></th>
|
||||
|
||||
<th><%= t(".table_headers.signed_at") %></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -65,6 +65,7 @@ en:
|
||||
file_infos_count: No. Files
|
||||
name: Name
|
||||
notes: Notes
|
||||
owner_info: Owner Info
|
||||
signed_at: Date Signed
|
||||
tags: Tags
|
||||
new:
|
||||
@@ -140,10 +141,7 @@ en:
|
||||
actions:
|
||||
manage: Manage
|
||||
review: Review
|
||||
sign_amendment: Sign Additional Clause
|
||||
messages:
|
||||
amendment_not_signed_tooltip: Secondary Clause Not Yet Signed
|
||||
amendment_signed_tooltip: Secondary Clause Signed
|
||||
approved_tooltip: Approved by %{user} on %{timestamp}
|
||||
no_photos: Needs Photo
|
||||
create:
|
||||
@@ -176,7 +174,6 @@ en:
|
||||
empty: Appearance Releases will appear here
|
||||
imported_appearance_release_missing_attachment: Person photo or contract missing for imported appearance release
|
||||
table_headers:
|
||||
amendment_signed: Additional Clause
|
||||
approved: Approved
|
||||
contact_info: Contact info
|
||||
name: Name
|
||||
@@ -353,7 +350,7 @@ en:
|
||||
amendment_clause: Amendment Clause
|
||||
amendment_signature: Amendment Signature
|
||||
amendment_signer_name: Amendment Signer Name
|
||||
heading: Secondary Clause
|
||||
heading: Amendment
|
||||
for_office_use_only:
|
||||
description_labels:
|
||||
date_issued: Date Issued
|
||||
@@ -522,8 +519,6 @@ en:
|
||||
person_last_name: Last name
|
||||
person_name: Name
|
||||
person_phone: Phone number
|
||||
contract_template:
|
||||
amendment_clause: Secondary Clause
|
||||
location_release:
|
||||
address_city: City
|
||||
address_country: Country
|
||||
@@ -832,6 +827,8 @@ en:
|
||||
location_releases:
|
||||
create:
|
||||
notice: The location release has been created
|
||||
csv:
|
||||
no_amendment_clause: No amendment clause
|
||||
destroy:
|
||||
alert: The location release has been deleted
|
||||
edit:
|
||||
@@ -855,6 +852,7 @@ en:
|
||||
empty: Location Releases will appear here
|
||||
table_headers:
|
||||
amendment_signed: Amendment
|
||||
amendment_signed_column: Amendment
|
||||
approved: Approved
|
||||
location_info: Location Info
|
||||
notes: Notes
|
||||
@@ -909,6 +907,7 @@ en:
|
||||
approved: Approved
|
||||
name: Name
|
||||
notes: Notes
|
||||
owner_info: Owner Info
|
||||
signed_at: Date Signed
|
||||
tags: Tags
|
||||
material_release:
|
||||
@@ -933,7 +932,6 @@ en:
|
||||
empty: Medical releases will appear here
|
||||
table_headers:
|
||||
approved: Approved
|
||||
approved?: Approved
|
||||
contact_info: Contact info
|
||||
name: Person name
|
||||
notes: Notes
|
||||
|
||||
@@ -16,9 +16,11 @@ es:
|
||||
heading: Guardian Photo
|
||||
index:
|
||||
table_headers:
|
||||
approved: Appproved (ES)
|
||||
file_infos_count: No. Files (ES)
|
||||
name: Name (ES)
|
||||
notes: Notes (ES)
|
||||
owner_info: Owner Info (ES)
|
||||
signed_at: Date Signed (ES)
|
||||
tags: Tags (ES)
|
||||
activerecord:
|
||||
@@ -45,13 +47,6 @@ es:
|
||||
models:
|
||||
appearance_release: Autorización de Aparacimiento
|
||||
appearance_releases:
|
||||
appearance_release:
|
||||
actions:
|
||||
sign_amendment: Sign Additional Clause (ES)
|
||||
manage: Manage (ES)
|
||||
messages:
|
||||
amendment_not_signed_tooltip: Amendment not yet signed (ES)
|
||||
amendment_signed_tooltip: Amendment signed (ES)
|
||||
create:
|
||||
failed_import: Failed to create appearance release for files listed below (ES)
|
||||
matching_started: Matching started (ES)
|
||||
@@ -71,7 +66,7 @@ es:
|
||||
index:
|
||||
imported_appearance_release_missing_attachment: Person photo or contract missing for imported appearance release (ES)
|
||||
table_headers:
|
||||
amendment_signed: Additional Clause (ES)
|
||||
approved: Approved (ES)
|
||||
contact_info: ""
|
||||
name: ""
|
||||
notes: ""
|
||||
@@ -177,7 +172,7 @@ es:
|
||||
amendment_clause: Amendment Clause (ES)
|
||||
amendment_signature: Amendment Signature (ES)
|
||||
amendment_signer_name: Amendment Signer Name (ES)
|
||||
heading: Secondary Clause (ES)
|
||||
heading: Amendment (ES)
|
||||
for_office_use_only:
|
||||
description_labels:
|
||||
date_issued: Date Issued (ES)
|
||||
@@ -410,6 +405,8 @@ es:
|
||||
update: Approve (ES)
|
||||
update: 'Actualizar %{model}'
|
||||
location_releases:
|
||||
csv:
|
||||
no_amendment_clause: No amendment clause (ES)
|
||||
form:
|
||||
photos:
|
||||
dropzone_label: Tap to take a photo of the Property (optional) (ES)
|
||||
@@ -417,6 +414,8 @@ es:
|
||||
table_headers:
|
||||
address: Address (ES)
|
||||
amendment_signed: Amendment (ES)
|
||||
amendment_signed_column: Amendment signed (ES)
|
||||
approved: Approved (ES)
|
||||
notes: Notes (ES)
|
||||
signed_at: Date Signed (ES)
|
||||
tags: Tags (ES)
|
||||
@@ -442,8 +441,10 @@ es:
|
||||
heading: Guardian Photo
|
||||
index:
|
||||
table_headers:
|
||||
approved: Approved (ES)
|
||||
name: Name (ES)
|
||||
notes: Notes (ES)
|
||||
owner_info: Owner Info
|
||||
signed_at: Date Signed (ES)
|
||||
tags: Tags (ES)
|
||||
medical_releases:
|
||||
@@ -452,7 +453,6 @@ es:
|
||||
index:
|
||||
table_headers:
|
||||
approved: Approved (ES)
|
||||
approved?: Approved (ES)
|
||||
contact_info: Contact info (ES)
|
||||
name: Person name (ES)
|
||||
notes: Notes (ES)
|
||||
@@ -466,6 +466,7 @@ es:
|
||||
misc_releases:
|
||||
index:
|
||||
table_headers:
|
||||
approved: Approved (ES)
|
||||
contact_info: Contact info (ES)
|
||||
name: Person name (ES)
|
||||
notes: Notes (ES)
|
||||
@@ -474,6 +475,7 @@ es:
|
||||
music_releases:
|
||||
index:
|
||||
table_headers:
|
||||
approved: Approved (ES)
|
||||
composers_count: No. Composers (ES)
|
||||
file_infos_count: No. Files (ES)
|
||||
name: Name (ES)
|
||||
@@ -635,6 +637,7 @@ es:
|
||||
heading: Guardian Photo (ES)
|
||||
index:
|
||||
table_headers:
|
||||
approved: Approved (ES)
|
||||
email: Email (ES)
|
||||
name: Name (ES)
|
||||
notes: Notes (ES)
|
||||
|
||||
@@ -131,9 +131,7 @@ Rails.application.routes.draw do
|
||||
resources :projects, only: [] do
|
||||
resources :contract_templates, only: [:index] do
|
||||
resources :talent_releases, only: [:new, :create]
|
||||
resources :appearance_releases, only: [:new, :create] do
|
||||
resources :amendments, only: [:new, :create]
|
||||
end
|
||||
resources :appearance_releases, only: [:new, :create]
|
||||
resources :acquired_media_releases, only: [:new, :create]
|
||||
resources :location_releases, only: [:new, :create] do
|
||||
resources :amendments, only: [:new, :create]
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddAmendmentSignerDetailsToAppearanceReleases < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :appearance_releases, :amendment_signer_name, :string
|
||||
end
|
||||
end
|
||||
@@ -365,8 +365,7 @@ CREATE TABLE public.appearance_releases (
|
||||
guardian_2_address_country character varying,
|
||||
approved_by_user_name text,
|
||||
approved_by_user_email text,
|
||||
approved_at timestamp without time zone,
|
||||
amendment_signer_name character varying
|
||||
approved_at timestamp without time zone
|
||||
);
|
||||
|
||||
|
||||
@@ -3997,7 +3996,6 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20200727143209'),
|
||||
('20200730050903'),
|
||||
('20200803145912'),
|
||||
('20200803150138'),
|
||||
('20200804093409');
|
||||
('20200803150138');
|
||||
|
||||
|
||||
|
||||
@@ -4,108 +4,96 @@ RSpec.describe Public::AmendmentsController, type: :controller do
|
||||
let(:user) { create(:user) }
|
||||
let(:account) { user.primary_account }
|
||||
let(:project) { create(:project, account: account) }
|
||||
let(:contract_template) { create(:location_release_contract_template, :with_amendment_clause, project: project) }
|
||||
let(:location_release) { create(:location_release, contract_template: contract_template, project: project) }
|
||||
|
||||
render_views
|
||||
|
||||
shared_examples "amendments signing controller" do
|
||||
describe "#new" do
|
||||
it "shows amendment signing form for non-signed amendment of a release" do
|
||||
expect(subject.amendment_signed?).to be_falsey
|
||||
describe "#new" do
|
||||
it "shows amendment signing form for non-signed amendment of a release" do
|
||||
expect(location_release.amendment_signed?).to be_falsey
|
||||
|
||||
get :new, params: {
|
||||
account_id: account,
|
||||
project_id: project,
|
||||
contract_template_id: subject.contract_template,
|
||||
"#{subject.model_name.param_key}_id": subject
|
||||
}
|
||||
get :new, params: {
|
||||
account_id: account,
|
||||
project_id: project,
|
||||
contract_template_id: location_release.contract_template,
|
||||
location_release_id: location_release
|
||||
}
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response).to be_successful
|
||||
|
||||
body = CGI.unescape_html(response.body)
|
||||
expect(body).not_to match already_signed_message
|
||||
end
|
||||
|
||||
it "shows already signed message for signed amendment of a release" do
|
||||
expect(signed_release.amendment_signed?).to be_truthy
|
||||
|
||||
get :new, params: {
|
||||
account_id: account,
|
||||
project_id: project,
|
||||
contract_template_id: signed_release.contract_template,
|
||||
"#{signed_release.model_name.param_key}_id": signed_release
|
||||
}
|
||||
|
||||
expect(response).to be_successful
|
||||
|
||||
body = CGI.unescape_html(response.body)
|
||||
expect(body).to match already_signed_message
|
||||
end
|
||||
body = CGI.unescape_html(response.body)
|
||||
expect(body).not_to match already_signed_message
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
it "signs amendment" do
|
||||
expect(subject.amendment_signed?).to be_falsey
|
||||
it "shows already signed message for signed amendment of a release" do
|
||||
signed_release = create(:location_release, :amendment_signed, contract_template: contract_template, project: project)
|
||||
|
||||
post :create, params: {
|
||||
account_id: account,
|
||||
project_id: project,
|
||||
contract_template_id: subject.contract_template,
|
||||
"#{subject.model_name.param_key}_id": subject,
|
||||
"#{subject.model_name.param_key}": {
|
||||
amendment_signer_name: "Signer Name",
|
||||
amendment_signature_base64: signature_base64
|
||||
}
|
||||
}
|
||||
expect(signed_release.amendment_signed?).to be_truthy
|
||||
|
||||
expect(response).to be_successful
|
||||
get :new, params: {
|
||||
account_id: account,
|
||||
project_id: project,
|
||||
contract_template_id: location_release.contract_template,
|
||||
location_release_id: signed_release
|
||||
}
|
||||
|
||||
body = CGI.unescape_html(response.body)
|
||||
expect(body).not_to match already_signed_message
|
||||
expect(body).to match signed_successfully_message
|
||||
expect(response).to be_successful
|
||||
|
||||
expect(subject.class.last.amendment_signed?).to be_truthy
|
||||
expect(subject.class.last.amendment_signer_name).to eq "Signer Name"
|
||||
end
|
||||
|
||||
it "shows already signed message for signed amendment of a release" do
|
||||
expect(signed_release.amendment_signed?).to be_truthy
|
||||
|
||||
post :create, params: {
|
||||
account_id: account,
|
||||
project_id: project,
|
||||
contract_template_id: signed_release.contract_template,
|
||||
"#{signed_release.model_name.param_key}_id": signed_release,
|
||||
"#{signed_release.model_name.param_key}": {
|
||||
amendment_signer_name: "Signer Who",
|
||||
amendment_signature_base64: signature_base64
|
||||
}
|
||||
}
|
||||
|
||||
expect(response).to be_successful
|
||||
|
||||
body = CGI.unescape_html(response.body)
|
||||
expect(body).to match already_signed_message
|
||||
|
||||
expect(signed_release.amendment_signed?).to be_truthy
|
||||
expect(signed_release.amendment_signer_name).to eq "Amendment Signer"
|
||||
end
|
||||
body = CGI.unescape_html(response.body)
|
||||
expect(body).to match already_signed_message
|
||||
end
|
||||
end
|
||||
|
||||
context "for location release" do
|
||||
let(:contract_template) { create(:location_release_contract_template, :with_amendment_clause, project: project) }
|
||||
let(:signed_release) { create(:location_release, :amendment_signed, contract_template: contract_template, project: project) }
|
||||
subject { create(:location_release, contract_template: contract_template, project: project) }
|
||||
describe "#create" do
|
||||
it "signs amendment" do
|
||||
expect(location_release.amendment_signed?).to be_falsey
|
||||
|
||||
it_behaves_like "amendments signing controller"
|
||||
end
|
||||
post :create, params: {
|
||||
account_id: account,
|
||||
project_id: project,
|
||||
contract_template_id: location_release.contract_template,
|
||||
location_release_id: location_release,
|
||||
location_release: {
|
||||
amendment_signer_name: "Signer Name",
|
||||
amendment_signature_base64: signature_base64
|
||||
}
|
||||
}
|
||||
|
||||
context "for location release" do
|
||||
let(:contract_template) { create(:appearance_release_contract_template, :with_amendment_clause, project: project) }
|
||||
let(:signed_release) { create(:appearance_release, :amendment_signed, contract_template: contract_template, project: project) }
|
||||
subject { create(:appearance_release, contract_template: contract_template, project: project) }
|
||||
expect(response).to be_successful
|
||||
|
||||
it_behaves_like "amendments signing controller"
|
||||
body = CGI.unescape_html(response.body)
|
||||
expect(body).not_to match already_signed_message
|
||||
expect(body).to match signed_successfully_message
|
||||
|
||||
expect(LocationRelease.last.amendment_signed?).to be_truthy
|
||||
expect(LocationRelease.last.amendment_signer_name).to eq "Signer Name"
|
||||
end
|
||||
|
||||
it "shows already signed message for signed amendment of a release" do
|
||||
signed_release = create(:location_release, :amendment_signed, name: "Test Loc", amendment_signer_name: "Big Signer", contract_template: contract_template, project: project)
|
||||
|
||||
expect(signed_release.amendment_signed?).to be_truthy
|
||||
|
||||
post :create, params: {
|
||||
account_id: account,
|
||||
project_id: project,
|
||||
contract_template_id: location_release.contract_template,
|
||||
location_release_id: signed_release,
|
||||
location_release: {
|
||||
amendment_signer_name: "Signer Who",
|
||||
amendment_signature_base64: signature_base64
|
||||
}
|
||||
}
|
||||
|
||||
expect(response).to be_successful
|
||||
|
||||
body = CGI.unescape_html(response.body)
|
||||
expect(body).to match already_signed_message
|
||||
|
||||
expect(signed_release.amendment_signed?).to be_truthy
|
||||
expect(signed_release.amendment_signer_name).to eq "Big Signer"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
@@ -121,4 +109,4 @@ RSpec.describe Public::AmendmentsController, type: :controller do
|
||||
def signature_base64
|
||||
@signature_base64 ||= Base64Image.from_image(file_fixture('signature.png')).data_uri
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,6 +4,22 @@ FactoryBot.define do
|
||||
|
||||
name "Test Acquired Media Release"
|
||||
|
||||
trait :with_address do
|
||||
person_address_street1 "St1"
|
||||
person_address_street2 "St2"
|
||||
person_address_city "City"
|
||||
person_address_state "State"
|
||||
person_address_zip "123"
|
||||
person_address_country "US"
|
||||
end
|
||||
|
||||
trait :with_owner_info do
|
||||
person_first_name "Jane"
|
||||
person_last_name "Doe"
|
||||
person_phone "100-555-1001"
|
||||
person_email "owner@email.com"
|
||||
end
|
||||
|
||||
trait :native do
|
||||
signature do
|
||||
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
|
||||
|
||||
@@ -32,14 +32,6 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
trait :amendment_signed do
|
||||
amendment_signature do
|
||||
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
|
||||
Rack::Test::UploadedFile.new(path, "image/png")
|
||||
end
|
||||
amendment_signer_name "Amendment Signer"
|
||||
end
|
||||
|
||||
trait :minor do
|
||||
minor true
|
||||
guardian_first_name "Jamie"
|
||||
|
||||
@@ -4,10 +4,20 @@ FactoryBot.define do
|
||||
|
||||
name "Test Materials"
|
||||
|
||||
trait :with_address do
|
||||
person_address_street1 "St1"
|
||||
person_address_street2 "St2"
|
||||
person_address_city "City"
|
||||
person_address_state "State"
|
||||
person_address_zip "123"
|
||||
person_address_country "US"
|
||||
end
|
||||
|
||||
trait :native do
|
||||
person_first_name "Jane"
|
||||
person_last_name "Doe"
|
||||
person_phone "100-555-1001"
|
||||
person_email "owner@email.com"
|
||||
|
||||
signature do
|
||||
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
|
||||
|
||||
@@ -66,18 +66,6 @@ RSpec.feature 'User manages contract templates', type: :feature do
|
||||
expect(ContractTemplate.last.amendment_clause.body.to_s).to match /Amendment clause text/
|
||||
end
|
||||
|
||||
scenario 'appearance release template has a amendment clause field' do
|
||||
visit new_project_contract_template_path(project)
|
||||
|
||||
fill_in 'Name', with: 'My Release Template'
|
||||
select 'Appearance Release', from: 'Release type'
|
||||
fill_hidden amendment_clause_field, with: 'Amendment clause text'
|
||||
click_on create_release_template_button
|
||||
|
||||
expect(page).to have_content(create_contract_template_success_message)
|
||||
expect(ContractTemplate.last.amendment_clause.body.to_s).to match /Amendment clause text/
|
||||
end
|
||||
|
||||
scenario 'medical release template has a guardian clause field' do
|
||||
visit new_project_contract_template_path(project)
|
||||
|
||||
|
||||
@@ -165,6 +165,24 @@ feature "User managing acquired_media releases" do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
scenario "index table shows owner info" do
|
||||
release = create(:acquired_media_release, :with_owner_info, :with_address, project: project)
|
||||
|
||||
visit project_acquired_media_releases_path(project)
|
||||
|
||||
expect(page).to have_content owner_info_table_header
|
||||
|
||||
expect(page).to have_content release.person_first_name
|
||||
expect(page).to have_content release.person_last_name
|
||||
expect(page).to have_content release.person_phone
|
||||
expect(page).to have_content release.person_email
|
||||
expect(page).to have_content release.person_address_street1
|
||||
expect(page).to have_content release.person_address_city
|
||||
expect(page).to have_content release.person_address_state
|
||||
expect(page).to have_content release.person_address_zip
|
||||
expect(page).to have_content release.person_address_country
|
||||
end
|
||||
|
||||
scenario "creating a release for an adult", js: true do
|
||||
visit new_project_acquired_media_release_path(project)
|
||||
|
||||
@@ -262,62 +280,63 @@ feature "User managing acquired_media releases" do
|
||||
end
|
||||
|
||||
scenario "creating, updating, destroying a release", js: true do
|
||||
release_data = {
|
||||
name: "Test Acquired Media Release",
|
||||
applicable_media: ApplicableMedium.last.label,
|
||||
territory: Territory.last.label,
|
||||
term: Term.last.label,
|
||||
restriction: Restriction.first.label,
|
||||
restriction_text: "Not available in China",
|
||||
}
|
||||
resize_window_to(1_000, 1_000) do
|
||||
release_data = {
|
||||
name: "Test Acquired Media Release",
|
||||
applicable_media: ApplicableMedium.last.label,
|
||||
territory: Territory.last.label,
|
||||
term: Term.last.label,
|
||||
restriction: Restriction.first.label,
|
||||
restriction_text: "Not available in China",
|
||||
}
|
||||
|
||||
sign_in current_user
|
||||
visit new_project_acquired_media_release_path(project)
|
||||
sign_in current_user
|
||||
visit new_project_acquired_media_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
|
||||
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(acquired_media_name_field)
|
||||
end
|
||||
|
||||
by "attaching files" do
|
||||
drop_file Rails.root.join(file_fixture("video_file.mp4")), type: "file-info-dropzone"
|
||||
click_button create_release_button
|
||||
|
||||
expect(page).to have_invalid_field(acquired_media_name_field)
|
||||
end
|
||||
|
||||
by "filling out the remaining information" do
|
||||
fill_in_release_fields release_data
|
||||
click_button create_release_button
|
||||
|
||||
expect(page).to have_content(create_release_notice)
|
||||
expect(page).to have_content("1")
|
||||
|
||||
click_on "Manage"
|
||||
expect(page).to have_link("Download")
|
||||
end
|
||||
|
||||
it_also "updates an existing release" do
|
||||
click_link "Edit"
|
||||
|
||||
within ".dropzone" do
|
||||
expect(page).to have_filename("video_file.mp4")
|
||||
expect(page).to have_invalid_field(acquired_media_name_field)
|
||||
end
|
||||
|
||||
expect(page).to have_filled_in_data(release_data)
|
||||
by "attaching files" do
|
||||
drop_file Rails.root.join(file_fixture("video_file.mp4")), type: "file-info-dropzone"
|
||||
click_button create_release_button
|
||||
|
||||
fill_in_release_fields name: "New name"
|
||||
drop_file Rails.root.join(file_fixture("person_photo.png")), type: "file-info-dropzone"
|
||||
click_button update_release_button
|
||||
expect(page).to have_invalid_field(acquired_media_name_field)
|
||||
end
|
||||
|
||||
expect(page).to have_content(update_release_notice)
|
||||
expect(page).to have_content("New name")
|
||||
expect(page).to have_content("2")
|
||||
end
|
||||
by "filling out the remaining information" do
|
||||
fill_in_release_fields release_data
|
||||
click_button create_release_button
|
||||
|
||||
it_also "deletes an existing release" do
|
||||
expect(page).to have_content(create_release_notice)
|
||||
expect(page).to have_content("1")
|
||||
|
||||
click_on "Manage"
|
||||
expect(page).to have_link("Download")
|
||||
end
|
||||
|
||||
it_also "updates an existing release" do
|
||||
click_link "Edit"
|
||||
|
||||
within ".dropzone" do
|
||||
expect(page).to have_filename("video_file.mp4")
|
||||
end
|
||||
|
||||
expect(page).to have_filled_in_data(release_data)
|
||||
|
||||
fill_in_release_fields name: "New name"
|
||||
drop_file Rails.root.join(file_fixture("person_photo.png")), type: "file-info-dropzone"
|
||||
click_button update_release_button
|
||||
|
||||
expect(page).to have_content(update_release_notice)
|
||||
expect(page).to have_content("New name")
|
||||
expect(page).to have_content("2")
|
||||
end
|
||||
|
||||
it_also "deletes an existing release" do
|
||||
click_button "Manage"
|
||||
accept_alert do
|
||||
click_link "Delete"
|
||||
@@ -325,6 +344,7 @@ feature "User managing acquired_media releases" do
|
||||
|
||||
expect(page).not_to have_content("New name")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario "viewing the contract PDF for an adult" do
|
||||
@@ -836,4 +856,8 @@ feature "User managing acquired_media releases" do
|
||||
def successful_import_message
|
||||
t 'acquired_media_releases.create.notice'
|
||||
end
|
||||
|
||||
def owner_info_table_header
|
||||
t 'acquired_media_releases.index.table_headers.owner_info'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -144,49 +144,6 @@ feature 'User managing appearance releases' do
|
||||
|
||||
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(:appearance_release_contract_template, :with_amendment_clause, project: project)
|
||||
release = create(:appearance_release, contract_template: contract_template, project: project)
|
||||
|
||||
expect(release.amendment_signed?).to be_falsey
|
||||
|
||||
visit new_account_project_contract_template_appearance_release_amendment_path(project.account, project, contract_template, release)
|
||||
|
||||
expect(page).to have_content amendments_heading
|
||||
|
||||
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(AppearanceRelease.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(:appearance_release_contract_template, :with_amendment_clause, project: project)
|
||||
release = create(:appearance_release, :amendment_signed, contract_template: contract_template, project: project)
|
||||
|
||||
expect(release.amendment_signed?).to be_truthy
|
||||
|
||||
visit new_account_project_contract_template_appearance_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(:appearance_release_contract_template, :with_amendment_clause, project: project)
|
||||
release = create(:appearance_release, contract_template: contract_template, project: project)
|
||||
|
||||
visit new_account_project_contract_template_appearance_release_amendment_path(project.account, project, contract_template, release)
|
||||
|
||||
expect(page).to have_content copy_url_button
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
context 'when signed in' do
|
||||
@@ -335,81 +292,7 @@ feature 'User managing appearance releases' do
|
||||
expect(page).to have_content('New Name')
|
||||
end
|
||||
|
||||
scenario "signing amendment for a not-signed amendment release", js: true do
|
||||
contract_template = create(:appearance_release_contract_template, :with_amendment_clause, project: project)
|
||||
release = create(:appearance_release, person_first_name: "First", contract_template: contract_template, project: project)
|
||||
|
||||
expect(release.amendment_signed?).to be_falsey
|
||||
|
||||
visit project_appearance_releases_path(project)
|
||||
|
||||
expect(page).to have_content "First"
|
||||
|
||||
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
|
||||
|
||||
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(AppearanceRelease.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(:appearance_release_contract_template, :with_amendment_clause, project: project)
|
||||
release = create(:appearance_release, :amendment_signed, person_first_name: "Firstn", contract_template: contract_template, project: project)
|
||||
|
||||
expect(release.amendment_signed?).to be_truthy
|
||||
|
||||
visit project_appearance_releases_path(project)
|
||||
|
||||
expect(page).to have_content "Firstn"
|
||||
|
||||
click_on manage_button
|
||||
|
||||
expect(page).not_to have_link sign_amendment_link
|
||||
end
|
||||
|
||||
scenario "signed amendment release have checked box in appearance releases index table", js: true do
|
||||
contract_template = create(:appearance_release_contract_template, :with_amendment_clause, project: project)
|
||||
not_signed_release = create(:appearance_release, person_first_name: "Firstn", contract_template: contract_template, project: project)
|
||||
expect(not_signed_release.amendment_signed?).to be_falsey
|
||||
|
||||
visit project_appearance_releases_path(project)
|
||||
|
||||
expect(page).to have_content "Firstn"
|
||||
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(:appearance_release, :amendment_signed, person_first_name: "Signedn", contract_template: contract_template, project: project)
|
||||
expect(signed_release.amendment_signed?).to be_truthy
|
||||
|
||||
visit project_appearance_releases_path(project)
|
||||
|
||||
expect(page).to have_content "Signedn"
|
||||
|
||||
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(:appearance_release_contract_template, :with_amendment_clause, project: project)
|
||||
release = create(:appearance_release, contract_template: contract_template, project: project)
|
||||
|
||||
visit new_account_project_contract_template_appearance_release_amendment_path(project.account, project, contract_template, release)
|
||||
|
||||
expect(page).to have_content copy_url_button
|
||||
end
|
||||
|
||||
scenario 'viewing the contract PDF when amendment is not yet signed' do
|
||||
scenario 'viewing the contract PDF' do
|
||||
appearance_release = create(:appearance_release_with_contract_template,
|
||||
:native,
|
||||
project: project,
|
||||
@@ -436,7 +319,6 @@ feature 'User managing appearance releases' do
|
||||
expect(content_type).to eq('application/pdf')
|
||||
expect(content_disposition).to include('inline')
|
||||
expect(pdf_filename).to include('doe-jane')
|
||||
expect(pdf_body).not_to have_content amendment_page_heading
|
||||
expect(pdf_body).to have_content('Jane Doe')
|
||||
expect(pdf_body).to have_content('NOTES')
|
||||
expect(pdf_body).to have_content('Note 1')
|
||||
@@ -451,35 +333,6 @@ feature 'User managing appearance releases' do
|
||||
expect(pdf_body).not_to have_content('Guardian Email')
|
||||
end
|
||||
|
||||
scenario "viewing the contract PDF when amendment is signed" do
|
||||
contract_template = create(:appearance_release_contract_template, :with_amendment_clause, project: project)
|
||||
appearance_release = create(:appearance_release,
|
||||
:amendment_signed,
|
||||
:native,
|
||||
contract_template: contract_template,
|
||||
project: project,
|
||||
person_first_name: "John",
|
||||
person_last_name: "Doe")
|
||||
|
||||
sign_in(current_user)
|
||||
visit project_appearance_releases_path(project)
|
||||
click_link *view_release_pdf_link_for(appearance_release)
|
||||
|
||||
expect(content_type).to eq("application/pdf")
|
||||
expect(content_disposition).to include("inline")
|
||||
expect(pdf_filename).to include("doe-john")
|
||||
|
||||
expect(pdf_body).to have_content("John Doe")
|
||||
|
||||
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 appearance_release.amendment_signer_name
|
||||
end
|
||||
|
||||
scenario 'viewing contract PDF for a minor without guardian photo' do
|
||||
appearance_release = create(:appearance_release_with_contract_template, :native, :minor, project: project)
|
||||
|
||||
@@ -520,7 +373,7 @@ feature 'User managing appearance releases' do
|
||||
|
||||
visit project_appearance_releases_path(project)
|
||||
|
||||
click_on manage_button
|
||||
click_on 'Manage'
|
||||
accept_alert do
|
||||
click_link *destroy_link_for(appearance_release)
|
||||
end
|
||||
@@ -723,7 +576,7 @@ feature 'User managing appearance releases' do
|
||||
create(:appearance_release_with_contract_template, :native, project: project)
|
||||
|
||||
visit project_appearance_releases_path(project)
|
||||
click_on manage_button
|
||||
click_on "Manage"
|
||||
|
||||
expect(page).not_to have_link(review_action, exact: true)
|
||||
end
|
||||
@@ -741,7 +594,7 @@ feature 'User managing appearance releases' do
|
||||
|
||||
visit project_appearance_releases_path(project)
|
||||
|
||||
click_on manage_button
|
||||
click_on 'Manage'
|
||||
expect(page).not_to have_link('Download', exact: true)
|
||||
end
|
||||
|
||||
@@ -749,7 +602,7 @@ feature 'User managing appearance releases' do
|
||||
create(:appearance_release_with_contract_template, :native, project: project)
|
||||
|
||||
visit project_appearance_releases_path(project)
|
||||
click_on manage_button
|
||||
click_on "Manage"
|
||||
|
||||
expect(page).not_to have_link(review_action, exact: true)
|
||||
end
|
||||
@@ -1013,56 +866,4 @@ feature 'User managing appearance releases' do
|
||||
def date_issued
|
||||
t 'contracts.for_office_use_only.description_labels.date_issued'
|
||||
end
|
||||
|
||||
def amendments_heading
|
||||
t 'public.amendments.new.amendment.heading'
|
||||
end
|
||||
|
||||
def amendment_signer_name_field
|
||||
'appearance_release[amendment_signer_name]'
|
||||
end
|
||||
|
||||
def amendment_signature_field
|
||||
'appearance_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 'appearance_releases.appearance_release.actions.manage'
|
||||
end
|
||||
|
||||
def sign_amendment_link
|
||||
t 'appearance_releases.appearance_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
|
||||
end
|
||||
|
||||
@@ -376,7 +376,7 @@ feature "User managing location releases" do
|
||||
|
||||
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_page_heading
|
||||
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
|
||||
|
||||
@@ -185,6 +185,24 @@ feature "User managing material releases" do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
scenario "index table shows owner info" do
|
||||
release = create(:material_release, :native, :with_address, project: project)
|
||||
|
||||
visit project_material_releases_path(project)
|
||||
|
||||
expect(page).to have_content owner_info_table_header
|
||||
|
||||
expect(page).to have_content release.person_first_name
|
||||
expect(page).to have_content release.person_last_name
|
||||
expect(page).to have_content release.person_phone
|
||||
expect(page).to have_content release.person_email
|
||||
expect(page).to have_content release.person_address_street1
|
||||
expect(page).to have_content release.person_address_city
|
||||
expect(page).to have_content release.person_address_state
|
||||
expect(page).to have_content release.person_address_zip
|
||||
expect(page).to have_content release.person_address_country
|
||||
end
|
||||
|
||||
scenario "creating a release for and adult", js: true do
|
||||
visit new_project_material_release_path(project)
|
||||
|
||||
@@ -813,4 +831,8 @@ feature "User managing material releases" do
|
||||
def signature_field
|
||||
'material_release_signature_base64'
|
||||
end
|
||||
|
||||
def owner_info_table_header
|
||||
t 'material_releases.index.table_headers.owner_info'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,6 +25,31 @@ describe GenerateContractsZipJob do
|
||||
end
|
||||
|
||||
describe ".perform_now" do
|
||||
shared_examples "generates ZIP containig CSV file with all releases data" do
|
||||
it "generates ZIP containing CSV file with all releases data for all release types" do
|
||||
lowercase_plural = subject.constantize.model_name.plural
|
||||
GenerateContractsZipJob.perform_now(project, download, subject, 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 subject
|
||||
release_headers = release_class.csv_headers
|
||||
|
||||
release_headers.each do |header|
|
||||
expect(csv_file).to match header
|
||||
expect(csv_file).not_to match translation_missing
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "updates a download record and creates attachment for it" do
|
||||
GenerateContractsZipJob.perform_now(project, download, "AppearanceRelease", project.appearance_releases.ids)
|
||||
|
||||
@@ -35,36 +60,60 @@ 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
|
||||
context "generates ZIP for acquired media releases" do
|
||||
let(:release) { create(:acquired_media_release_with_contract_template, :native, project: project) }
|
||||
subject { 'AcquiredMediaRelease' }
|
||||
|
||||
release_types.each do |type|
|
||||
lowercase_plural = type.constantize.model_name.plural
|
||||
GenerateContractsZipJob.perform_now(project, download, type, project.public_send(lowercase_plural).ids)
|
||||
it_behaves_like "generates ZIP containig CSV file with all releases data"
|
||||
end
|
||||
|
||||
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
|
||||
context "generates ZIP for appearance releases" do
|
||||
let(:release) { create(:appearance_release_with_contract_template, :native, project: project, person_name: "John Doe") }
|
||||
subject { 'AppearanceRelease' }
|
||||
|
||||
csv_file = entry.get_input_stream.read
|
||||
it_behaves_like "generates ZIP containig CSV file with all releases data"
|
||||
end
|
||||
|
||||
release_class = Object.const_get type
|
||||
release_headers = release_class.csv_headers
|
||||
context "generates ZIP for location releases" do
|
||||
let(:release) { create(:location_release_with_contract_template, :native, project: project) }
|
||||
subject { 'LocationRelease' }
|
||||
|
||||
release_headers.each do |header|
|
||||
expect(csv_file).to match header
|
||||
end
|
||||
end
|
||||
it_behaves_like "generates ZIP containig CSV file with all releases data"
|
||||
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
|
||||
context "generates ZIP for material releases" do
|
||||
let(:release) { create(:material_release_with_contract_template, :native, project: project) }
|
||||
subject { 'MaterialRelease' }
|
||||
|
||||
it_behaves_like "generates ZIP containig CSV file with all releases data"
|
||||
end
|
||||
|
||||
context "generates ZIP for medical releases" do
|
||||
let(:release) { create(:medical_release_with_contract_template, :native, project: project) }
|
||||
subject { 'MedicalRelease' }
|
||||
|
||||
it_behaves_like "generates ZIP containig CSV file with all releases data"
|
||||
end
|
||||
|
||||
context "generates ZIP for misc releases" do
|
||||
let(:release) { create(:misc_release_with_contract_template, :native, project: project) }
|
||||
subject { 'MiscRelease' }
|
||||
|
||||
it_behaves_like "generates ZIP containig CSV file with all releases data"
|
||||
end
|
||||
|
||||
context "generates ZIP for music releases" do
|
||||
let(:release) { create(:music_release_with_contract_template, project: project) }
|
||||
subject { 'MusicRelease' }
|
||||
|
||||
it_behaves_like "generates ZIP containig CSV file with all releases data"
|
||||
end
|
||||
|
||||
context "generates ZIP for talent releases" do
|
||||
let(:release) { create(:talent_release_with_contract_template, :native, project: project) }
|
||||
subject { 'TalentRelease' }
|
||||
|
||||
it_behaves_like "generates ZIP containig CSV file with all releases data"
|
||||
end
|
||||
|
||||
context "When there are errors" do
|
||||
@@ -88,21 +137,16 @@ 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")
|
||||
releases = %w[acquired-media appearance location material medical misc music talent]
|
||||
releases.each do |release|
|
||||
if File.exists? "#{path}/my-video-project_#{release}-releases.zip"
|
||||
File.delete("#{path}/my-video-project_#{release}-releases.zip")
|
||||
end
|
||||
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)
|
||||
def translation_missing
|
||||
/translation missing/
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user