|
1 | 1 | RSpec.describe "Partners", type: :request do |
2 | | - let(:organization) { create(:organization) } |
| 2 | + let(:organization) { create(:organization, partner_form_fields: ["media_information"]) } |
3 | 3 | let(:user) { create(:user, organization: organization) } |
4 | 4 |
|
5 | 5 | before do |
|
31 | 31 | let!(:profile) do |
32 | 32 | create(:partner_profile, |
33 | 33 | partner: partner, |
34 | | - primary_contact_name: contact_name, |
35 | | - primary_contact_email: contact_email, |
36 | | - primary_contact_phone: contact_phone, |
37 | 34 | address1: agency_address1, |
38 | 35 | address2: agency_address2, |
39 | 36 | city: agency_city, |
40 | 37 | state: agency_state, |
41 | 38 | zip_code: agency_zipcode, |
42 | 39 | website: agency_website, |
43 | 40 | agency_type: agency_type, |
44 | | - other_agency_type: other_agency_type) |
| 41 | + other_agency_type: other_agency_type, |
| 42 | + primary_contact_name: contact_name, |
| 43 | + primary_contact_phone: contact_phone, |
| 44 | + primary_contact_mobile: contact_mobile, |
| 45 | + primary_contact_email: contact_email, |
| 46 | + agency_mission: agency_mission, |
| 47 | + enable_child_based_requests: enable_child_based_requests, |
| 48 | + enable_individual_requests: enable_individual_requests, |
| 49 | + enable_quantity_based_requests: enable_quantity_based_requests, |
| 50 | + program_address1: program_address1, |
| 51 | + program_address2: program_address2, |
| 52 | + program_city: program_city, |
| 53 | + program_state: program_state, |
| 54 | + program_zip_code: program_zip_code, |
| 55 | + facebook: facebook, # Columns from the media_information partial |
| 56 | + twitter: twitter, |
| 57 | + instagram: instagram, |
| 58 | + no_social_media_presence: no_social_media_presence) |
45 | 59 | end |
46 | 60 | let(:name) { "Leslie Sue" } |
47 | 61 | let(:email) { "leslie@sue.com" } |
48 | | - let(:contact_name) { "Jon Ralfeo" } |
49 | | - let(:contact_email) { "jon@entertainment720.com" } |
50 | | - let(:contact_phone) { "1231231234" } |
51 | 62 | let(:agency_address1) { "4744 McDermott Mountain" } |
52 | 63 | let(:agency_address2) { "333 Never land street" } |
53 | 64 | let(:agency_city) { "Lake Shoshana" } |
54 | 65 | let(:agency_state) { "ND" } |
55 | 66 | let(:agency_zipcode) { "09980-7010" } |
56 | 67 | let(:agency_website) { "bosco.example" } |
57 | 68 | let(:agency_type) { :other } |
58 | | - let(:notes) { "Some notes" } |
59 | 69 | let(:other_agency_type) { "Another Agency Name" } |
60 | | - let(:providing_diapers) { {value: "N", index: 13} } |
61 | | - let(:providing_period_supplies) { {value: "N", index: 14} } |
62 | | - |
63 | | - let(:response_format) { 'csv' } |
64 | | - let(:expected_headers) do |
| 70 | + let(:contact_name) { "Jon Ralfeo" } |
| 71 | + let(:contact_phone) { "1231231234" } |
| 72 | + let(:contact_mobile) { "4564564567" } |
| 73 | + let(:contact_email) { "jon@entertainment720.com" } |
| 74 | + let(:notes) { "Some notes" } |
| 75 | + let(:providing_diapers) { {value: "N", index: 22} } |
| 76 | + let(:providing_period_supplies) { {value: "N", index: 23} } |
| 77 | + let(:agency_mission) { "agency_mission" } |
| 78 | + let(:enable_child_based_requests) { true } |
| 79 | + let(:enable_individual_requests) { true } |
| 80 | + let(:enable_quantity_based_requests) { true } |
| 81 | + let(:program_address1) { "program_address1" } |
| 82 | + let(:program_address2) { "program_address2" } |
| 83 | + let(:program_city) { "program_city" } |
| 84 | + let(:program_state) { "program_state" } |
| 85 | + let(:program_zip_code) { 12345 } |
| 86 | + let(:facebook) { "facebook" } # Columns from the media_information partial |
| 87 | + let(:twitter) { "twitter" } |
| 88 | + let(:instagram) { "instagram" } |
| 89 | + let(:no_social_media_presence) { false } |
| 90 | + |
| 91 | + let(:expected_headers) { |
65 | 92 | [ |
66 | 93 | "Agency Name", |
67 | 94 | "Agency Email", |
|
73 | 100 | "Agency Type", |
74 | 101 | "Contact Name", |
75 | 102 | "Contact Phone", |
| 103 | + "Contact Cell", |
76 | 104 | "Contact Email", |
| 105 | + "Agency Mission", |
| 106 | + "Child-based Requests", |
| 107 | + "Individual Requests", |
| 108 | + "Quantity-based Requests", |
| 109 | + "Program/Delivery Address", |
| 110 | + "Program City", |
| 111 | + "Program State", |
| 112 | + "Program Zip Code", |
77 | 113 | "Notes", |
78 | 114 | "Counties Served", |
79 | 115 | "Providing Diapers", |
80 | | - "Providing Period Supplies" |
81 | | - ] |
82 | | - end |
| 116 | + "Providing Period Supplies", |
| 117 | + "Facebook", # Columns from the media_information partial |
| 118 | + "Twitter", |
| 119 | + "Instagram", |
| 120 | + "No Social Media Presence" |
| 121 | + ] |
| 122 | + } |
| 123 | + |
| 124 | + let(:expected_values) { |
| 125 | + [ |
| 126 | + partner.name, |
| 127 | + partner.email, |
| 128 | + "#{agency_address1}, #{agency_address2}", |
| 129 | + agency_city, |
| 130 | + agency_state, |
| 131 | + agency_zipcode, |
| 132 | + agency_website, |
| 133 | + "#{I18n.t "partners_profile.other"}: #{other_agency_type}", |
| 134 | + contact_name, |
| 135 | + contact_phone, |
| 136 | + contact_mobile, |
| 137 | + contact_email, |
| 138 | + agency_mission, |
| 139 | + enable_child_based_requests.to_s, |
| 140 | + enable_individual_requests.to_s, |
| 141 | + enable_quantity_based_requests.to_s, |
| 142 | + "#{program_address1}, #{program_address2}", |
| 143 | + program_city, |
| 144 | + program_state, |
| 145 | + program_zip_code.to_s, |
| 146 | + notes, |
| 147 | + "", # no counties |
| 148 | + providing_diapers[:value], |
| 149 | + providing_period_supplies[:value], |
| 150 | + facebook, # Columns from the media_information partial |
| 151 | + twitter, |
| 152 | + instagram, |
| 153 | + no_social_media_presence.to_s |
| 154 | + ] |
| 155 | + } |
83 | 156 |
|
84 | 157 | it { is_expected.to be_successful } |
85 | 158 | it "returns the expected headers" do |
|
91 | 164 | end |
92 | 165 |
|
93 | 166 | context "with missing partner info" do |
94 | | - let(:name) { "Leslie" } |
95 | | - let(:email) { "leslie@humanessentials.com" } |
96 | | - let(:contact_name) { nil } |
97 | | - let(:contact_email) { nil } |
98 | | - let(:contact_phone) { nil } |
99 | | - let(:agency_address1) { nil } |
100 | | - let(:agency_address2) { nil } |
101 | | - let(:agency_city) { nil } |
102 | | - let(:agency_state) { nil } |
103 | | - let(:agency_zipcode) { nil } |
104 | | - let(:agency_website) { nil } |
105 | | - let(:agency_type) { nil } |
106 | | - let(:notes) { nil } |
107 | | - let(:other_agency_type) { nil } |
108 | | - |
109 | 167 | it "returns a CSV with correct data" do |
110 | | - get partners_path(partner, format: response_format) |
| 168 | + partner.update(profile: create( |
| 169 | + :partner_profile, |
| 170 | + website: nil, |
| 171 | + primary_contact_name: nil, |
| 172 | + primary_contact_email: nil |
| 173 | + )) |
| 174 | + |
| 175 | + expected_values = [ |
| 176 | + partner.name, |
| 177 | + partner.email, |
| 178 | + ", ", |
| 179 | + "", |
| 180 | + "", |
| 181 | + "", |
| 182 | + "", |
| 183 | + "", |
| 184 | + "", |
| 185 | + "", |
| 186 | + "", |
| 187 | + "", |
| 188 | + "", |
| 189 | + enable_child_based_requests.to_s, |
| 190 | + enable_individual_requests.to_s, |
| 191 | + enable_quantity_based_requests.to_s, |
| 192 | + ", ", |
| 193 | + "", |
| 194 | + "", |
| 195 | + "", |
| 196 | + notes, |
| 197 | + "", |
| 198 | + providing_diapers[:value], |
| 199 | + providing_period_supplies[:value], |
| 200 | + "", # Columns from the media_information partial |
| 201 | + "", |
| 202 | + "", |
| 203 | + "" |
| 204 | + ] |
111 | 205 |
|
| 206 | + get partners_path(partner, format: response_format) |
112 | 207 | csv = CSV.parse(response.body) |
113 | | - |
114 | | - expect(csv[1]).to eq( |
115 | | - ["Leslie", "leslie@humanessentials.com", "", "", "", "", "", "", "", "", "", "", "", "N", "N"] |
116 | | - ) |
| 208 | + expect(csv[1]).to eq(expected_values) |
117 | 209 | end |
118 | 210 | end |
119 | 211 |
|
|
122 | 214 |
|
123 | 215 | csv = CSV.parse(response.body) |
124 | 216 |
|
125 | | - expect(csv[1]).to eq( |
126 | | - [ |
127 | | - "Leslie Sue", |
128 | | - "leslie@sue.com", |
129 | | - "4744 McDermott Mountain, 333 Never land street", |
130 | | - "Lake Shoshana", |
131 | | - "ND", |
132 | | - "09980-7010", |
133 | | - "bosco.example", |
134 | | - "Other: Another Agency Name", |
135 | | - "Jon Ralfeo", |
136 | | - "1231231234", |
137 | | - "jon@entertainment720.com", |
138 | | - "Some notes", |
139 | | - "", |
140 | | - "N", |
141 | | - "N" |
142 | | - ] |
143 | | - ) |
| 217 | + expect(csv[1]).to eq(expected_values) |
144 | 218 | end |
145 | 219 |
|
146 | 220 | it "returns only active partners by default" do |
147 | 221 | partner.update(status: :deactivated) |
148 | 222 |
|
149 | 223 | get partners_path(partner, format: response_format) |
150 | | - |
151 | 224 | csv = CSV.parse(response.body) |
152 | | - |
153 | 225 | # Expect no parner rows in csv |
| 226 | + expect(csv[0]).to eq(expected_headers) |
154 | 227 | expect(csv[1]).to eq(nil) |
155 | 228 | end |
156 | 229 |
|
|
178 | 251 | let!(:profile_2) do |
179 | 252 | create(:partner_profile, |
180 | 253 | partner: partner_2, |
181 | | - primary_contact_name: contact_name_2, |
182 | | - primary_contact_email: contact_email_2, |
183 | | - primary_contact_phone: contact_phone_2, |
184 | 254 | address1: agency_address1_2, |
185 | 255 | address2: agency_address2_2, |
186 | 256 | city: agency_city_2, |
187 | 257 | state: agency_state_2, |
188 | 258 | zip_code: agency_zipcode_2, |
189 | 259 | website: agency_website_2, |
190 | 260 | agency_type: agency_type_2, |
191 | | - other_agency_type: other_agency_type_2) |
| 261 | + other_agency_type: other_agency_type_2, |
| 262 | + primary_contact_name: contact_name_2, |
| 263 | + primary_contact_phone: contact_phone_2, |
| 264 | + primary_contact_mobile: contact_mobile_2, |
| 265 | + primary_contact_email: contact_email_2, |
| 266 | + agency_mission: agency_mission_2, |
| 267 | + enable_child_based_requests: enable_child_based_requests_2, |
| 268 | + enable_individual_requests: enable_individual_requests_2, |
| 269 | + enable_quantity_based_requests: enable_quantity_based_requests_2, |
| 270 | + program_address1: program_address1_2, |
| 271 | + program_address2: program_address2_2, |
| 272 | + program_city: program_city_2, |
| 273 | + program_state: program_state_2, |
| 274 | + program_zip_code: program_zip_code_2, |
| 275 | + facebook: facebook_2, # Columns from the media_information partial |
| 276 | + twitter: twitter_2, |
| 277 | + instagram: instagram_2, |
| 278 | + no_social_media_presence: no_social_media_presence_2) |
192 | 279 | end |
193 | 280 |
|
194 | 281 | let(:name_2) { "Jane Doe" } |
195 | 282 | let(:email_2) { "jane@doe.com" } |
196 | | - let(:contact_name_2) { "Fakey McFakePerson" } |
197 | | - let(:contact_email_2) { "fakey@gmail.com" } |
198 | | - let(:contact_phone_2) { "1234567890" } |
199 | 283 | let(:agency_address1_2) { "123 Main St" } |
200 | 284 | let(:agency_address2_2) { "C.O. box 678" } |
201 | 285 | let(:agency_city_2) { "Paris" } |
202 | 286 | let(:agency_state_2) { "TX" } |
203 | 287 | let(:agency_zipcode_2) { "30234-0000" } |
204 | 288 | let(:agency_website_2) { "human.example" } |
205 | 289 | let(:agency_type_2) { :other } |
| 290 | + let(:other_agency_type_2) { "Another Agency Name" } |
| 291 | + let(:contact_name_2) { "Fakey McFakePerson" } |
| 292 | + let(:contact_phone_2) { "1234567890" } |
| 293 | + let(:contact_mobile_2) { "1234567890" } |
| 294 | + let(:contact_email_2) { "fakey@gmail.com" } |
206 | 295 | let(:notes_2) { "Some notes 2" } |
207 | | - let(:other_agency_type_2) { "Fake Agency Name" } |
208 | | - let(:providing_diapers_2) { {value: "N", index: 13} } |
209 | | - let(:providing_period_supplies_2) { {value: "N", index: 14} } |
| 296 | + let(:providing_diapers_2) { {value: "N", index: 22} } |
| 297 | + let(:providing_period_supplies_2) { {value: "N", index: 23} } |
| 298 | + let(:agency_mission_2) { "agency_mission" } |
| 299 | + let(:enable_child_based_requests_2) { true } |
| 300 | + let(:enable_individual_requests_2) { true } |
| 301 | + let(:enable_quantity_based_requests_2) { true } |
| 302 | + let(:program_address1_2) { "program_address1" } |
| 303 | + let(:program_address2_2) { "program_address2" } |
| 304 | + let(:program_city_2) { "program_city" } |
| 305 | + let(:program_state_2) { "program_state" } |
| 306 | + let(:program_zip_code_2) { 12345 } |
| 307 | + let(:facebook_2) { "facebook" } # Columns from the media_information partial |
| 308 | + let(:twitter_2) { "twitter" } |
| 309 | + let(:instagram_2) { "instagram" } |
| 310 | + let(:no_social_media_presence_2) { false } |
210 | 311 |
|
211 | 312 | it "orders partners alphaetically" do |
212 | 313 | get partners_path(partner, format: response_format) |
|
215 | 316 |
|
216 | 317 | expect(csv[1]).to eq( |
217 | 318 | [ |
218 | | - "Jane Doe", |
219 | | - "jane@doe.com", |
220 | | - "123 Main St, C.O. box 678", |
221 | | - "Paris", |
222 | | - "TX", |
223 | | - "30234-0000", |
224 | | - "human.example", |
225 | | - "Other: Fake Agency Name", |
226 | | - "Fakey McFakePerson", |
227 | | - "1234567890", |
228 | | - "fakey@gmail.com", |
229 | | - "Some notes 2", |
230 | | - "", |
231 | | - "N", |
232 | | - "N" |
| 319 | + partner_2.name, |
| 320 | + partner_2.email, |
| 321 | + "#{agency_address1_2}, #{agency_address2_2}", |
| 322 | + agency_city_2, |
| 323 | + agency_state_2, |
| 324 | + agency_zipcode_2, |
| 325 | + agency_website_2, |
| 326 | + "#{I18n.t "partners_profile.other"}: #{other_agency_type_2}", |
| 327 | + contact_name_2, |
| 328 | + contact_phone_2, |
| 329 | + contact_mobile_2, |
| 330 | + contact_email_2, |
| 331 | + agency_mission_2, |
| 332 | + enable_child_based_requests_2.to_s, |
| 333 | + enable_individual_requests_2.to_s, |
| 334 | + enable_quantity_based_requests_2.to_s, |
| 335 | + "#{program_address1_2}, #{program_address2_2}", |
| 336 | + program_city_2, |
| 337 | + program_state_2, |
| 338 | + program_zip_code_2.to_s, |
| 339 | + notes_2, |
| 340 | + "", # no counties |
| 341 | + providing_diapers_2[:value], |
| 342 | + providing_period_supplies_2[:value], |
| 343 | + facebook_2, # Columns from the media_information partial |
| 344 | + twitter_2, |
| 345 | + instagram_2, |
| 346 | + no_social_media_presence_2.to_s |
233 | 347 | ] |
234 | 348 | ) |
235 | 349 | end |
|
0 commit comments