|
25 | 25 | {
|
26 | 26 | "CHILD_ADDRESS_LINE_1" => "10 Downing Street",
|
27 | 27 | "CHILD_ADDRESS_LINE_2" => "",
|
28 |
| - "CHILD_PREFERRED_GIVEN_NAME" => "Jim", |
| 28 | + "CHILD_PREFERRED_FIRST_NAME" => "Jim", |
29 | 29 | "CHILD_DATE_OF_BIRTH" => "2010-01-01",
|
30 | 30 | "CHILD_FIRST_NAME" => "Jimmy",
|
31 | 31 | "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"
|
|
290 | 308 | expect(patient.pending_changes).to include("gender_code" => "male")
|
291 | 309 | end
|
292 | 310 | end
|
| 311 | + |
| 312 | + context "with an existing patient with different capitalisation" do |
| 313 | + let(:data) do |
| 314 | + { |
| 315 | + "CHILD_ADDRESS_LINE_1" => "10 Downing Street", |
| 316 | + "CHILD_PREFERRED_FIRST_NAME" => "Jim", |
| 317 | + "CHILD_DATE_OF_BIRTH" => "2010-01-01", |
| 318 | + "CHILD_FIRST_NAME" => "Jimmy", |
| 319 | + "CHILD_GENDER" => "Male", |
| 320 | + "CHILD_LAST_NAME" => "Smith", |
| 321 | + "CHILD_PREFERRED_LAST_NAME" => "Smithy", |
| 322 | + "CHILD_NHS_NUMBER" => "9990000018", |
| 323 | + "CHILD_POSTCODE" => "sw1a 1aa", |
| 324 | + "CHILD_SCHOOL_URN" => school_urn, |
| 325 | + "CHILD_TOWN" => "London" |
| 326 | + } |
| 327 | + end |
| 328 | + |
| 329 | + let!(:existing_patient) do |
| 330 | + create( |
| 331 | + :patient, |
| 332 | + address_postcode: "SW1A 1AA", |
| 333 | + family_name: "SMITH", |
| 334 | + gender_code: "male", |
| 335 | + given_name: "JIMMY", |
| 336 | + nhs_number: "9990000018", |
| 337 | + address_line_1: "10 DOWNING STREET", |
| 338 | + preferred_given_name: "JIM", |
| 339 | + preferred_family_name: "SMITHY", |
| 340 | + date_of_birth: Date.new(2010, 1, 1), |
| 341 | + address_town: "LONDON" |
| 342 | + ) |
| 343 | + end |
| 344 | + |
| 345 | + it { should eq(existing_patient) } |
| 346 | + |
| 347 | + it "saves the incoming values" do |
| 348 | + expect(patient).to have_attributes( |
| 349 | + address_postcode: "SW1A 1AA", |
| 350 | + family_name: "Smith", |
| 351 | + gender_code: "male", |
| 352 | + given_name: "Jimmy", |
| 353 | + nhs_number: "9990000018", |
| 354 | + address_line_1: "10 Downing Street", |
| 355 | + preferred_given_name: "Jim", |
| 356 | + preferred_family_name: "Smithy", |
| 357 | + address_town: "London" |
| 358 | + ) |
| 359 | + end |
| 360 | + |
| 361 | + it "doesn't stage the capitalisation differences" do |
| 362 | + expect(patient.pending_changes).to be_empty |
| 363 | + end |
| 364 | + end |
293 | 365 | end
|
294 | 366 |
|
295 | 367 | describe "#to_school_move" do
|
|
0 commit comments