From d1602c017d76c236775dafa848fbfaaa72d9f51b Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 22 Feb 2024 05:40:07 -0500 Subject: [PATCH] Add basic coverage for `ApproveAppealService` class (#29333) --- spec/services/approve_appeal_service_spec.rb | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/services/approve_appeal_service_spec.rb diff --git a/spec/services/approve_appeal_service_spec.rb b/spec/services/approve_appeal_service_spec.rb new file mode 100644 index 0000000000..5707c5d7f4 --- /dev/null +++ b/spec/services/approve_appeal_service_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe ApproveAppealService do + describe '#call' do + context 'with an existing appeal' do + let(:appeal) { Fabricate(:appeal) } + let(:account) { Fabricate(:account) } + + it 'processes the appeal approval' do + expect { subject.call(appeal, account) } + .to mark_overruled + .and record_approver + end + + def mark_overruled + change(appeal.strike, :overruled_at) + .from(nil) + .to(be > 1.minute.ago) + end + + def record_approver + change(appeal, :approved_by_account) + .from(nil) + .to(account) + end + end + end +end