-
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 business rules state that certain policy combinations aren't permitted, eg if a claimant has made an ECP claim they can't make a second claim for FE in the same academic year. In such an invalid claim scenario the requirement is to disable the approve button so admins can't approve the claim.
- Loading branch information
Showing
9 changed files
with
197 additions
and
14 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 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 |
---|---|---|
|
@@ -5,17 +5,20 @@ | |
end | ||
|
||
claims do | ||
personal_details = { | ||
national_insurance_number: generate(:national_insurance_number), | ||
email_address: "[email protected]", | ||
bank_sort_code: "220011", | ||
bank_account_number: "12345678", | ||
eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)} | ||
} | ||
personal_details = attributes_for( | ||
:claim, | ||
:random_personal_details, | ||
:with_bank_details | ||
).except(:reference).merge( | ||
eligibility_attributes: { | ||
teacher_reference_number: generate(:teacher_reference_number) | ||
} | ||
) | ||
claim_policies.map do |policy| | ||
association(:claim, :approved, personal_details.merge(policy: policy)) | ||
end | ||
end | ||
|
||
association(:payroll_run, factory: :payroll_run) | ||
|
||
award_amount { claims.map(&:award_amount).compact.sum } | ||
|
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
77 changes: 77 additions & 0 deletions
77
spec/features/admin/claim_with_unpermitted_policy_combo_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,77 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "Claim with unpermitted policy combo" do | ||
context "when one of the claims has been approved" do | ||
it "doesn't allow the admin to approve the other claim" do | ||
create( | ||
:claim, | ||
:approved, | ||
:current_academic_year, | ||
policy: Policies::InternationalRelocationPayments, | ||
email_address: "[email protected]" | ||
) | ||
|
||
duplicate_claim = create( | ||
:claim, | ||
:submitted, | ||
:current_academic_year, | ||
policy: Policies::FurtherEducationPayments, | ||
email_address: "[email protected]" | ||
) | ||
|
||
sign_in_as_service_operator | ||
|
||
visit new_admin_claim_decision_path(duplicate_claim) | ||
|
||
approve_option = find("input[type=radio][value=approved]") | ||
|
||
expect(approve_option).to be_disabled | ||
end | ||
end | ||
|
||
context "when neither of the claims have been approved" do | ||
it "allows the admin to approve one of the claims" do | ||
irp_claim = create( | ||
:claim, | ||
:submitted, | ||
:current_academic_year, | ||
policy: Policies::InternationalRelocationPayments, | ||
email_address: "[email protected]" | ||
) | ||
|
||
fe_claim = create( | ||
:claim, | ||
:submitted, | ||
:current_academic_year, | ||
policy: Policies::FurtherEducationPayments, | ||
email_address: "[email protected]" | ||
) | ||
|
||
sign_in_as_service_operator | ||
|
||
visit new_admin_claim_decision_path(irp_claim) | ||
|
||
approve_option = find("input[type=radio][value=approved]") | ||
|
||
expect(approve_option).not_to be_disabled | ||
|
||
visit new_admin_claim_decision_path(fe_claim) | ||
|
||
approve_option = find("input[type=radio][value=approved]") | ||
|
||
expect(approve_option).not_to be_disabled | ||
|
||
choose "Approve" | ||
|
||
fill_in "Decision notes", with: "LGTM" | ||
|
||
click_on "Confirm decision" | ||
|
||
visit new_admin_claim_decision_path(irp_claim) | ||
|
||
approve_option = find("input[type=radio][value=approved]") | ||
|
||
expect(approve_option).to be_disabled | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -392,6 +392,54 @@ | |
expect(subject).not_to be_approvable | ||
end | ||
end | ||
|
||
context "when the claimant has claimed for a policy that precludes them from this policy" do | ||
subject do | ||
create( | ||
:claim, | ||
:submitted, | ||
:current_academic_year, | ||
policy: Policies::FurtherEducationPayments, | ||
email_address: "[email protected]" | ||
) | ||
end | ||
|
||
context "when the other claim has been approved" do | ||
it "is not approvable" do | ||
create( | ||
:claim, | ||
:approved, | ||
:current_academic_year, | ||
policy: Policies::EarlyCareerPayments, | ||
email_address: "[email protected]" | ||
) | ||
|
||
expect(subject).not_to be_approvable | ||
end | ||
end | ||
|
||
context "when the other claim has not been approved" do | ||
it "is approvable" do | ||
create( | ||
:claim, | ||
:submitted, | ||
:current_academic_year, | ||
policy: Policies::EarlyCareerPayments, | ||
email_address: "[email protected]" | ||
) | ||
|
||
create( | ||
:claim, | ||
:rejected, | ||
:current_academic_year, | ||
policy: Policies::EarlyCareerPayments, | ||
email_address: "[email protected]" | ||
) | ||
|
||
expect(subject).to be_approvable | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "#rejectable?" do | ||
|
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