From 3e611094ab2ddb3cd8e056f69213ad3dde001c28 Mon Sep 17 00:00:00 2001 From: bilal Date: Fri, 12 Jun 2020 02:42:50 +0200 Subject: [PATCH] fix specs related to location release --- .../api/releases_controller_spec.rb | 24 ++++++++- .../user_managing_location_releases_spec.rb | 54 +++++++++---------- spec/requests/api_spec.rb | 40 ++++++++++++++ 3 files changed, 88 insertions(+), 30 deletions(-) diff --git a/spec/controllers/api/releases_controller_spec.rb b/spec/controllers/api/releases_controller_spec.rb index f72496b..48eafa0 100644 --- a/spec/controllers/api/releases_controller_spec.rb +++ b/spec/controllers/api/releases_controller_spec.rb @@ -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 diff --git a/spec/features/user_managing_location_releases_spec.rb b/spec/features/user_managing_location_releases_spec.rb index c570478..0db5fbf 100644 --- a/spec/features/user_managing_location_releases_spec.rb +++ b/spec/features/user_managing_location_releases_spec.rb @@ -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 diff --git a/spec/requests/api_spec.rb b/spec/requests/api_spec.rb index 0573da4..49b42c1 100644 --- a/spec/requests/api_spec.rb +++ b/spec/requests/api_spec.rb @@ -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,