Skip to content

Commit 00ffdce

Browse files
authored
chore: Make tests faster (#5600)
**Story card:** [sc-15268](https://app.shortcut.com/simpledotorg/story/15268/versioning-adopt-semantic-versioning) ## Because CI takes 1 hour to build ## This addresses Optimizing matview refreshes during unit tests Ensure `refresh_views` can refresh specific views. Originally, this refreshed all the mat views which — for some tests — may be a recipe for wasting time. It's this query that's in focus for this change. There are other places where `refresh_views` is used, but those do not seem to run slow. ## Test instructions suite tests
1 parent 1adaf36 commit 00ffdce

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

spec/queries/patient_states/diabetes/bs_over200_patients_query_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
facility_2_bs_below_200_patients = create_list(:patient, 1, :bs_below_200, assigned_facility: regions[:facility_2])
1717
facility_2_bs_200_to_300_patients = create_list(:patient, 1, :bs_200_to_300, assigned_facility: regions[:facility_2])
1818
facility_2_bs_over_300_patients = create_list(:patient, 1, :bs_over_300, assigned_facility: regions[:facility_2])
19-
refresh_views
19+
refresh_views views: %w[
20+
Reports::Month
21+
Reports::Facility
22+
Reports::PatientBloodPressure
23+
Reports::PatientBloodSugar
24+
Reports::PatientVisit
25+
Reports::Prescriptions
26+
Reports::PatientState
27+
]
2028

2129
expect(PatientStates::Diabetes::BsOver200PatientsQuery.new(regions[:facility_1].region, period)
2230
.call

spec/rails_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def with_reporting_time_zone(&blk)
5353
end
5454
end
5555

56-
def refresh_views
57-
RefreshReportingViews.call
56+
def refresh_views(views: :all)
57+
RefreshReportingViews.call(views: views)
5858
end
5959

6060
config.before(:each) do

0 commit comments

Comments
 (0)