File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ class ActiveRecord_Relation < ActiveRecord::Relation
4545 include ContributesToPatientTeams ::Relation
4646 end
4747
48+ UPLOAD_ONLY_YEAR_GROUPS = ( -2 ..13 ) . to_a . freeze
49+
4850 audited associated_with : :organisation
4951 has_associated_audits
5052
@@ -95,6 +97,8 @@ class ActiveRecord_Relation < ActiveRecord::Relation
9597 def to_param = workgroup
9698
9799 def year_groups ( academic_year : nil )
100+ return UPLOAD_ONLY_YEAR_GROUPS if has_upload_only_access?
101+
98102 academic_year ||= AcademicYear . pending
99103 location_programme_year_groups
100104 . joins ( :location_year_group )
Original file line number Diff line number Diff line change 6464
6565 it_behaves_like "a model with a normalised email address"
6666 it_behaves_like "a model with a normalised phone number"
67+
68+ describe "#year_groups" do
69+ context "when team has upload_only access" do
70+ let ( :team ) { create ( :team , type : :upload_only ) }
71+
72+ it "covers nursery to upper sixth" do
73+ expect ( team . year_groups ) . to eq ( ( -2 ..13 ) . to_a )
74+ end
75+
76+ it "ignores academic_year parameter" do
77+ expect ( team . year_groups ( academic_year : 2024 ) ) . to eq ( ( -2 ..13 ) . to_a )
78+ end
79+ end
80+ end
6781end
You can’t perform that action at this time.
0 commit comments