fix specs related to location release

This commit is contained in:
bilal
2020-06-12 02:42:50 +02:00
parent 021ac7ffc6
commit 3e611094ab
3 changed files with 88 additions and 30 deletions

View File

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

View File

@@ -21,26 +21,7 @@ feature "User managing location releases" do
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 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"
fill_all_form_fields
end
click_button submit_release_button
@@ -53,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
@@ -238,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

View File

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