summaryrefslogtreecommitdiff
path: root/spec/models/spree/shipment_spec.rb
diff options
context:
space:
mode:
authorNoah Silvera <noah@super.gd>2021-07-19 15:49:31 -0700
committerNoah Silvera <noah@super.gd>2021-07-19 15:52:42 -0700
commitdd587bb1746247974e77b35cc6c81789e22634a5 (patch)
tree573396af003a84d19062a9bb5322e639f984716b /spec/models/spree/shipment_spec.rb
parent65d0db3ec71b148777a59f752268d07b345c7e9e (diff)
Add an event that is fired when any shipment ships
Transactions need to be reported to TaxJar when any of the shipment ships (some stores have partial shipping). To accomodate this, we add a new event which is fired whenever any shipment on an order ships. Co-authored-by: Nick Van Doorn <nick@super.gd>
Diffstat (limited to 'spec/models/spree/shipment_spec.rb')
-rw-r--r--spec/models/spree/shipment_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/models/spree/shipment_spec.rb b/spec/models/spree/shipment_spec.rb
new file mode 100644
index 0000000..27f213b
--- /dev/null
+++ b/spec/models/spree/shipment_spec.rb
@@ -0,0 +1,16 @@
+RSpec.describe Spree::Shipment do
+ describe '#update' do
+ subject { shipment.ship }
+
+ let(:shipment) { create(:shipment, state: 'ready', order: order) }
+ let(:order) { create :order_with_line_items }
+
+ it 'fires the shipment_shipped event exactly once' do
+ stub_const('Spree::Event', class_spy(Spree::Event))
+
+ expect(Spree::Event).to receive(:fire).with('shipment_shipped', shipment: shipment).once
+
+ subject
+ end
+ end
+end