|
27 | 27 | "CHILD_ADDRESS_LINE_2" => "",
|
28 | 28 | "CHILD_TOWN" => "London",
|
29 | 29 | "CHILD_POSTCODE" => "SW1A 1AA",
|
30 |
| - "CHILD_PREFERRED_GIVEN_NAME" => "Jim", |
| 30 | + "CHILD_PREFERRED_FIRST_NAME" => "Jim", |
31 | 31 | "CHILD_DATE_OF_BIRTH" => "2010-01-01",
|
32 | 32 | "CHILD_FIRST_NAME" => "Jimmy",
|
33 | 33 | "CHILD_GENDER" => "Male",
|
|
177 | 177 | )
|
178 | 178 | end
|
179 | 179 | end
|
| 180 | + |
| 181 | + context "when uploading different caps name" do |
| 182 | + let(:capitalised_parent_2_data) do |
| 183 | + { |
| 184 | + "PARENT_2_EMAIL" => "jenny@example.com", |
| 185 | + "PARENT_2_NAME" => "Jenny Smith" |
| 186 | + } |
| 187 | + end |
| 188 | + let(:data) { valid_data.merge(capitalised_parent_2_data) } |
| 189 | + |
| 190 | + let!(:existing_parent) do |
| 191 | + create(:parent, full_name: "JENNY SMITH", email: "jenny@example.com") |
| 192 | + end |
| 193 | + |
| 194 | + it { should eq([existing_parent]) } |
| 195 | + end |
180 | 196 | end
|
181 | 197 |
|
182 | 198 | describe "#to_patient" do
|
|
241 | 257 | family_name: "Smith",
|
242 | 258 | gender_code: "not_known",
|
243 | 259 | given_name: "Jimmy",
|
| 260 | + preferred_given_name: "Jim", |
244 | 261 | nhs_number: "9990000018",
|
245 | 262 | address_line_1: "10 Downing Street",
|
246 | 263 | address_line_2: "",
|
|
266 | 283 | let!(:existing_patient) do
|
267 | 284 | create(
|
268 | 285 | :patient,
|
| 286 | + address_line_1: "10 Downing Street", |
| 287 | + address_line_2: "", |
| 288 | + address_town: "London", |
269 | 289 | address_postcode: "SW1A 1AA",
|
| 290 | + given_name: "Jimmy", |
270 | 291 | family_name: "Smith",
|
| 292 | + preferred_given_name: "Jim", |
271 | 293 | gender_code: "female",
|
272 |
| - given_name: "Jimmy", |
273 | 294 | nhs_number: "9990000018",
|
274 |
| - address_line_1: "10 Downing Street", |
275 |
| - address_line_2: "", |
276 |
| - address_town: "London", |
277 | 295 | birth_academic_year: 2009,
|
278 | 296 | date_of_birth: Date.new(2010, 1, 1),
|
279 | 297 | registration: "8AB"
|
|
362 | 380 | )
|
363 | 381 | end
|
364 | 382 | end
|
| 383 | + |
| 384 | + context "with an existing patient with different capitalisation" do |
| 385 | + let(:data) do |
| 386 | + { |
| 387 | + "CHILD_ADDRESS_LINE_1" => "10 Downing Street", |
| 388 | + "CHILD_PREFERRED_FIRST_NAME" => "Jim", |
| 389 | + "CHILD_DATE_OF_BIRTH" => "2010-01-01", |
| 390 | + "CHILD_FIRST_NAME" => "Jimmy", |
| 391 | + "CHILD_GENDER" => "Male", |
| 392 | + "CHILD_LAST_NAME" => "Smith", |
| 393 | + "CHILD_PREFERRED_LAST_NAME" => "Smithy", |
| 394 | + "CHILD_NHS_NUMBER" => "9990000018", |
| 395 | + "CHILD_POSTCODE" => "sw1a 1aa", |
| 396 | + "CHILD_SCHOOL_URN" => school_urn, |
| 397 | + "CHILD_TOWN" => "London" |
| 398 | + } |
| 399 | + end |
| 400 | + |
| 401 | + let!(:existing_patient) do |
| 402 | + create( |
| 403 | + :patient, |
| 404 | + address_postcode: "SW1A 1AA", |
| 405 | + family_name: "SMITH", |
| 406 | + gender_code: "male", |
| 407 | + given_name: "JIMMY", |
| 408 | + nhs_number: "9990000018", |
| 409 | + address_line_1: "10 DOWNING STREET", |
| 410 | + preferred_given_name: "JIM", |
| 411 | + preferred_family_name: "SMITHY", |
| 412 | + date_of_birth: Date.new(2010, 1, 1), |
| 413 | + address_town: "LONDON" |
| 414 | + ) |
| 415 | + end |
| 416 | + |
| 417 | + it { should eq(existing_patient) } |
| 418 | + |
| 419 | + it "saves the incoming values" do |
| 420 | + expect(patient).to have_attributes( |
| 421 | + address_postcode: "SW1A 1AA", |
| 422 | + family_name: "Smith", |
| 423 | + gender_code: "male", |
| 424 | + given_name: "Jimmy", |
| 425 | + nhs_number: "9990000018", |
| 426 | + address_line_1: "10 Downing Street", |
| 427 | + preferred_given_name: "Jim", |
| 428 | + preferred_family_name: "Smithy", |
| 429 | + address_town: "London" |
| 430 | + ) |
| 431 | + end |
| 432 | + |
| 433 | + it "doesn't stage the capitalisation differences" do |
| 434 | + expect(patient.pending_changes).to be_empty |
| 435 | + end |
| 436 | + end |
365 | 437 | end
|
366 | 438 |
|
367 | 439 | describe "#to_school_move" do
|
|
0 commit comments