Skip to content

Commit f5a76ab

Browse files
committed
test: 🧪 add cargo handled event handler
1 parent 9325244 commit f5a76ab

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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

0 commit comments

Comments
 (0)