Compare commits

...

4 Commits

Author SHA1 Message Date
bilal
867260514e fix appearance release spec 2020-06-12 14:53:54 +02:00
bilal
a5822a9556 update specs to test guardian email field 2020-06-12 14:45:51 +02:00
bilal
96968b2adc show guardian email when downloading appearance release contract 2020-06-12 13:56:14 +02:00
bilal
25c4c73ad5 add guardian email field to the appearance release public signing form 2020-06-12 13:35:52 +02:00
8 changed files with 40 additions and 4 deletions

View File

@@ -41,7 +41,7 @@ class Public::AppearanceReleasesController < Public::BaseController
def appearance_release_params
params.require(:appearance_release).permit(:person_address, :person_first_name, :person_last_name, :person_phone, :person_email, :person_photo,
:guardian_address, :guardian_first_name, :guardian_last_name, :guardian_phone, :guardian_photo, :minor,
:guardian_address, :guardian_first_name, :guardian_last_name, :guardian_phone, :guardian_email, :guardian_photo, :minor,
:signature_base64, :person_date_of_birth,
:locale, :contract_template,)
end

View File

@@ -39,6 +39,7 @@ class AppearanceRelease < ApplicationRecord
# These validations apply to releases being signed by a minor
with_options if: :minor? do
validates :guardian_first_name, :guardian_last_name, presence: true
validates :guardian_email, email: true, allow_blank: true
end
validates :person_photo, content_type: face_photo_acceptable_content_types

View File

@@ -56,6 +56,7 @@
<%= description_list_pair_for releasable, :guardian_name, append: ":" %>
<%= description_list_pair_for releasable, :guardian_address, append: ":" %>
<%= description_list_pair_for releasable, :guardian_phone, append: ":" %>
<%= description_list_pair_for releasable, :guardian_email, append: ":" %>
<%= description_list_pair_for releasable, :signed_on, append: ":" %>
</dl>

View File

@@ -76,6 +76,9 @@
<%= form.text_field :guardian_last_name, required: @appearance_release.minor?, wrapper_class: "col-sm-3" %>
<%= form.phone_field :guardian_phone, wrapper_class: "col-sm-6" %>
</div>
<div class="form-row">
<%= form.text_field :guardian_email, wrapper_class: "col-sm-6" %>
</div>
<div class="form-row">
<%= form.text_field :guardian_address, wrapper_class: "col-sm-6" %>
</div>

View File

@@ -0,0 +1,5 @@
class AddGuardianEmailToAppearanceReleases < ActiveRecord::Migration[6.0]
def change
add_column :appearance_releases, :guardian_email, :string
end
end

View File

@@ -263,7 +263,10 @@ RSpec.describe AppearanceReleasesController, tye: :controller do
end
def minor_appearance_release_params
attributes_for(:appearance_release, :non_native, :minor_with_guardian_photo).except(:contract).merge(contract_param, exploitable_rights_params)
attributes_for(:appearance_release, :non_native, :minor_with_guardian_photo)
.except(:contract)
.except(:guardian_email)
.merge(contract_param, exploitable_rights_params)
end
def exploitable_rights_params

View File

@@ -33,6 +33,7 @@ FactoryBot.define do
guardian_last_name "Doe"
guardian_address "100 Test Lane, New York, 10001"
guardian_phone "123-555-1234"
guardian_email "guardian@galaxy.all"
end
trait :minor_with_guardian_photo do
@@ -41,6 +42,7 @@ FactoryBot.define do
guardian_last_name "Doe"
guardian_address "100 Test Lane, New York, 10001"
guardian_phone "123-555-1234"
guardian_email "guardian@galaxy.all"
guardian_photo do
path = Rails.root.join("spec", "fixtures", "files", "pratt.jpg")
Rack::Test::UploadedFile.new(path, "image/jpeg")

View File

@@ -25,7 +25,7 @@ feature 'User managing appearance releases' do
fill_in person_date_of_birth, with: '01/01/1999'
attach_file person_photo_field, file_fixture('person_photo.png'), visible: :all
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
click_button 'I have read and agree to the above'
click_button submit_release_button
expect(page).to have_content(successful_submission_message)
end
@@ -45,6 +45,7 @@ feature 'User managing appearance releases' do
page.check person_is_minor_checkbox
expect(page).to have_content('GUARDIAN INFORMATION')
expect(page).to have_content('GUARDIAN PHOTO')
expect(page).to have_content 'Guardian Email'
fill_in guardian_first_name_field, with: 'Guardian'
fill_in guardian_last_name_field, with: 'Name'
@@ -58,7 +59,14 @@ feature 'User managing appearance releases' do
attach_file person_photo_field, file_fixture('person_photo.png'), visible: :all
attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
click_button 'I have read and agree to the above'
fill_in guardian_email_field, with: 'invalid@email'
click_button submit_release_button
expect(page).to have_content('Guardian email is not an email')
fill_in guardian_email_field, with: 'valid@email.com'
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
click_button submit_release_button
expect(page).to have_content(successful_submission_message)
end
@@ -249,6 +257,7 @@ feature 'User managing appearance releases' do
expect(pdf_body).to have_content('TAGS')
expect(pdf_body).to have_content('Woman')
expect(pdf_body).to have_content('Brunette')
expect(pdf_body).not_to have_content('Guardian Email')
end
scenario 'viewing contract PDF for a minor without guardian photo' do
@@ -262,8 +271,10 @@ feature 'User managing appearance releases' do
expect(pdf_filename).to include(appearance_release.filename_suffix.parameterize)
expect(pdf_body).to have_content(appearance_release.name)
expect(pdf_body).to have_content(appearance_release.guardian_name)
expect(pdf_body).to have_content(appearance_release.guardian_email)
expect(pdf_body).to have_content photos_heading.upcase
expect(pdf_body).to have_content(appearance_release.photo.filename.to_s)
expect(pdf_body).to have_content('Guardian Email')
end
scenario 'viewing contract PDF for a minor with guardian photo' do
@@ -277,9 +288,11 @@ feature 'User managing appearance releases' do
expect(pdf_filename).to include(appearance_release.filename_suffix.parameterize)
expect(pdf_body).to have_content(appearance_release.name)
expect(pdf_body).to have_content(appearance_release.guardian_name)
expect(pdf_body).to have_content(appearance_release.guardian_email)
expect(pdf_body).to have_content photos_heading(2).upcase
expect(pdf_body).to have_content(appearance_release.photo.filename.to_s)
expect(pdf_body).to have_content(appearance_release.guardian_photo.filename.to_s)
expect(pdf_body).to have_content('Guardian Email')
end
scenario 'deleting a release', js: true do
@@ -470,6 +483,10 @@ feature 'User managing appearance releases' do
'Guardian phone'
end
def guardian_email_field
'Guardian email'
end
def guardian_photo_field
'appearance_release[guardian_photo]'
end
@@ -518,6 +535,10 @@ feature 'User managing appearance releases' do
'Import Release'
end
def submit_release_button
'I have read and agree to the above'
end
def submit_update_button
'Save Changes'
end