Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CPDLP-3510] npq internal api revisit fallback for funding eligibility logic in npq #1741

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions app/services/funding_eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ def possible_funding_for_non_pp50_and_fe?
end

def previously_received_targeted_funding_support?
return ecf_api_funding_lookup["previously_received_targeted_funding_support"] == true unless Rails.application.config.npq_separation[:ecf_api_disabled]

accepted_applications.with_targeted_delivery_funding_eligibility.any?
if Feature.ecf_api_disabled?
accepted_applications.with_targeted_delivery_funding_eligibility.any?
else
ecf_api_funding_lookup["previously_received_targeted_funding_support"] == true
end
end

def ineligible_institution_type?
Expand Down Expand Up @@ -212,9 +214,11 @@ def trn_users
end

def previously_funded?
return ecf_api_funding_lookup["previously_funded"] == true unless Rails.application.config.npq_separation[:ecf_api_disabled]

accepted_applications.any?
if Feature.ecf_api_disabled?
accepted_applications.any?
else
ecf_api_funding_lookup["previously_funded"] == true
end
end

def accepted_applications
Expand Down
40 changes: 21 additions & 19 deletions spec/lib/services/funding_eligibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
let(:query_store) { nil }

before do
mock_previous_funding_api_request(
course_identifier:,
get_an_identity_id:,
trn:,
response: ecf_funding_lookup_response(previously_funded:),
)
unless Feature.ecf_api_disabled?
mock_previous_funding_api_request(
course_identifier:,
get_an_identity_id:,
trn:,
response: ecf_funding_lookup_response(previously_funded:),
)
end
end

describe ".funded? && .funding_eligiblity_status_code" do
Expand All @@ -49,7 +51,7 @@
end

context "when External::EcfAPI is disabled" do
before { allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true }) }
before { allow(Feature).to receive(:ecf_api_disabled?).and_return(true) }

it "returns true" do
expect(subject).to be_funded
Expand Down Expand Up @@ -82,7 +84,7 @@

context "when External::EcfAPI is disabled" do
before do
allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true })
allow(Feature).to receive(:ecf_api_disabled?).and_return(true)
user = create(:user, trn:)
create(:application, :previously_funded, user:, course:)
end
Expand Down Expand Up @@ -125,7 +127,7 @@
end

context "when External::EcfAPI is disabled" do
before { allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true }) }
before { allow(Feature).to receive(:ecf_api_disabled?).and_return(true) }

it "returns true" do
expect(subject).to be_funded
Expand Down Expand Up @@ -166,7 +168,7 @@
end

context "when External::EcfAPI is disabled" do
before { allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true }) }
before { allow(Feature).to receive(:ecf_api_disabled?).and_return(true) }

it "returns false" do
expect(subject).not_to be_funded
Expand Down Expand Up @@ -239,7 +241,7 @@
end

context "when External::EcfAPI is disabled" do
before { allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true }) }
before { allow(Feature).to receive(:ecf_api_disabled?).and_return(true) }

it "is eligible" do
expect(subject).to be_funded
Expand All @@ -258,7 +260,7 @@
end

context "when External::EcfAPI is disabled" do
before { allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true }) }
before { allow(Feature).to receive(:ecf_api_disabled?).and_return(true) }

it "is not eligible for #{course.identifier}" do
expect(subject).not_to be_funded
Expand All @@ -278,7 +280,7 @@
end

context "when External::EcfAPI is disabled" do
before { allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true }) }
before { allow(Feature).to receive(:ecf_api_disabled?).and_return(true) }

it "is eligible" do
expect(subject).to be_funded
Expand All @@ -296,7 +298,7 @@

context "when External::EcfAPI is disabled" do
before do
allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true })
allow(Feature).to receive(:ecf_api_disabled?).and_return(true)
user = create(:user, trn:)
create(:application, :previously_funded, user:, course:)
end
Expand Down Expand Up @@ -325,7 +327,7 @@

context "when External::EcfAPI is disabled" do
before do
allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true })
allow(Feature).to receive(:ecf_api_disabled?).and_return(true)
user = create(:user, trn:)
create(:application, :previously_funded, user:, course:)
end
Expand All @@ -349,7 +351,7 @@
end

context "when External::EcfAPI is disabled" do
before { allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true }) }
before { allow(Feature).to receive(:ecf_api_disabled?).and_return(true) }

it "returns status code :not_in_england" do
expect(subject.funding_eligiblity_status_code).to eq :not_in_england
Expand All @@ -373,7 +375,7 @@
end

context "when External::EcfAPI is disabled" do
before { allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true }) }
before { allow(Feature).to receive(:ecf_api_disabled?).and_return(true) }

it "returns status code :early_years_invalid_npq" do
expect(subject.funding_eligiblity_status_code).to eq :early_years_invalid_npq
Expand All @@ -395,7 +397,7 @@
end

context "when External::EcfAPI is disabled" do
before { allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true }) }
before { allow(Feature).to receive(:ecf_api_disabled?).and_return(true) }

it "is not eligible" do
expect(subject.funded?).to be false
Expand All @@ -417,7 +419,7 @@
end

context "when External::EcfAPI is disabled" do
before { allow(Rails.application.config).to receive(:npq_separation).and_return({ ecf_api_disabled: true }) }
before { allow(Feature).to receive(:ecf_api_disabled?).and_return(true) }

it "is ineligible" do
expect(subject.funded?).to be false
Expand Down
Loading