-
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.
Adds a screen for the passport number. Again like, the nationality, this is a question we show in the personal details part of the journey but we store it on the eligiblity, as this is the only journey that asks this question and the claim is shared with all journeys.
- Loading branch information
Showing
15 changed files
with
186 additions
and
3 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
app/forms/journeys/get_a_teacher_relocation_payment/passport_number_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,26 @@ | ||
module Journeys | ||
module GetATeacherRelocationPayment | ||
class PassportNumberForm < Form | ||
attribute :passport_number, :string | ||
|
||
validates :passport_number, presence: { | ||
message: i18n_error_message(:presence) | ||
} | ||
|
||
validates :passport_number, format: { | ||
with: /\A[a-zA-Z0-9]{1,20}\z/, | ||
message: i18n_error_message(:invalid) | ||
}, if: :passport_number | ||
|
||
def save | ||
return false unless valid? | ||
|
||
journey_session.answers.assign_attributes( | ||
passport_number: passport_number | ||
) | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ class SlugSequence | |
|
||
PERSONAL_DETAILS_SLUGS = [ | ||
"nationality", | ||
"passport-number" | ||
] | ||
|
||
RESULTS_SLUGS = [ | ||
|
30 changes: 30 additions & 0 deletions
30
app/views/get_a_teacher_relocation_payment/claims/passport_number.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,30 @@ | ||
<% content_for( | ||
:page_title, | ||
page_title( | ||
t("get_a_teacher_relocation_payment.forms.passport_number.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| %> | ||
<%= f.govuk_error_summary %> | ||
|
||
<%= f.govuk_text_field( | ||
:passport_number, | ||
label: { | ||
text: t("get_a_teacher_relocation_payment.forms.passport_number.question"), | ||
size: "l" | ||
}, | ||
) %> | ||
|
||
<%= 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,4 +96,6 @@ | |
- created_at | ||
- updated_at | ||
- gender_digit | ||
:international_relocation_payments_eligibilities: | ||
- passport_number | ||
|
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
.../20240624105924_add_passport_number_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 AddPassportNumberToInternationalRelocationPaymentsEligibilities < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :international_relocation_payments_eligibilities, :passport_number, :string | ||
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
70 changes: 70 additions & 0 deletions
70
spec/forms/journeys/get_a_teacher_relocation_payment/passport_number_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,70 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Journeys::GetATeacherRelocationPayment::PassportNumberForm, type: :model do | ||
let(:journey_session) { create(:get_a_teacher_relocation_payment_session) } | ||
|
||
let(:params) do | ||
ActionController::Parameters.new( | ||
claim: { | ||
passport_number: option | ||
} | ||
) | ||
end | ||
|
||
let(:option) { nil } | ||
|
||
let(:form) do | ||
described_class.new( | ||
journey_session: journey_session, | ||
journey: Journeys::GetATeacherRelocationPayment, | ||
params: params | ||
) | ||
end | ||
|
||
describe "validations" do | ||
subject { form } | ||
|
||
it do | ||
is_expected.to( | ||
validate_presence_of(:passport_number) | ||
.with_message("Enter your passport number") | ||
) | ||
end | ||
|
||
# Passport number contains non alphanumeric characters | ||
it do | ||
is_expected.not_to( | ||
allow_value("123456789012345$") | ||
.for(:passport_number) | ||
.with_message("Invalid passport number") | ||
) | ||
end | ||
|
||
# Passport number at max allowed length | ||
it do | ||
is_expected.to( | ||
allow_value("1234567890ABCDEfghij").for(:passport_number) | ||
) | ||
end | ||
|
||
# Passport number too long | ||
it do | ||
is_expected.not_to( | ||
allow_value("12345678901234567890A") | ||
.for(:passport_number) | ||
.with_message("Invalid passport number") | ||
) | ||
end | ||
end | ||
|
||
describe "#save" do | ||
let(:option) { "123456789012345" } | ||
|
||
it "updates the journey session" do | ||
expect { expect(form.save).to be(true) }.to( | ||
change { journey_session.reload.answers.passport_number } | ||
.to("123456789012345") | ||
) | ||
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