Skip to content

Commit 3d527f9

Browse files
committed
test: 🧪 add cargo routing controller
1 parent 363fdfa commit 3d527f9

File tree

1 file changed

+38
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)