Skip to content

Commit 904ece6

Browse files
committed
Correction to totals on import review page
This was using the count of records displayed rather than the total count. Jira-Issue: MAV-5724
1 parent 280d3fe commit 904ece6

2 files changed

Lines changed: 64 additions & 2 deletions

File tree

app/components/app_import_review_component.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def auto_matched_message
4646
end
4747

4848
def import_issues_message
49-
count = @import_issues.count
49+
count = @import_issues_pagy.count
5050
"This upload includes #{pluralize(count, "record")} that " \
5151
"#{count > 1 ? "are close matches to existing records" : "is a close match to an existing record"} " \
5252
"in Mavis. If you approve the upload, you will need to resolve " \
@@ -62,7 +62,7 @@ def inter_team_message
6262
end
6363

6464
def school_moves_message
65-
count = @school_moves.count
65+
count = @school_moves_pagy.count
6666
if @import.is_a?(ClassImport)
6767
"This upload will change the school of the #{count > 1 ? "children" : "child"} listed below. " \
6868
"Children present in the class list will be moved into the school, and those who are not in the " \

spec/components/app_import_review_component_spec.rb

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,35 @@
105105
end
106106
end
107107

108+
describe "with multiple pages of new records" do
109+
let(:new_records) do
110+
create_list(:patient_changeset, 75, :new_patient, import:)
111+
end
112+
let(:new_records_pagy) do
113+
instance_double(
114+
Pagy,
115+
count: new_records.count,
116+
limit: 50,
117+
from: 1,
118+
to: 50
119+
).as_null_object
120+
end
121+
122+
include_examples "section with details",
123+
title: "New records",
124+
summary: /75 new records\s+\(showing 1 to 50\)/,
125+
count: 75
126+
127+
it "shows the section description" do
128+
expect(rendered).to have_content(
129+
"This upload includes 75 new records that are not currently in Mavis"
130+
)
131+
expect(rendered).to have_content(
132+
"If you approve the upload, these records will be added to Mavis"
133+
)
134+
end
135+
end
136+
108137
describe "with auto-matched records" do
109138
let(:auto_matched_records) do
110139
[
@@ -263,6 +292,39 @@
263292
end
264293
end
265294

295+
describe "with multiple pages of school moves" do
296+
let(:school_moves) do
297+
create_list(
298+
:patient_changeset,
299+
55,
300+
:with_school_move,
301+
import:,
302+
patient: school_move_patient,
303+
school: second_location
304+
)
305+
end
306+
let(:school_moves_pagy) do
307+
instance_double(
308+
Pagy,
309+
count: school_moves.count,
310+
limit: 50,
311+
from: 1,
312+
to: 50
313+
).as_null_object
314+
end
315+
316+
include_examples "section with details",
317+
title: "School moves - resolve after import",
318+
summary: /55 school moves\s+\(showing 1 to 50\)/,
319+
count: 55
320+
321+
it "shows correct total in import message" do
322+
expect(rendered).to have_content(
323+
"This upload includes 55 children with a different school to the one on their Mavis record"
324+
)
325+
end
326+
end
327+
266328
describe "with skipped school moves" do
267329
let(:other_team_school) do
268330
create(:school, team: other_team, name: "School in Other Team")

0 commit comments

Comments
 (0)