|
327 | 327 | end |
328 | 328 | end |
329 | 329 |
|
330 | | - context "with an existing patient already with an address" do |
| 330 | + context "with an existing patient already with an address (with a different postcode)" do |
331 | 331 | let(:data) do |
332 | 332 | valid_data.merge( |
333 | 333 | "CHILD_ADDRESS_LINE_1" => "10 Downing Street", |
|
373 | 373 | ) |
374 | 374 | end |
375 | 375 | end |
| 376 | + |
| 377 | + context "with an existing patient already with an address (with the same postcode)" do |
| 378 | + let(:data) do |
| 379 | + valid_data.merge( |
| 380 | + "CHILD_ADDRESS_LINE_1" => "10 Downing Street", |
| 381 | + "CHILD_ADDRESS_LINE_2" => "", |
| 382 | + "CHILD_TOWN" => "London", |
| 383 | + "CHILD_POSTCODE" => "SW1A 1AA" |
| 384 | + ) |
| 385 | + end |
| 386 | + |
| 387 | + let!(:existing_patient) do |
| 388 | + create( |
| 389 | + :patient, |
| 390 | + family_name: "Smith", |
| 391 | + gender_code: "male", |
| 392 | + given_name: "Jimmy", |
| 393 | + nhs_number: "9990000018", |
| 394 | + address_line_1: "20 Woodstock Road", |
| 395 | + address_line_2: "", |
| 396 | + address_town: "Oxford", |
| 397 | + address_postcode: "SW1A 1AA", |
| 398 | + birth_academic_year: 2009, |
| 399 | + date_of_birth: Date.new(2010, 1, 1), |
| 400 | + registration: "8AB" |
| 401 | + ) |
| 402 | + end |
| 403 | + |
| 404 | + it { should eq(existing_patient) } |
| 405 | + |
| 406 | + it "does save the incoming address" do |
| 407 | + expect(patient).to have_attributes( |
| 408 | + address_line_1: "10 Downing Street", |
| 409 | + address_line_2: "", |
| 410 | + address_town: "London", |
| 411 | + address_postcode: "SW1A 1AA" |
| 412 | + ) |
| 413 | + end |
| 414 | + |
| 415 | + it "doesn't stage the address differences" do |
| 416 | + expect(patient.pending_changes).to be_empty |
| 417 | + end |
| 418 | + end |
376 | 419 | end |
377 | 420 |
|
378 | 421 | describe "#to_parent_relationships" do |
|
0 commit comments