-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor edit claim to wizard pattern #1212
base: jc/refactor_claims_to_wizard_pattern
Are you sure you want to change the base?
Refactor edit claim to wizard pattern #1212
Conversation
Deployments
|
@@ -22,7 +22,7 @@ def remaining_claimable_hours_condition(scope) | |||
end | |||
|
|||
def training_allowance_for(mentor) | |||
Claims::TrainingAllowance.new(mentor:, provider:, academic_year:) | |||
Claims::TrainingAllowance.new(mentor:, provider:, academic_year:, claim_to_exclude: claim) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What changed to require the addition of claim_to_exclude
here?
@@ -15,7 +15,8 @@ | |||
<% row.with_value(text: claim.provider.name) %> | |||
<% if policy(claim).edit? %> | |||
<% row.with_action(text: t("change"), | |||
href: create_revision_claims_support_school_claim_path(claim.school, claim), | |||
href: edit_attribute_path(:provider), | |||
visually_hidden_text: Claims::Claim.human_attribute_name(:accredited_provider), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice spot on the visually_hidden_text
arguments you've added ⭐
<% unless current_user.support_user? %> | ||
<% summary_list.with_row do |row| %> | ||
<% row.with_key(text: Claims::Claim.human_attribute_name(:school)) %> | ||
<% row.with_value(text: @wizard.school.name) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we consider delegation here to guard against nil
values? Granted this shouldn't happen but we've seen a lot of cases that shouldn't happen 😂
Likewise for the other chained methods in this file if you agree!
end | ||
|
||
def academic_year | ||
claim.claim_window.academic_year |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make use of the has_one :academic_year, through: :claim_window
association here?
claim.claim_window.academic_year | |
claim.academic_year |
Is this worth memoizing?
max_hours = Claims::TrainingAllowance.new( | ||
mentor: mentor_training.mentor, | ||
provider: mentor_training.provider, | ||
academic_year: claim.claim_window.academic_year, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this make use of the academic_year
method above?
@@ -70,7 +130,7 @@ def given_i_sign_in | |||
end | |||
|
|||
def given_there_is_a_current_claim_window | |||
Claims::ClaimWindow::Build.call(claim_window_params: { starts_on: 2.days.ago, ends_on: 2.days.from_now }).save!(validate: false) | |||
claim_window |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we use let!
to declare the claim_window
is this step necessary?
@@ -216,21 +197,25 @@ def when_i_add_training_hours(hours) | |||
end | |||
|
|||
def then_i_expect_the_training_hours_to_be_selected(hours) | |||
find("#claims-support-claim-mentor-training-form-hours-completed-#{hours}-field").checked? | |||
if hours.to_i == 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to convert this to an integer here or could we use string comparison?
expect(page).to have_content("Check your answers") | ||
|
||
within("dl.govuk-summary-list:nth(1)") do | ||
within(".govuk-summary-list__row:nth(1)") do | ||
expect(page).to have_content("Academic year") | ||
expect(page).to have_content(claim.academic_year_name) | ||
expect(page).to have_content(@claim_window.academic_year.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to a previous comment 😁
expect(page).to have_content(@claim_window.academic_year.name) | |
expect(page).to have_content(@claim_window.academic_year_name) |
given_i_sign_in | ||
when_i_select_a_school | ||
when_i_click_on_claims | ||
scenario "A support user I can edit a draft claim" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scenario "A support user I can edit a draft claim" do | |
scenario "As a support user I can edit a draft claim" do |
let(:school) { create(:claims_school) } | ||
let(:created_by) { create(:claims_user, schools: [school]) } | ||
let(:provider) { create(:claims_provider, :niot) } | ||
let(:mentor_1) { create(:claims_mentor, schools: [school], first_name: "Alan", last_name: "Anderson") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let(:school) { create(:claims_school) } | |
let(:created_by) { create(:claims_user, schools: [school]) } | |
let(:provider) { create(:claims_provider, :niot) } | |
let(:mentor_1) { create(:claims_mentor, schools: [school], first_name: "Alan", last_name: "Anderson") } | |
let(:school) { build(:claims_school) } | |
let(:created_by) { build(:claims_user, schools: [school]) } | |
let(:provider) { build(:claims_provider, :niot) } | |
let(:mentor_1) { build(:claims_mentor, schools: [school], first_name: "Alan", last_name: "Anderson") } |
Context
Changes proposed in this pull request
Guidance to review
Sign in as Anne (School user)
Sign in as Colin (Support user)
Link to Trello card
https://trello.com/c/dzMquW8D/934-refactor-the-edit-claim-form-to-use-the-wizard-pattern