Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3067: add required info on csv partner export (partial solution) #4229

Merged
27 changes: 27 additions & 0 deletions app/models/partner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def self.csv_export_headers
[
"Agency Name",
"Agency Email",
"Agency address",
"Agency City",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor quibble: inconsistent capitalization -- please caplitalize address.

"Agency State",
"Agency Zip Code",
"Agency Website",
"Agency Type",
"Contact Name",
"Contact Phone",
"Contact Email",
Expand All @@ -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],
Expand All @@ -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,
dorner marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
22 changes: 20 additions & 2 deletions spec/models/partner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do a test with both address1 and address 2.

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
dorner marked this conversation as resolved.
Show resolved Hide resolved
end
Expand Down