Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add forgotten quote errors to success response list #556

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ how this file is formatted and how the process works.

### Fixed
- JTB: ignore units without availability calendar
- Add `:property_not_instant_bookable` and `:max_guests_exceeded` errors to `ERROR_CODES_WITH_SUCCESS_RESPONSE`

### Changed
- Refactor reading `suppliers.yml`, extract all logic in `Concierge::SupplierConfig` class
Expand Down
3 changes: 2 additions & 1 deletion lib/concierge/errors/quote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# for constructing common quote errors
module Concierge::Errors::Quote

ERROR_CODES_WITH_SUCCESS_RESPONSE = [:check_in_too_near, :check_in_too_far, :stay_too_short]
ERROR_CODES_WITH_SUCCESS_RESPONSE = [:check_in_too_near, :check_in_too_far, :stay_too_short,
:property_not_instant_bookable, :max_guests_exceeded]

def check_in_too_near
Result.error(:check_in_too_near, "Selected check-in date is too near")
Expand Down
2 changes: 1 addition & 1 deletion spec/api/controllers/atleisure/quote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def provoke_failure!
stub_call(:post, endpoint) { [200, {}, jsonrpc_fixture("atleisure/on_request.json")] }
response = parse_response(described_class.new.call(params))

expect(response.status).to eq 503
expect(response.status).to eq 200
expect(response.body["status"]).to eq "error"
expect(response.body["errors"]["quote"]).to eq "Instant booking is not supported for the given period"
end
Expand Down
21 changes: 21 additions & 0 deletions spec/api/controllers/shared/quote_call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@
end
end

context "client returns property_not_instant_bookable" do
it "returns proper error messages" do
expect_any_instance_of(described_class).to receive(:quote_price).and_return(not_instant_bookable)
response = parse_response(subject)
expect(response.status).to eq 200
expect(response.body["status"]).to eq "error"
expect(response.body["errors"]["quote"]).to eq "Instant booking is not supported for the given period"
end
end

context "client returns max_guests_exceeded" do
it "returns proper error messages" do
expect_any_instance_of(described_class).to receive(:quote_price).and_return(max_guests_exceeded(5))
response = parse_response(subject)
expect(response.status).to eq 200
expect(response.body["status"]).to eq "error"
expect(response.body["errors"]["quote"]).to eq "The maximum number of guests to book this apartment is 5"
end
end


it "returns unavailable quotation" do
unavailable_quotation = Quotation.new({
property_id: params[:property_id],
Expand Down