Skip to content

Commit f4f36f1

Browse files
Merge pull request #5673 from nhsuk/mnr-upload-only-team-year-groups
Set` Team.year_groups` statically for upload-only teams
2 parents 974f91a + ce6f850 commit f4f36f1

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

app/models/team.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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)

spec/models/team_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,18 @@
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
6781
end

0 commit comments

Comments
 (0)