generated from dxw/rails-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added evaluation due date update functionality
- Loading branch information
1 parent
7b3a466
commit 35012cf
Showing
10 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
app/controllers/support/cases/evaluation_due_dates_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Support | ||
class Cases::EvaluationDueDatesController < Cases::ApplicationController | ||
before_action :set_current_case | ||
before_action { @back_url = support_case_tasklist_path(params[:case_id]) } | ||
def edit | ||
@evaluation_due_date = @current_case | ||
end | ||
|
||
def update | ||
@evaluation_due_date = Support::Case.find(params[:case_id]) | ||
@evaluation_due_date.assign_attributes(evaluaton_due_date_params) | ||
|
||
if @evaluation_due_date.save(context: :update_due_date_form) | ||
redirect_to edit_support_case_evaluation_due_dates_path(case_id: @current_case) | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_current_case | ||
@current_case = Support::Case.find(params[:case_id]) | ||
end | ||
|
||
def evaluaton_due_date_params | ||
params.require(:support_case).permit(:evaluation_due_date) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/views/support/cases/evaluation_due_dates/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<%= render partial: "support/cases/components/case_header", locals: { current_case: @current_case } %> | ||
<h1 class="govuk-heading-l"><%= I18n.t("support.cases.evaluation_due_date.header") %></h1> | ||
|
||
<%= form_with model: @evaluation_due_date, url: support_case_evaluation_due_dates_path(@current_case), method: :patch do |form| %> | ||
<%= form.govuk_error_summary %> | ||
<%= form.govuk_date_field :evaluation_due_date, legend: { text: I18n.t("support.cases.evaluation_due_date.date.label"), }, hint: { text: I18n.t("support.cases.evaluation_due_date.date.hint") } %> | ||
|
||
<div class="govuk-button-group flex-align-center"> | ||
<%= form.submit I18n.t("support.cases.evaluation_due_date.submit"), class: "govuk-button" %> | ||
<%= link_to I18n.t("support.cases.evaluation_due_date.cancel"), @back_url, class: "govuk-link govuk-link--no-visited-state" %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
db/migrate/20241126122758_add_evaluation_due_date_to_support_cases.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddEvaluationDueDateToSupportCases < ActiveRecord::Migration[7.2] | ||
def change | ||
add_column :support_cases, :evaluation_due_date, :date | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
spec/features/support/agent_can_add_evaluation_due_date_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require "rails_helper" | ||
|
||
describe "Edit evaluation due date", :js do | ||
include_context "with an agent" | ||
|
||
let(:support_case) { create(:support_case) } | ||
|
||
specify "Update evaluation due date evaluators" do | ||
visit edit_support_case_evaluation_due_dates_path(case_id: support_case) | ||
|
||
expect(page).to have_text("Set due date") | ||
expect(page).to have_text("When does the evaluation need to be completed by?") | ||
|
||
fill_in "Day", with: "" | ||
fill_in "Month", with: "" | ||
fill_in "Year", with: "" | ||
click_button "Continue" | ||
|
||
expect(page).to have_text("Enter the evaluation due date") | ||
|
||
fill_in "Day", with: Date.yesterday.day | ||
fill_in "Month", with: Date.yesterday.month | ||
fill_in "Year", with: Date.yesterday.year | ||
click_button "Continue" | ||
|
||
expect(page).to have_text("Evaluation due date must be in the future") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters