From e850dd89d5ff5d718b8c259bd46b691e671a8460 Mon Sep 17 00:00:00 2001 From: Eugenio Augusto Jimenes Date: Tue, 26 Mar 2024 20:03:03 -0300 Subject: [PATCH 1/4] feat(3067): add required info on csv partner export - Also includes the updates on partner model test --- app/models/partner.rb | 27 +++++++++++++++++++++++++++ spec/models/partner_spec.rb | 22 ++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/app/models/partner.rb b/app/models/partner.rb index 455428869c..6b14482a74 100644 --- a/app/models/partner.rb +++ b/app/models/partner.rb @@ -172,6 +172,12 @@ def self.csv_export_headers [ "Agency Name", "Agency Email", + "Agency address", + "Agency City", + "Agency State", + "Agency Zip Code", + "Agency Website", + "Agency Type", "Contact Name", "Contact Phone", "Contact Email", @@ -183,6 +189,12 @@ def csv_export_attributes [ name, email, + agency_info[:address], + agency_info[:city], + agency_info[:state], + agency_info[:zip_code], + agency_info[:website], + agency_info[:agency_type], contact_person[:name], contact_person[:phone], contact_person[:email], @@ -203,6 +215,21 @@ def contact_person } end + def agency_info + return @agency_info if @agency_info + + return {} if profile.blank? + + @agency_info = { + address: [profile.address1, profile.address2].reject(&:blank?).join(' '), + city: profile.city, + state: profile.state, + zip_code: profile.zip_code, + website: profile.website, + agency_type: profile.agency_type + } + end + def partials_to_show organization.partner_form_fields.presence || ALL_PARTIALS end diff --git a/spec/models/partner_spec.rb b/spec/models/partner_spec.rb index ab3e5bfc93..d86af80dee 100644 --- a/spec/models/partner_spec.rb +++ b/spec/models/partner_spec.rb @@ -291,21 +291,39 @@ let(:contact_name) { "Jon Ralfeo" } let(:contact_email) { "jon@entertainment720.com" } let(:contact_phone) { "1231231234" } + let(:agency_address) { "4744 McDermott Mountain" } + let(:agency_city) { "Lake Shoshana" } + let(:agency_state) { "ND" } + let(:agency_zipcode) { "09980-7010" } + let(:agency_website) { "bosco.example" } + let(:agency_type) { "HEALTH" } let(:notes) { "Some notes" } before do partner.profile.update({ primary_contact_name: contact_name, primary_contact_email: contact_email, - primary_contact_phone: contact_phone + primary_contact_phone: contact_phone, + address1: agency_address, + city: agency_city, + state: agency_state, + zip_code: agency_zipcode, + website: agency_website, + agency_type: agency_type, }) partner.update(notes: notes) end - it "includes contact person information from parnerbase" do + it "includes contact person and agency information from parnerbase" do expect(partner.csv_export_attributes).to include(contact_name) expect(partner.csv_export_attributes).to include(contact_phone) expect(partner.csv_export_attributes).to include(contact_email) + expect(partner.csv_export_attributes).to include(agency_address) + expect(partner.csv_export_attributes).to include(agency_city) + expect(partner.csv_export_attributes).to include(agency_state) + expect(partner.csv_export_attributes).to include(agency_zipcode) + expect(partner.csv_export_attributes).to include(agency_website) + expect(partner.csv_export_attributes).to include(agency_type) expect(partner.csv_export_attributes).to include(notes) end end From 41681ee5c99c5733b382dbaeb43369e66d4382e4 Mon Sep 17 00:00:00 2001 From: Eugenio Augusto Jimenes Date: Wed, 27 Mar 2024 16:05:21 -0300 Subject: [PATCH 2/4] fix(#3067): minor functionality quibbles --- app/models/partner.rb | 2 +- spec/models/partner_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/partner.rb b/app/models/partner.rb index 6b14482a74..fd31c9d55f 100644 --- a/app/models/partner.rb +++ b/app/models/partner.rb @@ -221,7 +221,7 @@ def agency_info return {} if profile.blank? @agency_info = { - address: [profile.address1, profile.address2].reject(&:blank?).join(' '), + address: [profile.address1, profile.address2].reject(&:blank?).join(', '), city: profile.city, state: profile.state, zip_code: profile.zip_code, diff --git a/spec/models/partner_spec.rb b/spec/models/partner_spec.rb index d86af80dee..26edb23f31 100644 --- a/spec/models/partner_spec.rb +++ b/spec/models/partner_spec.rb @@ -314,7 +314,7 @@ partner.update(notes: notes) end - it "includes contact person and agency information from parnerbase" do + it "includes contact person and agency information" do expect(partner.csv_export_attributes).to include(contact_name) expect(partner.csv_export_attributes).to include(contact_phone) expect(partner.csv_export_attributes).to include(contact_email) From b38becaa5b573968e3df36b62951776900c6431d Mon Sep 17 00:00:00 2001 From: Eugenio Augusto Jimenes Date: Wed, 27 Mar 2024 16:45:53 -0300 Subject: [PATCH 3/4] fix(3067): includes other_agency_type info --- app/models/partner.rb | 4 ++-- spec/models/partner_spec.rb | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/models/partner.rb b/app/models/partner.rb index fd31c9d55f..970f5e009c 100644 --- a/app/models/partner.rb +++ b/app/models/partner.rb @@ -172,7 +172,7 @@ def self.csv_export_headers [ "Agency Name", "Agency Email", - "Agency address", + "Agency Address", "Agency City", "Agency State", "Agency Zip Code", @@ -226,7 +226,7 @@ def agency_info state: profile.state, zip_code: profile.zip_code, website: profile.website, - agency_type: profile.agency_type + agency_type: (profile.agency_type == AGENCY_TYPES["OTHER"]) ? "#{AGENCY_TYPES["OTHER"]}: #{profile.other_agency_type}" : profile.agency_type } end diff --git a/spec/models/partner_spec.rb b/spec/models/partner_spec.rb index 26edb23f31..f6aea4514d 100644 --- a/spec/models/partner_spec.rb +++ b/spec/models/partner_spec.rb @@ -291,12 +291,14 @@ let(:contact_name) { "Jon Ralfeo" } let(:contact_email) { "jon@entertainment720.com" } let(:contact_phone) { "1231231234" } - let(:agency_address) { "4744 McDermott Mountain" } + let(:agency_address1) { "4744 McDermott Mountain" } + let(:agency_address2) { "333 Never land street" } let(:agency_city) { "Lake Shoshana" } let(:agency_state) { "ND" } let(:agency_zipcode) { "09980-7010" } let(:agency_website) { "bosco.example" } - let(:agency_type) { "HEALTH" } + let(:agency_type) { Partner::AGENCY_TYPES["OTHER"] } + let(:other_agency_type) { "Another Agency Name" } let(:notes) { "Some notes" } before do @@ -304,12 +306,14 @@ primary_contact_name: contact_name, primary_contact_email: contact_email, primary_contact_phone: contact_phone, - address1: agency_address, + address1: agency_address1, + address2: agency_address2, city: agency_city, state: agency_state, zip_code: agency_zipcode, website: agency_website, agency_type: agency_type, + other_agency_type: other_agency_type, }) partner.update(notes: notes) end @@ -318,12 +322,12 @@ expect(partner.csv_export_attributes).to include(contact_name) expect(partner.csv_export_attributes).to include(contact_phone) expect(partner.csv_export_attributes).to include(contact_email) - expect(partner.csv_export_attributes).to include(agency_address) + expect(partner.csv_export_attributes).to include("#{agency_address1}, #{agency_address2}") expect(partner.csv_export_attributes).to include(agency_city) expect(partner.csv_export_attributes).to include(agency_state) expect(partner.csv_export_attributes).to include(agency_zipcode) expect(partner.csv_export_attributes).to include(agency_website) - expect(partner.csv_export_attributes).to include(agency_type) + expect(partner.csv_export_attributes).to include("#{Partner::AGENCY_TYPES["OTHER"]}: #{other_agency_type}") expect(partner.csv_export_attributes).to include(notes) end end From 2e483ab8026cacde8c50fa648abbc3245ce40397 Mon Sep 17 00:00:00 2001 From: Eugenio Augusto Jimenes Date: Thu, 28 Mar 2024 11:20:13 -0300 Subject: [PATCH 4/4] fix(#3067): minor quibbles and test the the exact array of csv_export_attributes --- app/models/partner.rb | 2 +- spec/models/partner_spec.rb | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/models/partner.rb b/app/models/partner.rb index 970f5e009c..be47fe962a 100644 --- a/app/models/partner.rb +++ b/app/models/partner.rb @@ -221,7 +221,7 @@ def agency_info return {} if profile.blank? @agency_info = { - address: [profile.address1, profile.address2].reject(&:blank?).join(', '), + address: [profile.address1, profile.address2].select(&:present?).join(', '), city: profile.city, state: profile.state, zip_code: profile.zip_code, diff --git a/spec/models/partner_spec.rb b/spec/models/partner_spec.rb index f6aea4514d..c9ffc2b1fe 100644 --- a/spec/models/partner_spec.rb +++ b/spec/models/partner_spec.rb @@ -292,7 +292,7 @@ let(:contact_email) { "jon@entertainment720.com" } let(:contact_phone) { "1231231234" } let(:agency_address1) { "4744 McDermott Mountain" } - let(:agency_address2) { "333 Never land street" } + let(:agency_address2) { "333 Never land street" } let(:agency_city) { "Lake Shoshana" } let(:agency_state) { "ND" } let(:agency_zipcode) { "09980-7010" } @@ -313,22 +313,26 @@ zip_code: agency_zipcode, website: agency_website, agency_type: agency_type, - other_agency_type: other_agency_type, + other_agency_type: other_agency_type }) partner.update(notes: notes) end - it "includes contact person and agency information" do - expect(partner.csv_export_attributes).to include(contact_name) - expect(partner.csv_export_attributes).to include(contact_phone) - expect(partner.csv_export_attributes).to include(contact_email) - expect(partner.csv_export_attributes).to include("#{agency_address1}, #{agency_address2}") - expect(partner.csv_export_attributes).to include(agency_city) - expect(partner.csv_export_attributes).to include(agency_state) - expect(partner.csv_export_attributes).to include(agency_zipcode) - expect(partner.csv_export_attributes).to include(agency_website) - expect(partner.csv_export_attributes).to include("#{Partner::AGENCY_TYPES["OTHER"]}: #{other_agency_type}") - expect(partner.csv_export_attributes).to include(notes) + it "should has the info in the columns order" do + expect(partner.csv_export_attributes).to eq([ + partner.name, + partner.email, + "#{agency_address1}, #{agency_address2}", + agency_city, + agency_state, + agency_zipcode, + agency_website, + "#{Partner::AGENCY_TYPES["OTHER"]}: #{other_agency_type}", + contact_name, + contact_phone, + contact_email, + notes + ]) end end