Compare commits
3 Commits
cast-me-mv
...
make-all-f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e611094ab | ||
|
|
021ac7ffc6 | ||
|
|
6d62caa96a |
@@ -36,7 +36,12 @@ class LocationRelease < ApplicationRecord
|
||||
validate :end_date_after_start_date
|
||||
|
||||
with_options on: :native do
|
||||
validates :person_first_name, :person_last_name, presence: true
|
||||
validates :address_street1, :address_city, :address_state, :address_zip, :address_country,
|
||||
:person_first_name, :person_last_name,
|
||||
:person_phone, :person_email, :person_company, :person_title,
|
||||
:person_address_street1, :person_address_city, :person_address_state,
|
||||
:person_address_zip, :person_address_country,
|
||||
:filming_started_on, :filming_ended_on, :filming_hours, presence: true
|
||||
validates :signature, attached: true
|
||||
end
|
||||
|
||||
|
||||
@@ -17,21 +17,21 @@
|
||||
<div class="form-row">
|
||||
<%= form.text_field :name, required: true, wrapper_class: "col-12" %>
|
||||
</div>
|
||||
<%= render "shared/address_fields", form: form, subject: "" %>
|
||||
<%= render "shared/address_fields", form: form, subject: "", required: true %>
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
|
||||
<%= card_field_set_tag t(".contact_info.heading") do %>
|
||||
<div class="form-row">
|
||||
<%= form.text_field :person_first_name, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_last_name, wrapper_class: "col-sm-6" %>
|
||||
<%= form.phone_field :person_phone, wrapper_class: "col-sm-6" %>
|
||||
<%= form.email_field :person_email, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_company, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_title, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_first_name, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_last_name, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.phone_field :person_phone, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.email_field :person_email, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_company, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_title, required: true, wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
<%= render "shared/address_fields", form: form, subject: "person" %>
|
||||
<%= render "shared/address_fields", form: form, subject: "person", required: true %>
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
@@ -39,9 +39,9 @@
|
||||
|
||||
<%= card_field_set_tag t(".filming_info.heading") do %>
|
||||
<div class="form-row">
|
||||
<%= form.text_field :filming_started_on, wrapper_class: "col-sm-6", class: "datepicker-control", readonly: true %>
|
||||
<%= form.text_field :filming_ended_on, wrapper_class: "col-sm-6", class: "datepicker-control", readonly: true %>
|
||||
<%= form.text_field :filming_hours, wrapper_class: "col-sm-12" %>
|
||||
<%= form.text_field :filming_started_on, required: true, wrapper_class: "col-sm-6", class: "datepicker-control", readonly: true %>
|
||||
<%= form.text_field :filming_ended_on, required: true, wrapper_class: "col-sm-6", class: "datepicker-control", readonly: true %>
|
||||
<%= form.text_field :filming_hours, required: true, wrapper_class: "col-sm-12" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<% field_name_prefix = subject.present? ? "#{subject}_" : "" %>
|
||||
<% required = required || false %>
|
||||
|
||||
<div class="form-row">
|
||||
<%= form.text_field "#{field_name_prefix}address_street1", wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field "#{field_name_prefix}address_street1", required: required, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field "#{field_name_prefix}address_street2", wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<%= form.text_field "#{field_name_prefix}address_city", wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field "#{field_name_prefix}address_state", wrapper_class: "col-sm-3" %>
|
||||
<%= form.text_field "#{field_name_prefix}address_zip", wrapper_class: "col-sm-3" %>
|
||||
<%= form.text_field "#{field_name_prefix}address_city", required: required, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field "#{field_name_prefix}address_state", required: required, wrapper_class: "col-sm-3" %>
|
||||
<%= form.text_field "#{field_name_prefix}address_zip", required: required, wrapper_class: "col-sm-3" %>
|
||||
</div>
|
||||
<%= form.form_group "#{field_name_prefix}address_country" do %>
|
||||
<%= form.label "#{field_name_prefix}address_country" %>
|
||||
|
||||
@@ -86,10 +86,32 @@ releases.each do |release|
|
||||
io: small_photo,
|
||||
filename: 'photo1.jpg'
|
||||
}]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if release[:type] == :location_release
|
||||
additional_params = {
|
||||
address_street1: 'Dummy St.',
|
||||
address_city: 'Dummy City',
|
||||
address_state: 'Dummy State',
|
||||
address_zip: '12121',
|
||||
address_country: 'US',
|
||||
person_email: 'mail@mail.com',
|
||||
person_company: 'Dummy Company Inc.',
|
||||
person_title: 'mr.',
|
||||
person_address_street1: 'Dummy St. 2',
|
||||
person_address_city: 'Dummy City 2',
|
||||
person_address_state: 'Dummy State 2',
|
||||
person_address_zip: '1111111',
|
||||
person_address_country: 'US',
|
||||
filming_ended_on: DateTime.now,
|
||||
filming_started_on: '01/02/20',
|
||||
filming_hours: '04-20'
|
||||
}
|
||||
|
||||
@parameters[release[:type]].merge!(additional_params)
|
||||
end
|
||||
|
||||
sign_in_to_api(current_user)
|
||||
end
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ describe Public::LocationReleasesController do
|
||||
it "logs analytics" do
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
expect {
|
||||
expect do
|
||||
post :create, params: { account_id: project.account.to_param, project_id: project, contract_template_id: contract_template, location_release: location_release_params }
|
||||
}.to(
|
||||
end.to(
|
||||
have_enqueued_job(TrackAnalyticsJob)
|
||||
.with(nil, nil, :track_create_native_release, release_type: "LocationRelease", account: project.account, user_agent: "Rails Testing", user_ip: "0.0.0.0")
|
||||
)
|
||||
@@ -31,28 +31,54 @@ describe Public::LocationReleasesController do
|
||||
contract_template = create(:contract_template, project: project)
|
||||
sign_in(user)
|
||||
|
||||
post :create, params: { account_id: user.primary_account.to_param, project_id: project, contract_template_id: contract_template, location_release: { person_address_city: "Albuquerque", filming_started_on: '02/02/02', filming_ended_on: '01/01/02' } }
|
||||
expect do
|
||||
post :create, params: {
|
||||
account_id: user.primary_account.to_param,
|
||||
project_id: project,
|
||||
contract_template_id: contract_template,
|
||||
location_release: attributes_for(:empty_location_release)
|
||||
}
|
||||
end.not_to change(LocationRelease, :count)
|
||||
|
||||
body = CGI.unescape_html(response.body)
|
||||
expect(body).to match /Name can't be blank/
|
||||
expect(body).to match />can't be blank</
|
||||
# expect(body).to match /must be after the filming started on date/
|
||||
expect(body).to match /Address street1 can't be blank/
|
||||
expect(body).to match /Address city can't be blank/
|
||||
expect(body).to match /Address state can't be blank/
|
||||
expect(body).to match /Address zip can't be blank/
|
||||
expect(body).to match /Address country can't be blank/
|
||||
expect(body).to match /Person first name can't be blank/
|
||||
expect(body).to match /Person last name can't be blank/
|
||||
expect(body).to match /Phone can't be blank/
|
||||
expect(body).to match /Email can't be blank/
|
||||
expect(body).to match /Company can't be blank/
|
||||
expect(body).to match /Title can't be blank/
|
||||
expect(body).to match /Person address street1 can't be blank/
|
||||
expect(body).to match /Person address city can't be blank/
|
||||
expect(body).to match /Person address state can't be blank/
|
||||
expect(body).to match /Person address zip can't be blank/
|
||||
expect(body).to match /Person address country can't be blank/
|
||||
expect(body).to match /Filming started on can't be blank/
|
||||
expect(body).to match /Filming ended on can't be blank/
|
||||
expect(body).to match /Filming hours can't be blank/
|
||||
expect(body).to match /Signature is not attached/
|
||||
end
|
||||
|
||||
it "renders a success page" do
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
post :create, params: { account_id: user.primary_account.to_param, project_id: project, contract_template_id: contract_template, location_release: location_release_params, filming_started_on: '01/02/20', filming_ended_on: '03/18/20' }
|
||||
|
||||
expect {
|
||||
post :create, params: { account_id: user.primary_account.to_param, project_id: project, contract_template_id: contract_template, location_release: location_release_params, filming_started_on: '01/02/20', filming_ended_on: '03/18/20' }
|
||||
}.to change(LocationRelease, :count).by(1)
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it "runs set tags for releasable job" do
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
expect {
|
||||
expect do
|
||||
post :create, params: { account_id: project.account.to_param, project_id: project, contract_template_id: contract_template, location_release: location_release_params }
|
||||
}.to(
|
||||
end.to(
|
||||
have_enqueued_job(SetTagsForReleasableJob)
|
||||
.with(LocationRelease.last)
|
||||
)
|
||||
@@ -61,9 +87,9 @@ describe Public::LocationReleasesController do
|
||||
it "runs attach contract to releasable job" do
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
expect {
|
||||
expect do
|
||||
post :create, params: { account_id: project.account.to_param, project_id: project, contract_template_id: contract_template, location_release: location_release_params }
|
||||
}.to(
|
||||
end.to(
|
||||
have_enqueued_job(AttachContractToReleasableJob)
|
||||
.with(LocationRelease.last)
|
||||
)
|
||||
@@ -73,11 +99,11 @@ describe Public::LocationReleasesController do
|
||||
private
|
||||
|
||||
def location_release_params
|
||||
attributes_for(:location_release, :native).except(:signature).merge(signature_param).merge(person_address_params)
|
||||
attributes_for(:location_release, :full_native).except(:signature).merge(signature_param).merge(person_address_params)
|
||||
end
|
||||
|
||||
def location_release_params_with_photos
|
||||
attributes_for(:location_release, :native, :with_photo).except(:signature).merge(signature_param)
|
||||
attributes_for(:location_release, :full_native, :with_photo).except(:signature).merge(signature_param)
|
||||
end
|
||||
|
||||
def person_address_params
|
||||
|
||||
@@ -29,6 +29,32 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
trait :full_native do
|
||||
address_street1 'Dummy St.'
|
||||
address_city 'Dummy City'
|
||||
address_state 'Dummy State'
|
||||
address_zip '12121'
|
||||
address_country 'US'
|
||||
person_first_name 'John'
|
||||
person_last_name 'Doe'
|
||||
person_phone '222223333'
|
||||
person_email 'mail@mail.com'
|
||||
person_company 'Dummy Company Inc.'
|
||||
person_title 'mr.'
|
||||
person_address_street1 'Dummy St. 2'
|
||||
person_address_city 'Dummy City 2'
|
||||
person_address_state 'Dummy State 2'
|
||||
person_address_zip '1111111'
|
||||
person_address_country 'US'
|
||||
filming_ended_on DateTime.now
|
||||
filming_started_on '01/02/20'
|
||||
filming_hours '04-20'
|
||||
end
|
||||
|
||||
factory :empty_location_release do
|
||||
name nil
|
||||
end
|
||||
|
||||
factory :location_release_with_contract_template do
|
||||
after(:build) do |location_release, _|
|
||||
location_release.contract_template = build(:location_release_contract_template)
|
||||
|
||||
@@ -17,20 +17,16 @@ feature "User managing location releases" do
|
||||
|
||||
visit new_account_project_contract_template_location_release_path(project.account, project, contract_template)
|
||||
|
||||
click_button submit_release_button
|
||||
expect(page).not_to have_content submitted_release_notice
|
||||
|
||||
by "filling out the form" do
|
||||
fill_in location_name_field, with: "Benny's Burritos"
|
||||
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_address_street1_field, with: "100 Broadway"
|
||||
fill_in filming_hours_field, with: "04:00 - 22:00"
|
||||
draw_signature file_fixture("signature.png"), "location_release_signature_base64"
|
||||
fill_all_form_fields
|
||||
end
|
||||
|
||||
click_button submit_release_button
|
||||
|
||||
expect(page).to have_content("Your release was successfully submitted. Thank you.")
|
||||
expect(page).to have_content submitted_release_notice
|
||||
end
|
||||
|
||||
scenario "creating a release with photos", js: true do
|
||||
@@ -38,15 +34,7 @@ feature "User managing location releases" do
|
||||
|
||||
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 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_address_street1_field, with: "100 Broadway"
|
||||
fill_in filming_hours_field, with: "04:00 - 22:00"
|
||||
draw_signature file_fixture("signature.png"), "location_release_signature_base64"
|
||||
|
||||
fill_all_form_fields
|
||||
drop_file Rails.root.join(file_fixture("location_photo.png")), type: :dropzone
|
||||
click_button submit_release_button
|
||||
|
||||
@@ -223,6 +211,29 @@ feature "User managing location releases" do
|
||||
|
||||
private
|
||||
|
||||
def fill_all_form_fields
|
||||
fill_in location_name_field, with: "Benny's Burritos"
|
||||
fill_in address_street1_field, with: "100 Broadway"
|
||||
fill_in address_city_field, with: "D"
|
||||
fill_in address_state_field, with: "CA"
|
||||
fill_in address_zip_field, with: "123"
|
||||
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: "Inc"
|
||||
fill_in person_title_field, with: "Mrs."
|
||||
fill_in person_address_street1_field, with: "100 Broadway"
|
||||
fill_in person_address_city_field, with: "D"
|
||||
fill_in person_address_state_field, with: "CA"
|
||||
fill_in person_address_zip_field, with: "123"
|
||||
fill_filming_started_on_field
|
||||
fill_filming_ended_on_field
|
||||
fill_in filming_hours_field, with: "04:00 - 22:00"
|
||||
|
||||
draw_signature file_fixture("signature.png"), "location_release_signature_base64"
|
||||
end
|
||||
|
||||
def country_field_value
|
||||
find_field("location_release[person_address_country]").value
|
||||
end
|
||||
@@ -251,14 +262,66 @@ feature "User managing location releases" do
|
||||
"location_release[person_email]"
|
||||
end
|
||||
|
||||
def person_company_field
|
||||
"location_release[person_company]"
|
||||
end
|
||||
|
||||
def person_title_field
|
||||
"location_release[person_title]"
|
||||
end
|
||||
|
||||
def address_street1_field
|
||||
"location_release[address_street1]"
|
||||
end
|
||||
|
||||
def address_city_field
|
||||
"location_release[address_city]"
|
||||
end
|
||||
|
||||
def address_state_field
|
||||
"location_release[address_state]"
|
||||
end
|
||||
|
||||
def address_zip_field
|
||||
"location_release[address_zip]"
|
||||
end
|
||||
|
||||
def address_country_field
|
||||
"location_release[address_country]"
|
||||
end
|
||||
|
||||
def person_address_street1_field
|
||||
"location_release[person_address_street1]"
|
||||
end
|
||||
|
||||
def person_address_city_field
|
||||
"location_release[person_address_city]"
|
||||
end
|
||||
|
||||
def person_address_state_field
|
||||
"location_release[person_address_state]"
|
||||
end
|
||||
|
||||
def person_address_zip_field
|
||||
"location_release[person_address_zip]"
|
||||
end
|
||||
|
||||
def person_address_country_field
|
||||
"location_release[person_address_country]"
|
||||
end
|
||||
|
||||
def person_phone_field
|
||||
"location_release[person_phone]"
|
||||
end
|
||||
|
||||
def fill_filming_started_on_field
|
||||
page.execute_script("$('#location_release_filming_started_on').val('01/03/20')")
|
||||
end
|
||||
|
||||
def fill_filming_ended_on_field
|
||||
page.execute_script("$('#location_release_filming_ended_on').val('03/03/20')")
|
||||
end
|
||||
|
||||
def filming_hours_field
|
||||
"location_release[filming_hours]"
|
||||
end
|
||||
@@ -291,6 +354,10 @@ feature "User managing location releases" do
|
||||
t("shared.submit_release_long")
|
||||
end
|
||||
|
||||
def submitted_release_notice
|
||||
"Your release was successfully submitted. Thank you."
|
||||
end
|
||||
|
||||
def create_release_notice
|
||||
t "location_releases.create.notice"
|
||||
end
|
||||
|
||||
@@ -13,7 +13,27 @@ RSpec.describe LocationRelease do
|
||||
end
|
||||
|
||||
describe "validations" do
|
||||
it { is_expected.to validate_presence_of(:name) }
|
||||
it { is_expected.to validate_presence_of(:name).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:address_street1).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:address_city).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:address_state).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:address_zip).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:address_country).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_first_name).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_last_name).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_phone).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_email).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_company).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_title).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_address_street1).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_address_city).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_address_state).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_address_zip).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:person_address_country).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:filming_ended_on).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:filming_started_on).on(:native) }
|
||||
it { is_expected.to validate_presence_of(:filming_hours).on(:native) }
|
||||
it { is_expected.to validate_attachment_of(:signature).on(:native) }
|
||||
it { is_expected.to allow_value("test@test.com", nil).for(:person_email) }
|
||||
it { is_expected.not_to allow_values("foo", "test@foo", "N/A").for(:person_email) }
|
||||
|
||||
|
||||
@@ -150,9 +150,49 @@ describe "IOS App Support API" do
|
||||
expect(response.body).to match /Person/
|
||||
end
|
||||
|
||||
it 'creates location release' do
|
||||
release = releases.third
|
||||
release_json = { "data" => {
|
||||
"type" => "location_release",
|
||||
"attributes" => {
|
||||
"name" => "Test Premises",
|
||||
"address_street1" => "Dummy St.",
|
||||
"address_city" => "Dummy City",
|
||||
"address_state" => "Dummy State",
|
||||
"address_zip" => "12121",
|
||||
"address_country" => "US",
|
||||
"person_first_name" => "John",
|
||||
"person_last_name" => "Doe",
|
||||
"person_phone" => "222223333",
|
||||
"person_email" => "mail@mail.com",
|
||||
"person_company" => "Dummy Company Inc.",
|
||||
"person_title" => "mr.",
|
||||
"person_address_street1" => "Dummy St. 2",
|
||||
"person_address_city" => "Dummy City 2",
|
||||
"person_address_state" => "Dummy State 2",
|
||||
"person_address_zip" => "1111111",
|
||||
"person_address_country" => "US",
|
||||
"filming_ended_on" => DateTime.now,
|
||||
"filming_started_on" => "01/02/20",
|
||||
"filming_hours" => "04-20",
|
||||
"signature" => "#{signature_base64}"
|
||||
}
|
||||
} }.to_json
|
||||
|
||||
post "/api/v1/contract_templates/#{template.id}/#{release[:type].to_s.pluralize}", params: release_json, headers: required_headers(current_user)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
|
||||
expect(response.status).to eq 201
|
||||
expect(json["data"]["attributes"].keys.length).to be > 1
|
||||
expect(response.body).to match /John/
|
||||
expect(response.body).to match /Doe/
|
||||
end
|
||||
|
||||
it 'creates talent, material and location releases' do
|
||||
releases.each do |release|
|
||||
next if release[:type] == :appearance_release
|
||||
next if release[:type] == :location_release
|
||||
|
||||
release_json = { "data" => {
|
||||
"type" => release[:type].to_s,
|
||||
|
||||
Reference in New Issue
Block a user