Compare commits

...

15 Commits

Author SHA1 Message Date
Bilal
4d83cff8d2 move approved column to common headers 2020-08-05 15:43:45 +02:00
Bilal
a8944c6c4a fix localizations 2020-08-05 15:37:58 +02:00
Bilal
7e571845d8 fix talent release CSV export 2020-08-05 15:35:19 +02:00
Bilal
d1aa103d9c fix music release CSV export 2020-08-05 15:24:57 +02:00
Bilal
3242bebd6a fix misc release CSV export 2020-08-05 15:22:04 +02:00
Bilal
6267f12cc4 fix medical release CSV export 2020-08-05 15:19:01 +02:00
Bilal
78d182624d fix material release CSV export 2020-08-05 15:16:00 +02:00
Bilal
088994b90c fix appearance release CSV export 2020-08-05 15:12:39 +02:00
Bilal
fd7357045c fix location release CSV export 2020-08-05 15:04:47 +02:00
Bilal
6378d45274 fix acq.media release CSV export 2020-08-05 14:50:58 +02:00
Bilal
708cc5e0a8 fix location release CSV export 2020-08-05 14:32:53 +02:00
Bilal
56d73d9844 improve spec 2020-08-05 12:58:30 +02:00
Bilal
580312bc52 fix spec 2020-08-04 15:24:45 +02:00
Bilal
0294a480ee show owner info in acquired media release table 2020-08-04 15:08:19 +02:00
Bilal
a7b7e1ecf9 show owner info in material release table 2020-08-04 13:14:42 +02:00
16 changed files with 258 additions and 110 deletions

View File

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

View File

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

View File

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

View File

@@ -20,7 +20,7 @@ class MaterialRelease < ApplicationRecord
class << self
def custom_csv_exportable_headers
%i[name]
%i[name owner_info]
end
end

View File

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

View File

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

View File

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

View File

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

View File

@@ -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:
@@ -826,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:
@@ -849,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
@@ -903,6 +907,7 @@ en:
approved: Approved
name: Name
notes: Notes
owner_info: Owner Info
signed_at: Date Signed
tags: Tags
material_release:
@@ -927,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

View File

@@ -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:
@@ -64,6 +66,7 @@ es:
index:
imported_appearance_release_missing_attachment: Person photo or contract missing for imported appearance release (ES)
table_headers:
approved: Approved (ES)
contact_info: ""
name: ""
notes: ""
@@ -402,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)
@@ -409,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)
@@ -434,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:
@@ -444,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)
@@ -458,6 +466,7 @@ es:
misc_releases:
index:
table_headers:
approved: Approved (ES)
contact_info: Contact info (ES)
name: Person name (ES)
notes: Notes (ES)
@@ -466,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)
@@ -627,6 +637,7 @@ es:
heading: Guardian Photo (ES)
index:
table_headers:
approved: Approved (ES)
email: Email (ES)
name: Name (ES)
notes: Notes (ES)

View File

@@ -9,20 +9,6 @@ SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
--
-- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: -
--
@@ -1479,6 +1465,7 @@ CREATE TABLE public.settings (
--
CREATE SEQUENCE public.settings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1514,6 +1501,7 @@ CREATE TABLE public.taggings (
--
CREATE SEQUENCE public.taggings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1544,6 +1532,7 @@ CREATE TABLE public.tags (
--
CREATE SEQUENCE public.tags_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE

View File

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

View File

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

View File

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

View File

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

View File

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