quicktravel_client 3.7.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +5 -4
- data/CHANGELOG.md +30 -0
- data/gemfiles/rails6.gemfile +8 -0
- data/lib/quick_travel.rb +2 -0
- data/lib/quick_travel/adapter.rb +13 -25
- data/lib/quick_travel/booking.rb +6 -5
- data/lib/quick_travel/cache.rb +24 -5
- data/lib/quick_travel/checkout.rb +1 -1
- data/lib/quick_travel/client.rb +9 -1
- data/lib/quick_travel/init_from_hash.rb +4 -0
- data/lib/quick_travel/package.rb +13 -0
- data/lib/quick_travel/passenger_type.rb +1 -1
- data/lib/quick_travel/product_configuration.rb +1 -1
- data/lib/quick_travel/products/base.rb +4 -4
- data/lib/quick_travel/reservation.rb +1 -1
- data/lib/quick_travel/resource.rb +1 -1
- data/lib/quick_travel/route.rb +1 -1
- data/lib/quick_travel/route_stop.rb +8 -1
- data/lib/quick_travel/vehicle_type.rb +1 -1
- data/lib/quick_travel/version.rb +1 -1
- data/quicktravel_client.gemspec +5 -5
- data/spec/adapter_spec.rb +34 -3
- data/spec/booking_spec.rb +10 -0
- data/spec/checkout_spec.rb +0 -182
- data/spec/clients_spec.rb +42 -0
- data/spec/discounts_spec.rb +21 -21
- data/spec/package_spec.rb +24 -0
- data/spec/passenger_type_spec.rb +1 -1
- data/spec/product_configuration_spec.rb +11 -0
- data/spec/reservation_spec.rb +20 -0
- data/spec/spec_helper.rb +6 -3
- data/spec/support/cassettes/accommodation_reserve.yml +12 -4
- data/spec/support/cassettes/basic_product_scheduled_trips.yml +3 -1
- data/spec/support/cassettes/basic_product_scheduled_trips_multi_sector.yml +3 -1
- data/spec/support/cassettes/basic_product_scheduled_trips_unbookable.yml +3 -1
- data/spec/support/cassettes/booking_activate.yml +6 -2
- data/spec/support/cassettes/booking_cancel.yml +6 -2
- data/spec/support/cassettes/booking_create.yml +3 -1
- data/spec/support/cassettes/booking_create_accommodation.yml +3 -1
- data/spec/support/cassettes/booking_documents.yml +3 -1
- data/spec/support/cassettes/booking_non_existant.yml +3 -1
- data/spec/support/cassettes/booking_price_changes.yml +3 -1
- data/spec/support/cassettes/booking_show.yml +3 -1
- data/spec/support/cassettes/booking_update.yml +6 -2
- data/spec/support/cassettes/booking_with_comments.yml +119 -0
- data/spec/support/cassettes/booking_with_documents.yml +6 -2
- data/spec/support/cassettes/booking_with_nested_attributes.yml +9 -3
- data/spec/support/cassettes/booking_with_price_changes.yml +3 -1
- data/spec/support/cassettes/checkout_client_token.yml +3 -1
- data/spec/support/cassettes/client_templates.yml +120 -0
- data/spec/support/cassettes/countries.yml +3 -1
- data/spec/support/cassettes/country_all.yml +3 -1
- data/spec/support/cassettes/create_reservation_fail.yml +3 -1
- data/spec/support/cassettes/create_reservation_with_booking.yml +3 -1
- data/spec/support/cassettes/locations.yml +3 -1
- data/spec/support/cassettes/opal_modern_pay_failed_booking.yml +3 -1
- data/spec/support/cassettes/opal_modern_pay_failed_create.yml +3 -1
- data/spec/support/cassettes/opal_modern_pay_failed_update.yml +3 -1
- data/spec/support/cassettes/opal_modern_pay_successful_booking.yml +3 -1
- data/spec/support/cassettes/opal_modern_pay_successful_response.yml +3 -1
- data/spec/support/cassettes/opal_modern_pay_successful_update_response.yml +3 -1
- data/spec/support/cassettes/opal_pay.yml +3 -1
- data/spec/support/cassettes/opal_pay_booking.yml +3 -1
- data/spec/support/cassettes/package_show.yml +83 -0
- data/spec/support/cassettes/package_show_product_type.yml +80 -0
- data/spec/support/cassettes/passenger_all.yml +3 -1
- data/spec/support/cassettes/payment_info.yml +3 -1
- data/spec/support/cassettes/price_quote.yml +6 -2
- data/spec/support/cassettes/product_date_range_bookability.yml +3 -1
- data/spec/support/cassettes/product_show.yml +3 -1
- data/spec/support/cassettes/product_show_as_agent.yml +3 -1
- data/spec/support/cassettes/product_type_all.yml +3 -1
- data/spec/support/cassettes/product_type_resource_categories.yml +3 -1
- data/spec/support/cassettes/product_type_resource_categories_tickets.yml +3 -1
- data/spec/support/cassettes/product_type_routes.yml +3 -1
- data/spec/support/cassettes/property.yml +3 -1
- data/spec/support/cassettes/property_types.yml +3 -1
- data/spec/support/cassettes/region_show.yml +3 -1
- data/spec/support/cassettes/reservation_resource.yml +3 -1
- data/spec/support/cassettes/reservation_with_extra_picks.yml +9 -3
- data/spec/support/cassettes/resource_category_all.yml +3 -1
- data/spec/support/cassettes/resource_category_all_for_product_type_8.yml +3 -1
- data/spec/support/cassettes/resource_fare_bases.yml +3 -1
- data/spec/support/cassettes/resource_show.yml +3 -1
- data/spec/support/cassettes/resource_with_price.yml +3 -1
- data/spec/support/cassettes/settings_basic.yml +3 -1
- data/spec/support/cassettes/tenant_switcher.yml +6 -2
- data/spec/support/cassettes/wrong_url.yml +3 -1
- data/spec/support/coverage_loader.rb +1 -1
- metadata +35 -29
- data/gemfiles/rails4.gemfile +0 -9
data/spec/adapter_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'quick_travel/adapter'
|
3
3
|
|
4
4
|
describe QuickTravel::Adapter do
|
5
|
-
let(:response) { double code: 200, parsed_response: parsed_response }
|
5
|
+
let(:response) { double code: 200, parsed_response: parsed_response, headers: {} }
|
6
6
|
let(:parsed_response) { { test: true } }
|
7
7
|
|
8
8
|
before do
|
@@ -26,8 +26,7 @@ describe QuickTravel::Adapter do
|
|
26
26
|
let(:expected_body) {
|
27
27
|
{
|
28
28
|
test: true,
|
29
|
-
sub_hash: { id: 42 }
|
30
|
-
access_key: an_instance_of(String)
|
29
|
+
sub_hash: { id: 42 }
|
31
30
|
}
|
32
31
|
}
|
33
32
|
|
@@ -52,4 +51,36 @@ describe QuickTravel::Adapter do
|
|
52
51
|
)
|
53
52
|
end
|
54
53
|
end
|
54
|
+
|
55
|
+
context 'when cache options present' do
|
56
|
+
subject(:all) do
|
57
|
+
QuickTravel::Adapter.call_and_validate(:get, 'some_path', {}, { cache_key: 'test_key', cache_options: { expires_in: 3.minutes } })
|
58
|
+
end
|
59
|
+
let(:api) { double }
|
60
|
+
|
61
|
+
before do
|
62
|
+
QuickTravel::Cache.cache_store.clear
|
63
|
+
stub_const('QuickTravel::Api', api)
|
64
|
+
allow(api).to receive(:call_and_validate) { [{id: 1}, {id: 2}] }
|
65
|
+
all
|
66
|
+
end
|
67
|
+
|
68
|
+
specify { expect(api).to have_received(:call_and_validate).once }
|
69
|
+
|
70
|
+
context 'when called again' do
|
71
|
+
before do
|
72
|
+
QuickTravel::Adapter.call_and_validate(:get, 'some_path', {}, { cache_key: 'test_key', cache_options: { expires_in: 3.minutes } })
|
73
|
+
end
|
74
|
+
|
75
|
+
specify { expect(api).to have_received(:call_and_validate).once } # not called again
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when called with different key' do
|
79
|
+
before do
|
80
|
+
QuickTravel::Adapter.call_and_validate(:get, 'some_path', {}, { cache_key: 'test_key1', cache_options: { expires_in: 3.minutes } })
|
81
|
+
end
|
82
|
+
|
83
|
+
specify { expect(api).to have_received(:call_and_validate).twice }
|
84
|
+
end
|
85
|
+
end
|
55
86
|
end
|
data/spec/booking_spec.rb
CHANGED
@@ -207,3 +207,13 @@ describe QuickTravel::Booking, "when booking doesn't exist" do
|
|
207
207
|
end
|
208
208
|
end
|
209
209
|
end
|
210
|
+
|
211
|
+
describe QuickTravel::Booking, "#customer_comments" do
|
212
|
+
let(:booking) { QuickTravel::Booking.find(333536) }
|
213
|
+
|
214
|
+
it 'should return customer comments' do
|
215
|
+
VCR.use_cassette('booking_with_comments') do
|
216
|
+
expect(booking.customer_comments).to eq 'I hate this'
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
data/spec/checkout_spec.rb
CHANGED
@@ -12,186 +12,4 @@ describe QuickTravel::Checkout do
|
|
12
12
|
expect(token.keys).to eq [:client_token]
|
13
13
|
expect(token[:client_token]).to match /^[0-9A-Za-z\=]+$/
|
14
14
|
end
|
15
|
-
|
16
|
-
context 'Modern Opal Pay' do
|
17
|
-
context 'failed payment' do
|
18
|
-
let!(:booking) {
|
19
|
-
VCR.use_cassette('opal_modern_pay_failed_booking') do
|
20
|
-
QuickTravel.config.version = 4
|
21
|
-
QuickTravel::Booking.create
|
22
|
-
end
|
23
|
-
}
|
24
|
-
let(:create_payment_request) {
|
25
|
-
{
|
26
|
-
booking_id: booking.id,
|
27
|
-
payment: {
|
28
|
-
payment_type_id: 10,
|
29
|
-
amount_in_cents: 10,
|
30
|
-
uid: 'modern-opal-failed-uid',
|
31
|
-
comment: 'Test Opal Payment'
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
let!(:create_payment_response) {
|
37
|
-
VCR.use_cassette('opal_modern_pay_failed_create') do
|
38
|
-
QuickTravel::Checkout.create(create_payment_request)
|
39
|
-
end
|
40
|
-
}
|
41
|
-
|
42
|
-
let(:update_payment_request) {
|
43
|
-
{
|
44
|
-
gateway_response: {
|
45
|
-
raw_response: '{
|
46
|
-
"CardNumber": 3085227007682330,
|
47
|
-
"CardBalance": 6546,
|
48
|
-
"CardSequenceNumber": 55,
|
49
|
-
"CILAmount": 0,
|
50
|
-
"AuthorizedAmount": 890,
|
51
|
-
"SalesReferenceNumber": 53183943,
|
52
|
-
"TransactionDTM": "2018-01-04T09:00:43.106",
|
53
|
-
"VoidTransactionReferenceNumber": 1271099697,
|
54
|
-
"CardBlockState": false,
|
55
|
-
"AutoloadAmount": 0
|
56
|
-
}',
|
57
|
-
meta_data: {
|
58
|
-
applicationInstanceId: 101166,
|
59
|
-
operatorId: 'an_operator'
|
60
|
-
},
|
61
|
-
success: false
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
let(:update_payment_response) {
|
67
|
-
VCR.use_cassette('opal_modern_pay_failed_update') do
|
68
|
-
QuickTravel::Checkout.update(create_payment_response.id, update_payment_request)
|
69
|
-
end
|
70
|
-
}
|
71
|
-
|
72
|
-
let(:expected_create_attributes) { { completable: false } }
|
73
|
-
let(:expected_update_attributes) { { successful: false } }
|
74
|
-
it 'should update correctly' do
|
75
|
-
expect(create_payment_response).to have_attributes(expected_create_attributes)
|
76
|
-
expect(update_payment_response).to have_attributes(expected_update_attributes)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context 'successful payment' do
|
81
|
-
let!(:booking) {
|
82
|
-
VCR.use_cassette('opal_modern_pay_successful_booking') do
|
83
|
-
QuickTravel.config.version = 4
|
84
|
-
QuickTravel::Booking.create
|
85
|
-
end
|
86
|
-
}
|
87
|
-
let(:payment_create_request) {
|
88
|
-
{
|
89
|
-
booking_id: booking.id,
|
90
|
-
payment: {
|
91
|
-
payment_type_id: 10,
|
92
|
-
amount_in_cents: 10,
|
93
|
-
uid: 'modern-opal-uid',
|
94
|
-
comment: 'Test Opal Payment'
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
let!(:create_payment_response) {
|
100
|
-
VCR.use_cassette('opal_modern_pay_successful_response') do
|
101
|
-
QuickTravel::Checkout.create(payment_create_request)
|
102
|
-
end
|
103
|
-
}
|
104
|
-
|
105
|
-
let(:update_payment_request) {
|
106
|
-
{
|
107
|
-
gateway_response: {
|
108
|
-
raw_response: '{
|
109
|
-
"CardNumber": 3085227007682330,
|
110
|
-
"CardBalance": 6546,
|
111
|
-
"CardSequenceNumber": 55,
|
112
|
-
"CILAmount": 0,
|
113
|
-
"AuthorizedAmount": 890,
|
114
|
-
"SalesReferenceNumber": 53183943,
|
115
|
-
"TransactionDTM": "2018-01-04T09:00:43.106",
|
116
|
-
"TransactionReferenceNumber": 1271099697,
|
117
|
-
"CardBlockState": false,
|
118
|
-
"AutoloadAmount": 0
|
119
|
-
}',
|
120
|
-
meta_data: {
|
121
|
-
applicationInstanceId: 101166,
|
122
|
-
operatorId: 'an_operator'
|
123
|
-
},
|
124
|
-
success: true
|
125
|
-
}
|
126
|
-
}
|
127
|
-
}
|
128
|
-
|
129
|
-
let(:update_payment_response) {
|
130
|
-
VCR.use_cassette('opal_modern_pay_successful_update_response') do
|
131
|
-
QuickTravel::Checkout.update(create_payment_response.id, update_payment_request)
|
132
|
-
end
|
133
|
-
}
|
134
|
-
|
135
|
-
let(:expected_create_attributes) { { completable: false } }
|
136
|
-
let(:expected_update_attributes) { { successful: true } }
|
137
|
-
it 'should update correctly' do
|
138
|
-
expect(create_payment_response).to have_attributes(expected_create_attributes)
|
139
|
-
expect(update_payment_response).to have_attributes(expected_update_attributes)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
context 'Opal Pay' do
|
145
|
-
let(:booking) {
|
146
|
-
VCR.use_cassette('opal_pay_booking') do
|
147
|
-
QuickTravel.config.version = 4
|
148
|
-
QuickTravel::Booking.create
|
149
|
-
end
|
150
|
-
}
|
151
|
-
|
152
|
-
let(:payment_create_request) {
|
153
|
-
{
|
154
|
-
booking_id: booking.id,
|
155
|
-
payment: {
|
156
|
-
gateway_response: '{
|
157
|
-
"CardNumber": 3085227007682330,
|
158
|
-
"CardBalance": 6546,
|
159
|
-
"CardSequenceNumber": 55,
|
160
|
-
"CILAmount": 0,
|
161
|
-
"AuthorizedAmount": 890,
|
162
|
-
"SalesReferenceNumber": 53183943,
|
163
|
-
"TransactionDTM": "2018-01-04T09:00:43.106",
|
164
|
-
"TransactionReferenceNumber": 1271099697,
|
165
|
-
"CardBlockState": false,
|
166
|
-
"AutoloadAmount": 0
|
167
|
-
}',
|
168
|
-
meta_data: {
|
169
|
-
applicationInstanceId: 101166,
|
170
|
-
operatorId: 'an_operator'
|
171
|
-
},
|
172
|
-
payment_type_id: 10,
|
173
|
-
amount_in_cents: 10,
|
174
|
-
uid: 'opal-uid',
|
175
|
-
comment: 'Test Opal Payment'
|
176
|
-
}
|
177
|
-
}
|
178
|
-
}
|
179
|
-
|
180
|
-
subject(:response) {
|
181
|
-
VCR.use_cassette('opal_pay') do
|
182
|
-
QuickTravel::Checkout.create(payment_create_request)
|
183
|
-
end
|
184
|
-
}
|
185
|
-
|
186
|
-
let(:expected_attributes) {
|
187
|
-
{
|
188
|
-
completable: true,
|
189
|
-
completed: true,
|
190
|
-
progress: 'completed',
|
191
|
-
successful: true
|
192
|
-
}
|
193
|
-
}
|
194
|
-
|
195
|
-
it { is_expected.to have_attributes(expected_attributes) }
|
196
|
-
end
|
197
15
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'quick_travel/client'
|
5
|
+
|
6
|
+
describe QuickTravel::Client do
|
7
|
+
context '#find' do
|
8
|
+
let(:templates) do
|
9
|
+
VCR.use_cassette('client_templates') do
|
10
|
+
QuickTravel::Client.find(2).templates
|
11
|
+
end
|
12
|
+
end
|
13
|
+
it 'should find the templates correctly' do
|
14
|
+
expect(templates['vehicle_templates']).to eq([
|
15
|
+
{
|
16
|
+
'id' => 1,
|
17
|
+
'length' => 5.0,
|
18
|
+
'height' => 1.5,
|
19
|
+
'width' => 1.8,
|
20
|
+
'weight' => 1000.0,
|
21
|
+
'details' => 'Holden Commodore',
|
22
|
+
'registration' => 'ABC123',
|
23
|
+
'cargo' => 'None',
|
24
|
+
'vehicle_type_id' => 1,
|
25
|
+
'party_id' => 9
|
26
|
+
}
|
27
|
+
])
|
28
|
+
expect(templates['passenger_templates']).to eq([
|
29
|
+
{
|
30
|
+
'id' => 1,
|
31
|
+
'age' => 30,
|
32
|
+
'title' => 'Mr',
|
33
|
+
'first_name' => 'Homer',
|
34
|
+
'last_name' => 'Simpson',
|
35
|
+
'gender' => 'Male',
|
36
|
+
'passenger_type_id' => 1,
|
37
|
+
'party_id' => 9
|
38
|
+
}
|
39
|
+
])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/discounts_spec.rb
CHANGED
@@ -26,9 +26,9 @@ describe 'Booking price_changes' do
|
|
26
26
|
|
27
27
|
specify { expect(price_change.target.type).to eq 'Booking' }
|
28
28
|
specify { expect(price_change.target.id).to eq booking.id }
|
29
|
-
specify { expect(price_change.original_price).to eq 640.00 }
|
30
|
-
specify { expect(price_change.changed_price).to eq 380.00 }
|
31
|
-
specify { expect(price_change.price_change).to eq(-260.00) }
|
29
|
+
specify { expect(price_change.original_price).to eq 640.00.to_money }
|
30
|
+
specify { expect(price_change.changed_price).to eq 380.00.to_money }
|
31
|
+
specify { expect(price_change.price_change).to eq(-260.00.to_money) }
|
32
32
|
specify do
|
33
33
|
expect(price_change.reservation_price_changes.count).to(
|
34
34
|
eq booking.reservations.count)
|
@@ -43,9 +43,9 @@ describe 'Booking price_changes' do
|
|
43
43
|
|
44
44
|
specify { expect(price_change.target.type).to eq 'Reservation' }
|
45
45
|
specify { expect(price_change.target.id).to eq reservation.id }
|
46
|
-
specify { expect(price_change.original_price).to eq 400.00 }
|
47
|
-
specify { expect(price_change.changed_price).to eq 200.00 }
|
48
|
-
specify { expect(price_change.price_change).to eq(-200) }
|
46
|
+
specify { expect(price_change.original_price).to eq 400.00.to_money }
|
47
|
+
specify { expect(price_change.changed_price).to eq 200.00.to_money }
|
48
|
+
specify { expect(price_change.price_change).to eq(-200.to_money) }
|
49
49
|
end
|
50
50
|
|
51
51
|
context 'the total price_change applied on the top level reservation' do
|
@@ -57,9 +57,9 @@ describe 'Booking price_changes' do
|
|
57
57
|
|
58
58
|
specify { expect(price_change.target.type).to eq 'Reservation' }
|
59
59
|
specify { expect(price_change.target.id).to eq reservation.id }
|
60
|
-
specify { expect(price_change.original_price).to eq 640.00 }
|
61
|
-
specify { expect(price_change.changed_price).to eq 380.00 }
|
62
|
-
specify { expect(price_change.price_change).to eq(-260.00) }
|
60
|
+
specify { expect(price_change.original_price).to eq 640.00.to_money }
|
61
|
+
specify { expect(price_change.changed_price).to eq 380.00.to_money }
|
62
|
+
specify { expect(price_change.price_change).to eq(-260.00.to_money) }
|
63
63
|
end
|
64
64
|
|
65
65
|
context 'the price_change applied on the first extra pick' do
|
@@ -71,9 +71,9 @@ describe 'Booking price_changes' do
|
|
71
71
|
|
72
72
|
specify { expect(price_change.target.type).to eq 'Reservation' }
|
73
73
|
specify { expect(price_change.target.id).to eq extra_pick_without_price_change.id }
|
74
|
-
specify { expect(price_change.original_price).to eq 120 }
|
75
|
-
specify { expect(price_change.changed_price).to eq 120 }
|
76
|
-
specify { expect(price_change.price_change).to eq 0 }
|
74
|
+
specify { expect(price_change.original_price).to eq 120.to_money }
|
75
|
+
specify { expect(price_change.changed_price).to eq 120.to_money }
|
76
|
+
specify { expect(price_change.price_change).to eq 0.to_money }
|
77
77
|
end
|
78
78
|
|
79
79
|
context 'the total price_change applied on the first extra pick' do
|
@@ -85,9 +85,9 @@ describe 'Booking price_changes' do
|
|
85
85
|
|
86
86
|
specify { expect(price_change.target.type).to eq 'Reservation' }
|
87
87
|
specify { expect(price_change.target.id).to eq extra_pick_without_price_change.id }
|
88
|
-
specify { expect(price_change.original_price).to eq 120 }
|
89
|
-
specify { expect(price_change.changed_price).to eq 120 }
|
90
|
-
specify { expect(price_change.price_change).to eq 0 }
|
88
|
+
specify { expect(price_change.original_price).to eq 120.to_money }
|
89
|
+
specify { expect(price_change.changed_price).to eq 120.to_money }
|
90
|
+
specify { expect(price_change.price_change).to eq 0.to_money }
|
91
91
|
end
|
92
92
|
|
93
93
|
context 'the price_change applied on second extra pick' do
|
@@ -99,9 +99,9 @@ describe 'Booking price_changes' do
|
|
99
99
|
|
100
100
|
specify { expect(price_change.target.type).to eq 'Reservation' }
|
101
101
|
specify { expect(price_change.target.id).to eq extra_pick_with_price_change.id }
|
102
|
-
specify { expect(price_change.original_price).to eq 120.00 }
|
103
|
-
specify { expect(price_change.changed_price).to eq 60.00 }
|
104
|
-
specify { expect(price_change.price_change).to eq(-60.00) }
|
102
|
+
specify { expect(price_change.original_price).to eq 120.00.to_money }
|
103
|
+
specify { expect(price_change.changed_price).to eq 60.00.to_money }
|
104
|
+
specify { expect(price_change.price_change).to eq(-60.00.to_money) }
|
105
105
|
end
|
106
106
|
|
107
107
|
context 'the total price_change applied on second extra pick' do
|
@@ -113,9 +113,9 @@ describe 'Booking price_changes' do
|
|
113
113
|
|
114
114
|
specify { expect(price_change.target.type).to eq 'Reservation' }
|
115
115
|
specify { expect(price_change.target.id).to eq extra_pick_with_price_change.id }
|
116
|
-
specify { expect(price_change.original_price).to eq 120.00 }
|
117
|
-
specify { expect(price_change.changed_price).to eq 60.00 }
|
118
|
-
specify { expect(price_change.price_change).to eq(-60.00) }
|
116
|
+
specify { expect(price_change.original_price).to eq 120.00.to_money }
|
117
|
+
specify { expect(price_change.changed_price).to eq 60.00.to_money }
|
118
|
+
specify { expect(price_change.price_change).to eq(-60.00.to_money) }
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'quick_travel/package'
|
3
|
+
|
4
|
+
describe QuickTravel::Package do
|
5
|
+
subject(:package) {
|
6
|
+
VCR.use_cassette('package_show') do
|
7
|
+
QuickTravel::Package.find(464)
|
8
|
+
end
|
9
|
+
}
|
10
|
+
|
11
|
+
its(:name) { should eq 'Swan Valley Gourmet Wine Cruise (SVGWC-0945)' }
|
12
|
+
its(:type) { should eq 'Package' }
|
13
|
+
|
14
|
+
|
15
|
+
context '#product_type' do
|
16
|
+
subject(:property_type) {
|
17
|
+
VCR.use_cassette 'package_show_product_type' do
|
18
|
+
package.product_type
|
19
|
+
end
|
20
|
+
}
|
21
|
+
|
22
|
+
its(:name) { should eq 'Rottnest Packages' }
|
23
|
+
end
|
24
|
+
end
|
data/spec/passenger_type_spec.rb
CHANGED
@@ -39,7 +39,7 @@ describe QuickTravel::PassengerType do
|
|
39
39
|
|
40
40
|
before do
|
41
41
|
stub_const('QuickTravel::Api', api)
|
42
|
-
allow(api).to receive(:call_and_validate) { [{id: 1}, {id: 2}] }
|
42
|
+
allow(api).to receive(:call_and_validate) { double(parsed_response: [{id: 1}, {id: 2}], headers: {}) }
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'when called the first time' do
|
@@ -127,6 +127,17 @@ describe QuickTravel::ProductConfiguration do
|
|
127
127
|
let(:pricing_details) { nil }
|
128
128
|
it { is_expected.not_to be_priced }
|
129
129
|
end
|
130
|
+
|
131
|
+
context 'when pricing details are omitted' do
|
132
|
+
let(:product) do
|
133
|
+
double(
|
134
|
+
extras: extras,
|
135
|
+
available?: available
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
it { is_expected.not_to be_priced }
|
140
|
+
end
|
130
141
|
end
|
131
142
|
|
132
143
|
context '#price' do
|
data/spec/reservation_spec.rb
CHANGED
@@ -48,3 +48,23 @@ describe QuickTravel::Reservation do
|
|
48
48
|
expect(@reservation.gross_including_packaged_item).to be_an_instance_of Money
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
describe QuickTravel::Reservation do
|
53
|
+
before(:each) do
|
54
|
+
VCR.use_cassette('reservation_with_extra_picks') do
|
55
|
+
@booking = QuickTravel::Booking.find(1)
|
56
|
+
@reservation = @booking.reservations.first
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should convert hash to objects' do
|
61
|
+
expect(@reservation.passenger_splits.first).to be_an_instance_of QuickTravel::PassengerSplit
|
62
|
+
end
|
63
|
+
|
64
|
+
let(:test_type) { double(name: 'test') }
|
65
|
+
|
66
|
+
it 'should not raise error in passenger count' do
|
67
|
+
allow(QuickTravel::PassengerType).to receive(:find).and_return(test_type)
|
68
|
+
expect{ @reservation.passengers_count(@booking) }.not_to raise_error
|
69
|
+
end
|
70
|
+
end
|