Skip to content

Commit

Permalink
abort
Browse files Browse the repository at this point in the history
  • Loading branch information
ac-dylan committed Jul 24, 2024
1 parent cb6ffd1 commit 758f762
Showing 1 changed file with 4 additions and 31 deletions.
35 changes: 4 additions & 31 deletions spec/requests/schoolings_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
let(:user) { create(:user, :director, :with_selected_establishment, establishment: student.classe.establishment) }

let(:schooling) { create(:schooling, :with_attributive_decision) }
let(:payment_request_missing_da) { create(:asp_payment_request, :incomplete_for_missing_abrogation_da) }
let(:payment_request) { create(:asp_payment_request, :incomplete) }
let(:payment_request) { create(:asp_payment_request, :incomplete_for_missing_abrogation_da) }

# rubocop:disable Layout/LineLength
error_message = I18n.t("activerecord.errors.models.asp/payment_request.attributes.ready_state_validation.needs_abrogated_attributive_decision")
# rubocop:enable Layout/LineLength

before do
sign_in(user)
schooling.pfmps = [payment_request_missing_da.pfmp]
schooling.pfmps = [payment_request.pfmp]
schooling.save!
Timecop.safe_mode = false
Timecop.freeze(Date.new(2024, 6, 21))
Expand All @@ -42,37 +41,11 @@
end

context "when the payment request is retry eligible" do
it "Does not return abrogated decision error" do
it "does not return abrogated decision error" do
delete abrogate_decision_school_year_class_schooling_path(schooling.classe.school_year,
class_id: schooling.classe.id, id: schooling.id),
params: { confirmed_director: "1" }
expect(payment_request_missing_da.last_transition.metadata).not_to include(error_message)
end
end

context "when the payment request is retry eligible" do
it "Does not return abrogated decision error" do
schooling.pfmps = [payment_request.pfmp]
schooling.save!
delete abrogate_decision_school_year_class_schooling_path(schooling.classe.school_year,
class_id: schooling.classe.id, id: schooling.id),
params: { confirmed_director: "1" }
expect(payment_request.last_transition.metadata).to include(error_message)
end
end

context "when the payment request is not retry eligible" do
let(:pfmp) { create(:pfmp, :completed) }

before do
schooling.update!(pfmps: [pfmp])
end

it "Returns abrogated decision error" do
delete abrogate_decision_school_year_class_schooling_path(schooling.classe.school_year,
class_id: schooling.classe.id, id: schooling.id),
params: { confirmed_director: "1" }
expect(payment_request_missing_da.current_state).not_to eq(:ready)
expect(payment_request.last_transition.metadata).not_to include(error_message)
end
end
end
Expand Down

0 comments on commit 758f762

Please sign in to comment.