Skip to content

Commit

Permalink
Ajout de tests unitaires
Browse files Browse the repository at this point in the history
  • Loading branch information
tnicolas1 committed Oct 11, 2024
1 parent c563108 commit 9de7458
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion spec/models/asp/payment_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
end
end

# rubocop:disable RSpec/MultipleMemoizedHelpers
describe "eligible_for_auto_retry?" do
let(:p_r_incomplete_for_abrogation) do
create(:asp_payment_request, :incomplete, incomplete_reason: :needs_abrogated_attributive_decision)
Expand All @@ -146,6 +147,15 @@
end
let(:p_r_ready) { create(:asp_payment_request, :ready) }

let(:p_r_rejected) { create(:asp_payment_request, :rejected) }
let(:p_r_rejected_rib) do
create(:asp_payment_request, :rejected, reason: "Test d'une raison de blocage d'un paiement bancaire")
end
let(:p_r_unpaid) { create(:asp_payment_request, :unpaid) }
let(:p_r_unpaid_rib) do
create(:asp_payment_request, :unpaid, reason: "Test d'une raison de blocage d'un paiement bancaire")
end

context "when the payment request is in 'incomplete' state with the abrogation specific error message" do
it "returns true" do
expect(p_r_incomplete_for_abrogation.eligible_for_auto_retry?).to be true
Expand All @@ -164,6 +174,29 @@
end
end

# TODO: Ajouter un contexte pour le cas 'rejected' et 'unpaid'
context "when the payment request is in 'rejected' state without a RIB reason" do
it "returns false" do
expect(p_r_rejected.eligible_for_auto_retry?).to be false
end
end

context "when the payment request is in 'rejected' state with a RIB reason" do
it "returns true" do
expect(p_r_rejected_rib.eligible_for_auto_retry?).to be true
end
end

context "when the payment request is in 'unpaid' state without a RIB reason" do
it "returns false" do
expect(p_r_unpaid.eligible_for_auto_retry?).to be false
end
end

context "when the payment request is in 'unpaid' state with a RIB reason" do
it "returns true" do
expect(p_r_unpaid_rib.eligible_for_auto_retry?).to be true
end
end
end
# rubocop:enable RSpec/MultipleMemoizedHelpers
end

0 comments on commit 9de7458

Please sign in to comment.