-
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.
reminders now supports reverse soft delete
- Loading branch information
Showing
4 changed files
with
106 additions
and
1 deletion.
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 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Reminders::EmailVerificationForm do | ||
let!(:journey_configuration) do | ||
create(:journey_configuration, :further_education_payments) | ||
end | ||
|
||
let(:journey) { Journeys::FurtherEducationPayments } | ||
let(:journey_session) do | ||
create( | ||
:further_education_payments_session, | ||
answers: { | ||
reminder_full_name: "John Doe", | ||
reminder_email_address: "[email protected]" | ||
} | ||
) | ||
end | ||
|
||
subject do | ||
described_class.new( | ||
journey_session:, | ||
journey:, | ||
params: ActionController::Parameters.new, | ||
session: {} | ||
) | ||
end | ||
|
||
describe "#save!" do | ||
let(:fake_passing_validator) { OpenStruct.new(valid?: true) } | ||
|
||
before do | ||
allow(OneTimePassword::Validator).to receive(:new).and_return(fake_passing_validator) | ||
end | ||
|
||
context "when reminder previously soft deleted" do | ||
let!(:reminder) do | ||
create( | ||
:reminder, | ||
:soft_deleted, | ||
full_name: "John Doe", | ||
email_address: "[email protected]", | ||
email_verified: true, | ||
itt_subject: nil, | ||
itt_academic_year: journey_configuration.current_academic_year.succ, | ||
journey_class: journey.to_s | ||
) | ||
end | ||
|
||
it "becomes undeleted" do | ||
expect { | ||
subject.save! | ||
}.to change { reminder.reload.deleted_at }.to(nil) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Reminders::PersonalDetailsForm do | ||
let!(:journey_configuration) do | ||
create(:journey_configuration, :further_education_payments) | ||
end | ||
|
||
let(:journey) { Journeys::FurtherEducationPayments } | ||
let(:journey_session) { create(:further_education_payments_session) } | ||
let(:claim) { create(:claim, :submitted) } | ||
|
||
subject do | ||
described_class.new( | ||
journey_session:, | ||
journey:, | ||
params: ActionController::Parameters.new, | ||
session: {"submitted_claim_id" => claim.id} | ||
) | ||
end | ||
|
||
describe "#set_reminder_from_claim" do | ||
context "when reminder previously soft deleted" do | ||
let!(:reminder) do | ||
create( | ||
:reminder, | ||
:soft_deleted, | ||
full_name: claim.full_name, | ||
email_address: claim.email_address, | ||
email_verified: true, | ||
itt_subject: claim.eligible_itt_subject, | ||
itt_academic_year: journey_configuration.current_academic_year.succ, | ||
journey_class: journey.to_s | ||
) | ||
end | ||
|
||
it "becomes undeleted" do | ||
expect { | ||
subject.set_reminder_from_claim | ||
}.to change { reminder.reload.deleted_at }.to(nil) | ||
end | ||
end | ||
end | ||
end |