-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The contract details page in IRP write to the `one_year` attribute, so that's what we've done too.
- Loading branch information
Showing
19 changed files
with
194 additions
and
10 deletions.
There are no files selected for viewing
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
25 changes: 25 additions & 0 deletions
25
app/forms/journeys/get_a_teacher_relocation_payment/contract_details_form.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,25 @@ | ||
module Journeys | ||
module GetATeacherRelocationPayment | ||
class ContractDetailsForm < Form | ||
attribute :one_year, :boolean | ||
|
||
validates :one_year, | ||
inclusion: { | ||
in: [true, false], | ||
message: i18n_error_message(:inclusion) | ||
} | ||
|
||
def available_options | ||
[true, false] | ||
end | ||
|
||
def save | ||
return false unless valid? | ||
|
||
journey_session.answers.assign_attributes(one_year: one_year) | ||
|
||
journey_session.save! | ||
end | ||
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
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
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
34 changes: 34 additions & 0 deletions
34
app/views/get_a_teacher_relocation_payment/claims/contract_details.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,34 @@ | ||
<% content_for( | ||
:page_title, | ||
page_title( | ||
t("get_a_teacher_relocation_payment.forms.contract_details.question"), | ||
journey: current_journey_routing_name, | ||
show_error: @form.errors.any? | ||
) | ||
) %> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= form_for( | ||
@form, | ||
url: claim_path(current_journey_routing_name), | ||
builder: GOVUKDesignSystemFormBuilder::FormBuilder | ||
) do |f| %> | ||
<% if f.object.errors.any? %> | ||
<%= render("shared/error_summary", instance: f.object) %> | ||
<% end %> | ||
|
||
<%= f.govuk_collection_radio_buttons( | ||
:one_year, | ||
f.object.available_options, | ||
-> (option) { option }, | ||
-> (option) { t("get_a_teacher_relocation_payment.forms.contract_details.answers.#{option}.answer") }, | ||
legend: { text: t("get_a_teacher_relocation_payment.forms.contract_details.question") }, | ||
hint: { text: t("get_a_teacher_relocation_payment.forms.contract_details.hint") } | ||
) %> | ||
|
||
<%= f.govuk_submit %> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
|
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/20240620124504_add_one_year_to_international_relocation_payments_eligibilities.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 AddOneYearToInternationalRelocationPaymentsEligibilities < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :international_relocation_payments_eligibilities, :one_year, :boolean | ||
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
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
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
46 changes: 46 additions & 0 deletions
46
spec/forms/journeys/get_a_teacher_relocation_payment/contract_details_form_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,46 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Journeys::GetATeacherRelocationPayment::ContractDetailsForm, type: :model do | ||
let(:journey_session) { create(:get_a_teacher_relocation_payment_session) } | ||
|
||
let(:params) do | ||
ActionController::Parameters.new( | ||
claim: { | ||
one_year: option | ||
} | ||
) | ||
end | ||
|
||
let(:form) do | ||
described_class.new( | ||
journey_session: journey_session, | ||
journey: Journeys::GetATeacherRelocationPayment, | ||
params: params | ||
) | ||
end | ||
|
||
describe "validations" do | ||
subject { form } | ||
|
||
let(:option) { nil } | ||
|
||
it do | ||
is_expected.not_to( | ||
allow_value(nil) | ||
.for(:one_year) | ||
.with_message("Select the option that applies to you") | ||
) | ||
end | ||
end | ||
|
||
describe "#save" do | ||
let(:option) { true } | ||
|
||
it "updates the journey session" do | ||
expect { expect(form.save).to be(true) }.to( | ||
change { journey_session.reload.answers.one_year } | ||
.to(true) | ||
) | ||
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
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