-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ShipmentTracking Job and Call when updated
This commit adds a ShipmentTrackingJob that calls the ShipmentTracking Service. This was necessary because the check for the update on the tracking number is called before_save and calling the service at this point would cause a lot of delay for the API to execute. Hence, the service is called asynchronously from this point in the code.
- Loading branch information
1 parent
1f4c78d
commit e432ca5
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
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
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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module SolidusBolt | ||
class ShipmentTrackingJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(transaction_reference:, shipment:) | ||
SolidusBolt::Orders::TrackShipmentService.call(transaction_reference: transaction_reference, shipment: shipment) | ||
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
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,19 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe SolidusBolt::ShipmentTrackingJob do | ||
subject(:shipment_tracking_job) { | ||
described_class.perform_now(transaction_reference: transaction_reference, shipment: shipment) | ||
} | ||
|
||
let(:shipment) { build(:shipment) } | ||
let(:transaction_reference) { 'Multiverse of Madness' } | ||
|
||
before { allow(SolidusBolt::Orders::TrackShipmentService).to receive(:call) } | ||
|
||
it 'calls the TrackShipmentService' do | ||
shipment_tracking_job | ||
expect(SolidusBolt::Orders::TrackShipmentService).to have_received(:call).with( | ||
transaction_reference: transaction_reference, shipment: shipment | ||
) | ||
end | ||
end |