-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(integrations): Sync credit notes - create job
- Loading branch information
1 parent
64b072b
commit 8a1648c
Showing
3 changed files
with
61 additions
and
19 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
app/jobs/integrations/aggregator/credit_notes/create_job.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Integrations | ||
module Aggregator | ||
module CreditNotes | ||
class CreateJob < ApplicationJob | ||
queue_as 'integrations' | ||
|
||
retry_on LagoHttpClient::HttpError, wait: :exponentially_longer, attempts: 3 | ||
|
||
def perform(credit_note:) | ||
result = Integrations::Aggregator::CreditNotes::CreateService.call(credit_note:) | ||
result.raise_if_error! | ||
end | ||
end | ||
end | ||
end | ||
end |
25 changes: 25 additions & 0 deletions
25
spec/jobs/integrations/aggregator/credit_notes/create_job_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Integrations::Aggregator::CreditNotes::CreateJob, type: :job do | ||
subject(:create_job) { described_class } | ||
|
||
let(:service) { instance_double(Integrations::Aggregator::CreditNotes::CreateService) } | ||
let(:credit_note) { create(:credit_note) } | ||
let(:result) { BaseService::Result.new } | ||
|
||
before do | ||
allow(Integrations::Aggregator::CreditNotes::CreateService).to receive(:new).and_return(service) | ||
allow(service).to receive(:call).and_return(result) | ||
end | ||
|
||
it 'calls the aggregator create credit_note service' do | ||
described_class.perform_now(credit_note:) | ||
|
||
aggregate_failures do | ||
expect(Integrations::Aggregator::CreditNotes::CreateService).to have_received(:new) | ||
expect(service).to have_received(:call) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters