Skip to content

Commit 363fdfa

Browse files
committed
test: 🧪 add cargo booking controller
1 parent e94aec2 commit 363fdfa

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require "rails_helper"
2+
3+
module Booking
4+
module Application
5+
module Controllers
6+
RSpec.describe CargoBookingsController, type: :request do
7+
let(:repo) { Infrastructure::Repositories::CargoRepository.new }
8+
let(:path) { "/bookings" }
9+
let(:params) {
10+
{
11+
booking_amount: 1,
12+
origin_location: "ATH",
13+
dest_location: "HAM",
14+
dest_arrival_deadline: Time.now.iso8601
15+
}
16+
}
17+
let(:do_request) { post path, params: params }
18+
19+
it "responds with the correct http response" do
20+
do_request
21+
expect(response.status).to eq 200
22+
end
23+
24+
it "responds with the correct body" do
25+
do_request
26+
27+
json = JSON.parse(response.body)
28+
expect(json["value"]).to be_present
29+
expect(repo.get_by_booking_id(json["value"])).to be_a(Domain::Aggregates::Cargo)
30+
end
31+
end
32+
end
33+
end
34+
end

0 commit comments

Comments
 (0)