Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SC-124 Add evaluators link and status change funtionality to tasklist #2009

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/controllers/support/cases/evaluators_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ class Cases::EvaluatorsController < Cases::ApplicationController
before_action :set_current_case
before_action :set_evaluator, only: %i[edit update destroy]

before_action only: %i[new create edit update destroy] do
@back_url = support_case_evaluators_path(@current_case)
end

before_action only: [:index] do
@back_url = support_case_path(@current_case, anchor: "tasklist")
end
def index
@evaluators = @current_case.evaluators.all
end
Expand Down
3 changes: 1 addition & 2 deletions app/models/support/evaluator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ module Support
class Evaluator < ApplicationRecord
belongs_to :support_case, class_name: "Support::Case"

include HasNormalizedEmail

validates :email,
presence: true,
format: { with: URI::MailTo::EMAIL_REGEXP },
serenaabbott11 marked this conversation as resolved.
Show resolved Hide resolved
uniqueness: { case_sensitive: false, scope: :support_case_id }
validates :first_name, :last_name, presence: true

Expand Down
2 changes: 1 addition & 1 deletion app/views/support/cases/show/_tasklist.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<%= I18n.t("support.case.label.tasklist.complete_evaluation") %>
</h3>
<%= govuk_task_list(id_prefix: "complete-evaluation") do |task_list|
task_list.with_item(title: I18n.t("support.case.label.tasklist.item.add_evaluators"), href: '#', status: govuk_tag(text: I18n.t("support.case.label.tasklist.status.to_do")))
task_list.with_item(title: I18n.t("support.case.label.tasklist.item.add_evaluators"), href: support_case_evaluators_path(@current_case), status: @current_case.evaluators.present? ? govuk_tag(text: I18n.t("support.case.label.tasklist.status.complete"), colour: "green") : govuk_tag(text: I18n.t("support.case.label.tasklist.status.to_do")))
threedaymonk marked this conversation as resolved.
Show resolved Hide resolved
task_list.with_item(title: I18n.t("support.case.label.tasklist.item.set_due_date"), href: edit_support_case_evaluation_due_dates_path(@current_case), status: @current_case.evaluation_due_date ? govuk_tag(text: I18n.t("support.case.label.tasklist.status.complete"), colour: "green") : govuk_tag(text: I18n.t("support.case.label.tasklist.status.to_do")))

if @current_case.has_uploaded_documents == true
Expand Down
12 changes: 10 additions & 2 deletions config/locales/validation/support/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ en:
attributes:
body:
blank: Please enter a case note
support/evaluator:
attributes:
email:
blank: Enter the email address of the evaluator
invalid: Enter an email address in the correct format, like [email protected]
taken: This email address has already been added as an evaluator
first_name:
blank: Enter the first name of the evaluator
last_name:
blank: Enter the last name of the evaluator

activemodel:
errors:
Expand Down Expand Up @@ -65,8 +75,6 @@ en:
blank: Select files to upload
has_uploaded_documents:
blank: Please confirm that you uploaded all documents



forms:
rules:
Expand Down
8 changes: 8 additions & 0 deletions spec/features/support/case_tasklist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
expect(page).to have_text("Procurement task list")
expect(page).to have_text("Complete evaluation")
expect(page).to have_css(".govuk-task-list")
expect(page).to have_link("Add evaluators")
end
end

it "navigates to the add evaluators page when clicked" do
within "#tasklist" do
click_link "Add evaluators"
expect(page).to have_current_path("/support/cases/#{support_case.id}/evaluators")
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions spec/models/support/evaluator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,19 @@
evaluator.support_case = case_b
expect(evaluator).to be_valid
end

it "doesn't allow invalid email formats" do
support_case = create(:support_case)
evaluator = build(:support_evaluator, support_case:)

evaluator.email = "test.example.com"
expect(evaluator).not_to be_valid

evaluator.email = "@example.com"
expect(evaluator).not_to be_valid

evaluator.email = "example"
expect(evaluator).not_to be_valid
end
end
end
Loading