diff --git a/app/services/funding_eligibility.rb b/app/services/funding_eligibility.rb index a0854801bb..fcafd4b928 100644 --- a/app/services/funding_eligibility.rb +++ b/app/services/funding_eligibility.rb @@ -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? @@ -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 diff --git a/spec/lib/services/funding_eligibility_spec.rb b/spec/lib/services/funding_eligibility_spec.rb index aa98a6029a..50317f0a9c 100644 --- a/spec/lib/services/funding_eligibility_spec.rb +++ b/spec/lib/services/funding_eligibility_spec.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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