Skip to content

Commit

Permalink
Merge pull request #1857 from DFE-Digital/select-assignees
Browse files Browse the repository at this point in the history
Only show assessors who are assigned to applications
  • Loading branch information
thomasleese authored Dec 8, 2023
2 parents 8054049 + 36f10ce commit 87bbe2b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def filter_form
end

def assessor_filter_options
Staff.assessors.order(:name) +
ApplicationForm
.active
.joins(:assessor)
.pluck(Arel.sql("DISTINCT ON(assessor_id) assessor_id"), "staff.name")
.sort_by { |_id, name| name }
.map { |id, name| OpenStruct.new(id:, name:) } +
[OpenStruct.new(id: "null", name: "Not assigned")]
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def when_i_clear_the_filters
end

def and_i_apply_the_assessor_filter
expect(assessor_applications_page.assessor_filter.assessors.count).to eq(4)
assessor_applications_page.assessor_filter.assessors.second.checkbox.click
expect(assessor_applications_page.assessor_filter.assessors.count).to eq(3)
assessor_applications_page.assessor_filter.assessors.first.checkbox.click
assessor_applications_page.apply_filters.click
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,23 @@
end

context "with an assessor user" do
let!(:staff) { create(:staff, :with_assess_permission) }
let!(:staff) { create(:staff) }

before { create(:application_form, :submitted, assessor: staff) }

it { is_expected.to include(staff) }
it do
is_expected.to include(OpenStruct.new(id: staff.id, name: staff.name))
end
end

context "with an non-assessor user" do
let!(:staff) { create(:staff) }

it { is_expected.not_to include(staff) }
it do
is_expected.to_not include(
OpenStruct.new(id: staff.id, name: staff.name),
)
end
end
end

Expand Down

0 comments on commit 87bbe2b

Please sign in to comment.