-
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.
Add state_funded_secondary_school_form
Adds the second form in the teacher journey. The second form for trainee teachers is different so we'll handle that in a separate commit
- Loading branch information
Showing
18 changed files
with
191 additions
and
6 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
app/forms/journeys/get_a_teacher_relocation_payment/state_funded_secondary_school_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,27 @@ | ||
module Journeys | ||
module GetATeacherRelocationPayment | ||
class StateFundedSecondarySchoolForm < Form | ||
attribute :state_funded_secondary_school, :boolean | ||
|
||
validates :state_funded_secondary_school, | ||
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( | ||
state_funded_secondary_school: state_funded_secondary_school | ||
) | ||
|
||
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
33 changes: 33 additions & 0 deletions
33
app/views/get_a_teacher_relocation_payment/claims/state_funded_secondary_school.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,33 @@ | ||
<% content_for( | ||
:page_title, | ||
page_title( | ||
t("get_a_teacher_relocation_payment.forms.state_funded_secondary_school.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( | ||
:state_funded_secondary_school, | ||
f.object.available_options, | ||
-> (option) { option }, | ||
-> (option) { t("get_a_teacher_relocation_payment.forms.state_funded_secondary_school.answers.#{option}.answer") }, | ||
legend: { text: t("get_a_teacher_relocation_payment.forms.state_funded_secondary_school.question") }, | ||
hint: { text: t("get_a_teacher_relocation_payment.forms.state_funded_secondary_school.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
...6_add_state_funded_secondary_school_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 AddStateFundedSecondarySchoolToInternationalRelocationPaymentsEligibilities < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :international_relocation_payments_eligibilities, :state_funded_secondary_school, :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
...orms/journeys/get_a_teacher_relocation_payment/state_funded_secondary_school_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::StateFundedSecondarySchoolForm, type: :model do | ||
let(:journey_session) { create(:get_a_teacher_relocation_payment_session) } | ||
|
||
let(:params) do | ||
ActionController::Parameters.new( | ||
claim: { | ||
state_funded_secondary_school: 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(:state_funded_secondary_school) | ||
.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.state_funded_secondary_school } | ||
.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