Skip to content

Commit 035f4be

Browse files
authored
Merge pull request #6404 from NHSDigital/fix-import-issues-badge-count
Clear stale import issue counts after `ProcessImportJob`
2 parents 4e58226 + 895b4f3 commit 035f4be

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

app/models/concerns/csv_importable.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ def process!
166166
return if invalid?
167167

168168
process_import!
169+
170+
TeamCachedCounts.new(team).reset_import_issues!
169171
end
170172

171173
def remove!

spec/support/shared_examples/a_csv_importable_model.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@
5757
).from(nil).to(today)
5858
end
5959
end
60+
61+
it "resets import issues in team cached counts" do
62+
team_cached_counts =
63+
instance_double(TeamCachedCounts, reset_import_issues!: true)
64+
65+
allow(TeamCachedCounts).to receive(:new).with(subject.team).and_return(
66+
team_cached_counts
67+
)
68+
69+
if subject.is_a?(ImmunisationImport)
70+
travel_to(today) { subject.process! }
71+
else
72+
subject.process!
73+
end
74+
75+
expect(TeamCachedCounts).to have_received(:new).with(subject.team)
76+
expect(team_cached_counts).to have_received(:reset_import_issues!)
77+
end
6078
end
6179

6280
describe "#remove!" do

0 commit comments

Comments
 (0)