<%= render Claims::Claim::MentorsForm::DisclaimerComponent.new(mentors_form: current_step) %>
diff --git a/app/views/wizards/claims/add_claim_wizard/_mentor_training_step.html.erb b/app/views/wizards/claims/add_claim_wizard/_mentor_training_step.html.erb
index 8f8cc0226..ca815bab0 100644
--- a/app/views/wizards/claims/add_claim_wizard/_mentor_training_step.html.erb
+++ b/app/views/wizards/claims/add_claim_wizard/_mentor_training_step.html.erb
@@ -1,3 +1,8 @@
+<% content_for :page_title, title_with_error_prefix(
+ t(".page_title", contextual_text:, provider_name: @wizard.provider.name, mentor: current_step.mentor.full_name),
+ error: current_step.errors.any?,
+) %>
+
<%= form_for(current_step, url: current_step_path, method: :put) do |f| %>
<%= f.govuk_error_summary %>
@@ -6,24 +11,25 @@
-
<%= render Claims::Claim::MentorTrainingForm::DisclaimerComponent.new(mentor_training_form: current_step) %>
<%= f.govuk_radio_buttons_fieldset(
- :hours_completed,
+ :hours_to_claim,
legend: {
size: "m",
text: t(".hours_of_training"),
},
) do %>
- <%= f.govuk_radio_button :hours_completed, current_step.max_hours, label: { text: t(".hours", count: current_step.max_hours) }, hint: { text: t(".hours_hint.#{current_step.max_hours == 20 ? "full" : "remaining"}", count: current_step.max_hours) } %>
+ <%= f.govuk_radio_button :hours_to_claim, "maximum", label: { text: t(".hours", count: current_step.max_hours) }, hint: { text: t(".hours_hint.#{current_step.max_hours == 20 ? "full" : "remaining"}", count: current_step.max_hours) } %>
<%= f.govuk_radio_divider %>
- <%= f.govuk_radio_button(:hours_completed, "custom", label: { text: t(".other_amount") }) do %>
+ <%= f.govuk_radio_button(:hours_to_claim, "custom", label: { text: t(".other_amount") }) do %>
<%= f.govuk_number_field(
- :custom_hours_completed,
+ :custom_hours,
class: "govuk-input--width-2",
+ min: 1,
+ max: current_step.max_hours,
label: { text: t(".number_of_hours"), class: "govuk-!-font-weight-bold" },
hint: { text: t(".custom_hours_completed_hint", count: current_step.max_hours) },
) %>
diff --git a/app/views/wizards/claims/add_claim_wizard/_no_mentors_step.html.erb b/app/views/wizards/claims/add_claim_wizard/_no_mentors_step.html.erb
index ce5c5c2ff..d525b1046 100644
--- a/app/views/wizards/claims/add_claim_wizard/_no_mentors_step.html.erb
+++ b/app/views/wizards/claims/add_claim_wizard/_no_mentors_step.html.erb
@@ -1,3 +1,8 @@
+<% content_for :page_title, title_with_error_prefix(
+ t(".page_title", contextual_text:, provider_name: @wizard.provider.name),
+ error: current_step.errors.any?,
+) %>
+
<%= t(".heading_empty", provider_name: @wizard.provider.name) %>
diff --git a/app/wizards/claims/add_claim_wizard.rb b/app/wizards/claims/add_claim_wizard.rb
index 6bc27bb20..1cfb5cb1e 100644
--- a/app/wizards/claims/add_claim_wizard.rb
+++ b/app/wizards/claims/add_claim_wizard.rb
@@ -33,7 +33,7 @@ def academic_year
end
def total_hours
- mentor_training_steps.values.map(&:total_hours_completed).sum
+ mentor_training_steps.map(&:hours_completed).sum
end
def claim
@@ -42,10 +42,10 @@ def claim
school:,
created_by:,
claim_window: Claims::ClaimWindow.current,
- mentor_trainings_attributes: mentor_training_steps.map do |_k, v|
+ mentor_trainings_attributes: mentor_training_steps.map do |mentor_training_step|
{
- mentor_id: v.mentor_id,
- hours_completed: v.total_hours_completed,
+ mentor_id: mentor_training_step.mentor_id,
+ hours_completed: mentor_training_step.hours_completed,
provider:,
}
end,
@@ -76,6 +76,10 @@ def provider
steps.fetch(:provider).provider
end
+ def step_name_for_mentor(mentor)
+ step_name(MentorTrainingStep, mentor.id)
+ end
+
private
def step_name(step_class, id = nil)
@@ -96,7 +100,7 @@ def step_attributes(name, step_class, preset_attributes = {})
end
def mentor_training_steps
- steps.select { |k, _v| k.to_s.include?("mentor_training_") }
+ steps.values.select { |step| step.is_a?(MentorTrainingStep) }
end
end
end
diff --git a/app/wizards/claims/add_claim_wizard/mentor_training_step.rb b/app/wizards/claims/add_claim_wizard/mentor_training_step.rb
index 73fd896cf..e1ac0bb8f 100644
--- a/app/wizards/claims/add_claim_wizard/mentor_training_step.rb
+++ b/app/wizards/claims/add_claim_wizard/mentor_training_step.rb
@@ -1,23 +1,15 @@
class Claims::AddClaimWizard::MentorTrainingStep < BaseStep
- attribute :hours_completed
attribute :mentor_id
- attribute :custom_hours_completed
+ attribute :hours_to_claim, :string
+ attribute :custom_hours
+
+ HOURS_TO_CLAIM = %w[maximum custom].freeze
validates :mentor_id, presence: true
- validates :hours_completed, presence: true
- validates(
- :hours_completed,
- presence: true,
- numericality: {
- only_integer: true,
- greater_than_or_equal_to: 1,
- less_than_or_equal_to: :max_hours,
- },
- unless: :custom_hours_selected?,
- )
+ validates :hours_to_claim, presence: true, inclusion: { in: HOURS_TO_CLAIM }
validates(
- :custom_hours_completed,
+ :custom_hours,
presence: true,
numericality: { only_integer: true },
between: { min: 1, max: :max_hours },
@@ -33,7 +25,7 @@ def initialize(wizard:, attributes:)
return if custom_hours_selected?
- self.custom_hours_completed = nil
+ self.custom_hours = nil
end
def mentor
@@ -52,13 +44,13 @@ def training_allowance
)
end
- def total_hours_completed
- (custom_hours_selected? ? custom_hours_completed : hours_completed).to_i
+ def hours_completed
+ (hours_to_claim == "maximum" ? max_hours : custom_hours).to_i
end
private
def custom_hours_selected?
- hours_completed == "custom"
+ hours_to_claim == "custom"
end
end
diff --git a/config/locales/en/activemodel.yml b/config/locales/en/activemodel.yml
index 2f475c7d3..99a2a70e6 100644
--- a/config/locales/en/activemodel.yml
+++ b/config/locales/en/activemodel.yml
@@ -147,14 +147,12 @@ en:
attributes:
mentor_id:
blank: Select a mentor
- custom_hours_completed:
+ custom_hours:
blank: Enter the number of hours
not_an_integer: Enter whole numbers only
between: Enter the number of hours between %{min} and %{max}
- hours_completed:
+ hours_to_claim:
blank: Select the number of hours
- not_an_integer: Enter whole numbers only
- between: Enter the number of hours between %{min} and %{max}
claims/add_claim_wizard/check_your_answers_step:
attributes:
base:
diff --git a/config/locales/en/wizards/claims/add_claim_wizard.yml b/config/locales/en/wizards/claims/add_claim_wizard.yml
index 9bb86bffe..633381858 100644
--- a/config/locales/en/wizards/claims/add_claim_wizard.yml
+++ b/config/locales/en/wizards/claims/add_claim_wizard.yml
@@ -7,11 +7,13 @@ en:
page_title: Accredited provider - %{contextual_text}
title: Accredited provider
mentor_step:
+ page_title: Mentors for %{provider_name} - %{contextual_text}
continue: Continue
label: Mentor
heading: Mentors for %{provider_name}
select_all_that_apply: Select all that apply
mentor_training_step:
+ page_title: Hours of training for %{mentor} - %{contextual_text} - %{provider_name}
hours_of_training_for_mentor: Hours of training for %{mentor}
hours_of_training: Hours of training
hours:
@@ -26,8 +28,8 @@ en:
other: Enter whole numbers up to a maximum of %{count} hours
number_of_hours: Number of hours
check_your_answers_step:
- page_title: Check your answers
- caption: Add claim
+ page_title: Check your answers - %{contextual_text}
+ title: Check your answers
warning: You will not be able to change any of the claim details once you have submitted it.
submit: Submit claim
declaration: Declaration
@@ -43,6 +45,7 @@ en:
hours_of_training: Hours of training
save: Save claim
no_mentors_step:
+ page_title: No mentors for %{provider_name} - %{contextual_text}
heading_empty: No mentors for %{provider_name}
no_mentors_with_claimable_hours: There are no mentors you can include in a claim because they have already had 20 hours of training claimed for with %{provider_name}.
change_provider: Change the accredited provider
diff --git a/config/routes/claims.rb b/config/routes/claims.rb
index 472790144..f0eaa401a 100644
--- a/config/routes/claims.rb
+++ b/config/routes/claims.rb
@@ -20,6 +20,7 @@
get "new", to: "claims/add_claim#new", as: :new_add_claim
get "new/:state_key/:step", to: "claims/add_claim#edit", as: :add_claim
put "new/:state_key/:step", to: "claims/add_claim#update"
+ get :rejected
end
resource :mentors, only: %i[new create edit update], module: :claims do
@@ -40,10 +41,6 @@
get :create_revision
post :submit
end
-
- collection do
- get :rejected
- end
end
resource :grant_conditions, only: %i[show update]
@@ -111,6 +108,7 @@
get "new", to: "claims/add_claim#new", as: :new_add_claim
get "new/:state_key/:step", to: "claims/add_claim#edit", as: :add_claim
put "new/:state_key/:step", to: "claims/add_claim#update"
+ get :rejected
end
resource :mentors, only: %i[new create edit update], module: :claims do
@@ -130,10 +128,6 @@
post :draft
get :create_revision
end
-
- collection do
- get :rejected
- end
end
resources :mentors, only: %i[index show destroy] do
diff --git a/spec/system/claims/schools/claims/create_claim_spec.rb b/spec/system/claims/schools/claims/create_claim_spec.rb
index 736f8562a..a9ba04472 100644
--- a/spec/system/claims/schools/claims/create_claim_spec.rb
+++ b/spec/system/claims/schools/claims/create_claim_spec.rb
@@ -309,9 +309,9 @@ def then_i_get_a_claim_reference_and_see_next_steps
expect(page).to have_content("We will process this claim at the end of September 2024 and all payments will be paid from December 2024.")
end
- def then_i_expect_the_training_hours_for(hours, mentor)
+ def then_i_expect_the_training_hours_for(_hours, mentor)
expect(page).to have_content("Hours of training for #{mentor.full_name}")
- find("#claims-add-claim-wizard-mentor-training-step-hours-completed-#{hours}-field").checked?
+ find("#claims-add-claim-wizard-mentor-training-step-hours-to-claim-maximum-field").checked?
end
def then_i_see_the_error(message)
diff --git a/spec/system/claims/support/schools/claims/create_claim_spec.rb b/spec/system/claims/support/schools/claims/create_claim_spec.rb
index 11e93df86..8d9165c62 100644
--- a/spec/system/claims/support/schools/claims/create_claim_spec.rb
+++ b/spec/system/claims/support/schools/claims/create_claim_spec.rb
@@ -246,9 +246,9 @@ def then_i_check_my_answers
end
end
- def then_i_expect_the_training_hours_for(hours, mentor)
+ def then_i_expect_the_training_hours_for(_hours, mentor)
expect(page).to have_content("Hours of training for #{mentor.full_name}")
- find("#claims-add-claim-wizard-mentor-training-step-hours-completed-#{hours}-field").checked?
+ find("#claims-add-claim-wizard-mentor-training-step-hours-to-claim-maximum-field").checked?
end
def then_i_am_redirectd_to_index_page(claim)
diff --git a/spec/wizards/claims/add_claim_wizard/mentor_training_step_spec.rb b/spec/wizards/claims/add_claim_wizard/mentor_training_step_spec.rb
index 4183e2b59..fbbfd0a58 100644
--- a/spec/wizards/claims/add_claim_wizard/mentor_training_step_spec.rb
+++ b/spec/wizards/claims/add_claim_wizard/mentor_training_step_spec.rb
@@ -29,18 +29,19 @@
let(:attributes) { nil }
describe "attributes" do
- it { is_expected.to have_attributes(mentor_id: nil, hours_completed: nil, custom_hours_completed: nil) }
+ it { is_expected.to have_attributes(mentor_id: nil, hours_to_claim: nil, custom_hours: nil) }
end
describe "validations" do
it { is_expected.to validate_presence_of(:mentor_id) }
- it { is_expected.to validate_presence_of(:hours_completed) }
+ it { is_expected.to validate_presence_of(:hours_to_claim) }
+ it { is_expected.to validate_inclusion_of(:hours_to_claim).in_array(described_class::HOURS_TO_CLAIM) }
context "when custom are selected" do
- let(:attributes) { { hours_completed: "custom", mentor_id: mentor.id } }
+ let(:attributes) { { hours_to_claim: "custom", mentor_id: mentor.id } }
it do
- expect(step).to validate_numericality_of(:custom_hours_completed)
+ expect(step).to validate_numericality_of(:custom_hours)
.only_integer
.is_greater_than_or_equal_to(1)
.is_less_than_or_equal_to(20)
@@ -49,17 +50,10 @@
end
context "when custom are not selected" do
- let(:attributes) { { hours_completed: 20, mentor_id: mentor.id } }
+ let(:attributes) { { hours_to_claim: "maximum", mentor_id: mentor.id } }
it { is_expected.to be_valid }
- it { is_expected.not_to validate_presence_of(:custom_hours_completed) }
-
- it do
- expect(step).to validate_numericality_of(:hours_completed)
- .only_integer
- .is_greater_than_or_equal_to(1)
- .is_less_than_or_equal_to(20)
- end
+ it { is_expected.not_to validate_presence_of(:custom_hours) }
end
describe "delegations" do
@@ -123,22 +117,22 @@
end
end
- describe "#total_hours_completed" do
- subject(:total_hours_completed) { step.total_hours_completed }
+ describe "#hours_completed" do
+ subject(:hours_completed) { step.hours_completed }
context "when custom hours completed is present" do
- let(:attributes) { { mentor_id: mentor.id, custom_hours_completed: 6, hours_completed: "custom" } }
+ let(:attributes) { { mentor_id: mentor.id, custom_hours: 6, hours_to_claim: "custom" } }
it "returns hours completed" do
- expect(total_hours_completed).to eq(6)
+ expect(hours_completed).to eq(6)
end
end
context "when custom hours completed is not present" do
- let(:attributes) { { mentor_id: mentor.id, hours_completed: 20, custom_hours_completed: 6 } }
+ let(:attributes) { { mentor_id: mentor.id, hours_to_claim: "maximum", custom_hours: 6 } }
it "returns hours completed" do
- expect(total_hours_completed).to eq(20)
+ expect(hours_completed).to eq(20)
end
end
end
diff --git a/spec/wizards/claims/add_claim_wizard_spec.rb b/spec/wizards/claims/add_claim_wizard_spec.rb
index 6bb7acad0..2e0abe874 100644
--- a/spec/wizards/claims/add_claim_wizard_spec.rb
+++ b/spec/wizards/claims/add_claim_wizard_spec.rb
@@ -27,30 +27,30 @@
end
context "when the school has mentors" do
- let(:mentor) { create(:claims_mentor, schools: [school]) }
-
- before { mentor }
+ let!(:mentor_1) { create(:claims_mentor, schools: [school], first_name: "Alan", last_name: "Anderson") }
context "with claimable hours" do
it { is_expected.to eq %i[provider mentor check_your_answers] }
end
context "when mentors have been selected" do
+ let!(:mentor_2) { create(:claims_mentor, schools: [school], first_name: "Bob", last_name: "Bletcher") }
+
let(:state) do
{
"provider" => { "id" => provider.id },
- "mentor" => { "mentor_ids" => [mentor.id] },
+ "mentor" => { "mentor_ids" => [mentor_1.id, mentor_2.id] },
}
end
- it { is_expected.to eq [:provider, :mentor, "mentor_training_#{mentor.id}".to_sym, :check_your_answers] }
+ it { is_expected.to eq [:provider, :mentor, "mentor_training_#{mentor_1.id}".to_sym, "mentor_training_#{mentor_2.id}".to_sym, :check_your_answers] }
end
context "with no claimable hours" do
before do
create(:mentor_training,
hours_completed: 20,
- mentor:,
+ mentor: mentor_1,
provider:,
date_completed: claim_window.starts_on + 1.day,
claim: create(:claim, :submitted, school:, provider:))
@@ -94,16 +94,16 @@
"provider" => { "id" => provider.id },
"mentor" => { "mentor_ids" => [mentor_1.id, mentor_2.id, mentor_3.id, mentor_4.id] },
"mentor_training_#{mentor_1.id}" => {
- "mentor_id" => mentor_1.id, "hours_completed" => 20
+ "mentor_id" => mentor_1.id, "hours_to_claim" => "maximum"
},
"mentor_training_#{mentor_2.id}" => {
- "mentor_id" => mentor_2.id, "hours_completed" => 20
+ "mentor_id" => mentor_2.id, "hours_to_claim" => "maximum"
},
"mentor_training_#{mentor_3.id}" => {
- "mentor_id" => mentor_3.id, "hours_completed" => "custom", "custom_hours_completed" => 16
+ "mentor_id" => mentor_3.id, "hours_to_claim" => "custom", "custom_hours" => 16
},
"mentor_training_#{mentor_4.id}" => {
- "mentor_id" => mentor_4.id, "hours_completed" => "custom", "custom_hours_completed" => 4
+ "mentor_id" => mentor_4.id, "hours_to_claim" => "custom", "custom_hours" => 4
},
}
end
@@ -121,10 +121,10 @@
"provider" => { "id" => provider.id },
"mentor" => { "mentor_ids" => [mentor_1.id, mentor_2.id] },
"mentor_training_#{mentor_1.id}" => {
- "mentor_id" => mentor_1.id, "hours_completed" => 20
+ "mentor_id" => mentor_1.id, "hours_to_claim" => "maximum"
},
"mentor_training_#{mentor_2.id}" => {
- "mentor_id" => mentor_2.id, "hours_completed" => "custom", "custom_hours_completed" => 16
+ "mentor_id" => mentor_2.id, "hours_to_claim" => "custom", "custom_hours" => 16
},
}
end
@@ -157,10 +157,10 @@
"provider" => { "id" => provider.id },
"mentor" => { "mentor_ids" => [mentor_1.id, mentor_2.id] },
"mentor_training_#{mentor_1.id}" => {
- "mentor_id" => mentor_1.id, "hours_completed" => 20
+ "mentor_id" => mentor_1.id, "hours_to_claim" => "maximum"
},
"mentor_training_#{mentor_2.id}" => {
- "mentor_id" => mentor_2.id, "hours_completed" => "custom", "custom_hours_completed" => 16
+ "mentor_id" => mentor_2.id, "hours_to_claim" => "custom", "custom_hours" => 16
},
}
end