File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
spec/bounded_contexts/tracking/application/event_handlers Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ require "rails_helper"
2
+
3
+ module Tracking
4
+ module Application
5
+ module EventHandlers
6
+ describe CargoHandledEventHandler , type : :model do
7
+ let ( :handler ) { described_class }
8
+ let ( :event ) {
9
+ SharedDomain ::Events ::CargoHandledEvent . new (
10
+ booking_id : "booking_id" ,
11
+ handling_type : "handling_type" ,
12
+ handling_completion_time : Time . now . to_datetime ,
13
+ handling_location : "handling_location" ,
14
+ voyage_number : "voyage_number"
15
+ )
16
+ }
17
+
18
+ module AssignServiceMock
19
+ def self . add_tracking_event ( command )
20
+ command
21
+ end
22
+ end
23
+
24
+ before do
25
+ Tracking ::Container . enable_stubs!
26
+ Tracking ::Container . stub ( "tracking.assign_tracking_id_service" , AssignServiceMock )
27
+ end
28
+
29
+ after do
30
+ Tracking ::Container . unstub ( "shared.http_client" )
31
+ end
32
+
33
+ it "processes the event when dispatched" do
34
+ expect ( handler ) . to receive ( :call ) . with ( event )
35
+ EventDispatcher . emit ( event )
36
+ end
37
+
38
+ it "adds a tracking event" do
39
+ expect ( AssignServiceMock ) . to receive ( :add_tracking_event ) . with (
40
+ CargoHandledEventHandler ::TrackingActivityEventAssembler . to_command_from_event ( event )
41
+ )
42
+ EventDispatcher . emit ( event )
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
You can’t perform that action at this time.
0 commit comments