File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
spec/bounded_contexts/booking/application/controllers Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ require "rails_helper"
2
+
3
+ module Booking
4
+ module Application
5
+ module Controllers
6
+ RSpec . describe CargoRoutingController , type : :request do
7
+ let ( :repo ) { Infrastructure ::Repositories ::CargoRepository . new }
8
+ let ( :create_cargo_params ) {
9
+ {
10
+ booking_amount : 1 ,
11
+ origin_location : "ATH" ,
12
+ dest_location : "HAM" ,
13
+ dest_arrival_deadline : Time . now . iso8601
14
+ }
15
+ }
16
+ let ( :create_cargo_request ) { post "/bookings" , params : create_cargo_params }
17
+ let ( :do_request ) { post "/cargorouting" , params : { booking_id : cargo . booking_id . value } }
18
+ let ( :cargo ) do
19
+ create_cargo_request
20
+ repo . get_by_booking_id ( JSON . parse ( response . body ) [ "value" ] )
21
+ end
22
+
23
+ it "responds with the correct http response" do
24
+ do_request
25
+ expect ( response . status ) . to eq 200
26
+ end
27
+
28
+ it "creates update the cargo itinerary" do
29
+ do_request
30
+ updated = repo . get_by_booking_id ( cargo . booking_id . value )
31
+
32
+ expect ( updated . itinerary . legs ) . to be_present
33
+ expect ( updated . itinerary . legs . size ) . to eq 2
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
You can’t perform that action at this time.
0 commit comments