-
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.
tidy up. spec added for sign in form
- Loading branch information
Showing
4 changed files
with
58 additions
and
3 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
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
spec/factories/journeys/further_education_payments/further_education_payments_answers.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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
FactoryBot.define do | ||
factory :further_education_payments_answers, class: "Journeys::FurtherEducationPayments::SessionAnswers" do | ||
trait :with_details_from_onelogin do | ||
first_name { "Jo" } | ||
surname { "Bloggs" } | ||
onelogin_user_info { {email: "[email protected]"} } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe SignInForm do | ||
let(:journey) { Journeys::FurtherEducationPayments } | ||
let(:journey_session) do | ||
build( | ||
:"#{journey::I18N_NAMESPACE}_session", | ||
answers: attributes_for( | ||
:"#{journey::I18N_NAMESPACE}_answers", | ||
:with_details_from_onelogin | ||
) | ||
) | ||
end | ||
|
||
let(:onelogin_user_info) do | ||
{email: "[email protected]", phone: nil} | ||
end | ||
|
||
let(:form) do | ||
described_class.new( | ||
journey: journey, | ||
journey_session: journey_session, | ||
params: params | ||
) | ||
end | ||
|
||
let(:params) do | ||
ActionController::Parameters.new( | ||
claim: { | ||
# logged_in_with_tid: true | ||
} | ||
) | ||
end | ||
|
||
describe "#save" do | ||
before { form.save } | ||
|
||
it "keeps the details from onelogin_user_info" do | ||
expect( | ||
journey_session.answers.onelogin_user_info.symbolize_keys | ||
).to(eq(onelogin_user_info)) | ||
end | ||
|
||
it "keeps the first name" do | ||
expect(journey_session.answers.first_name).to eq "Jo" | ||
end | ||
|
||
it "keeps the surname" do | ||
expect(journey_session.answers.surname).to eq "Bloggs" | ||
end | ||
end | ||
end |