quicktravel_client 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/.rspec +2 -0
- data/.rubocop.yml +13 -0
- data/.ruby-version +1 -0
- data/.travis.yml +18 -0
- data/Gemfile +5 -0
- data/LICENSE +22 -0
- data/README.md +17 -0
- data/Rakefile +18 -0
- data/bootstrap/boot.rb +4 -0
- data/examples/example_config.rb +4 -0
- data/examples/login_example.rb +25 -0
- data/lib/extensions.rb +12 -0
- data/lib/quick_travel/accommodation.rb +72 -0
- data/lib/quick_travel/adapter.rb +283 -0
- data/lib/quick_travel/adapter_exception.rb +20 -0
- data/lib/quick_travel/address.rb +27 -0
- data/lib/quick_travel/adjustment.rb +8 -0
- data/lib/quick_travel/background_check.rb +9 -0
- data/lib/quick_travel/bed_configuration.rb +7 -0
- data/lib/quick_travel/bed_requirement.rb +7 -0
- data/lib/quick_travel/booking.rb +370 -0
- data/lib/quick_travel/cache.rb +38 -0
- data/lib/quick_travel/client.rb +8 -0
- data/lib/quick_travel/client_type.rb +6 -0
- data/lib/quick_travel/config.rb +26 -0
- data/lib/quick_travel/connection_error.rb +9 -0
- data/lib/quick_travel/constants.rb +16 -0
- data/lib/quick_travel/contact.rb +5 -0
- data/lib/quick_travel/country.rb +11 -0
- data/lib/quick_travel/credit_card.rb +12 -0
- data/lib/quick_travel/discounts/booking_discount.rb +18 -0
- data/lib/quick_travel/discounts/discount.rb +21 -0
- data/lib/quick_travel/discounts/discount_tree.rb +35 -0
- data/lib/quick_travel/discounts.rb +3 -0
- data/lib/quick_travel/document.rb +20 -0
- data/lib/quick_travel/document_group.rb +14 -0
- data/lib/quick_travel/encrypt.rb +13 -0
- data/lib/quick_travel/graphic.rb +18 -0
- data/lib/quick_travel/init_from_hash.rb +16 -0
- data/lib/quick_travel/location.rb +14 -0
- data/lib/quick_travel/mock.rb +41 -0
- data/lib/quick_travel/party.rb +49 -0
- data/lib/quick_travel/passenger.rb +7 -0
- data/lib/quick_travel/passenger_price_break.rb +8 -0
- data/lib/quick_travel/passenger_type.rb +21 -0
- data/lib/quick_travel/payment.rb +41 -0
- data/lib/quick_travel/payment_type.rb +37 -0
- data/lib/quick_travel/price.rb +14 -0
- data/lib/quick_travel/product.rb +165 -0
- data/lib/quick_travel/product_configuration.rb +134 -0
- data/lib/quick_travel/product_passenger_search_criteria.rb +28 -0
- data/lib/quick_travel/product_type.rb +28 -0
- data/lib/quick_travel/property.rb +99 -0
- data/lib/quick_travel/property_facility.rb +7 -0
- data/lib/quick_travel/property_type.rb +20 -0
- data/lib/quick_travel/region.rb +21 -0
- data/lib/quick_travel/reservation.rb +110 -0
- data/lib/quick_travel/resource.rb +50 -0
- data/lib/quick_travel/room_facility.rb +7 -0
- data/lib/quick_travel/route.rb +81 -0
- data/lib/quick_travel/route_stop.rb +7 -0
- data/lib/quick_travel/search.rb +14 -0
- data/lib/quick_travel/service.rb +5 -0
- data/lib/quick_travel/trip.rb +8 -0
- data/lib/quick_travel/vehicle.rb +17 -0
- data/lib/quick_travel/vehicle_type.rb +11 -0
- data/lib/quick_travel/version.rb +3 -0
- data/lib/quick_travel.rb +59 -0
- data/lib/quicktravel_client.rb +1 -0
- data/quicktravel_client.gemspec +37 -0
- data/spec/booking_spec.rb +107 -0
- data/spec/country_spec.rb +18 -0
- data/spec/credit_card_spec.rb +11 -0
- data/spec/discounts_spec.rb +121 -0
- data/spec/passenger_type_spec.rb +32 -0
- data/spec/payment_type_spec.rb +18 -0
- data/spec/product_spec.rb +82 -0
- data/spec/region_spec.rb +29 -0
- data/spec/reservation_spec.rb +50 -0
- data/spec/resource_spec.rb +22 -0
- data/spec/spec_helper.rb +77 -0
- data/spec/support/cassettes/booking_create.yml +50 -0
- data/spec/support/cassettes/booking_create_legacy.yml +50 -0
- data/spec/support/cassettes/booking_discounts.yml +53 -0
- data/spec/support/cassettes/booking_documents.yml +48 -0
- data/spec/support/cassettes/booking_show.yml +49 -0
- data/spec/support/cassettes/booking_update.yml +94 -0
- data/spec/support/cassettes/booking_with_discounts.yml +72 -0
- data/spec/support/cassettes/booking_with_documents.yml +117 -0
- data/spec/support/cassettes/booking_with_nested_attributes.yml +187 -0
- data/spec/support/cassettes/country_all.yml +127 -0
- data/spec/support/cassettes/create_reservation_fail.yml +47 -0
- data/spec/support/cassettes/create_reservation_with_booking.yml +53 -0
- data/spec/support/cassettes/passenger_all.yml +48 -0
- data/spec/support/cassettes/product_date_range_bookability.yml +118 -0
- data/spec/support/cassettes/product_show.yml +52 -0
- data/spec/support/cassettes/region_index.yml +48 -0
- data/spec/support/cassettes/region_show.yml +48 -0
- data/spec/support/cassettes/reservation_with_extra_picks.yml +165 -0
- data/spec/support/cassettes/resource_fare_bases.yml +97 -0
- data/spec/support/cassettes/resource_show.yml +50 -0
- metadata +421 -0
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'quick_travel/reservation'
|
3
|
+
require 'quick_travel/booking'
|
4
|
+
|
5
|
+
describe 'Booking discounts' do
|
6
|
+
let(:booking) do
|
7
|
+
VCR.use_cassette('booking_with_discounts') do
|
8
|
+
QuickTravel::Booking.find_by_reference('222223')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
QuickTravel.config.version = 4
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when the booking has a discount' do
|
17
|
+
let(:reservation) { booking.reservations.first }
|
18
|
+
let(:extra_pick_without_discount) { reservation.sub_reservations.first }
|
19
|
+
let(:extra_pick_with_discount) { reservation.sub_reservations.second }
|
20
|
+
|
21
|
+
let(:discount) do
|
22
|
+
VCR.use_cassette('booking_discounts') do
|
23
|
+
booking.discount
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
specify { expect(discount.target.type).to eq 'Booking' }
|
28
|
+
specify { expect(discount.target.id).to eq booking.id }
|
29
|
+
specify { expect(discount.original_price).to eq 640.00 }
|
30
|
+
specify { expect(discount.discounted_price).to eq 380.00 }
|
31
|
+
specify { expect(discount.discount).to eq(-260.00) }
|
32
|
+
specify do
|
33
|
+
expect(discount.reservation_discounts.count).to(
|
34
|
+
eq booking.reservations.count)
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'the discount applied on the top level reservation' do
|
38
|
+
let(:discount) do
|
39
|
+
VCR.use_cassette('booking_discounts') do
|
40
|
+
booking.discount_on(reservation)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
specify { expect(discount.target.type).to eq 'Reservation' }
|
45
|
+
specify { expect(discount.target.id).to eq reservation.id }
|
46
|
+
specify { expect(discount.original_price).to eq 400.00 }
|
47
|
+
specify { expect(discount.discounted_price).to eq 200.00 }
|
48
|
+
specify { expect(discount.discount).to eq(-200) }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'the total discount applied on the top level reservation' do
|
52
|
+
subject(:discount) do
|
53
|
+
VCR.use_cassette('booking_discounts') do
|
54
|
+
booking.total_discount_on(reservation)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
specify { expect(discount.target.type).to eq 'Reservation' }
|
59
|
+
specify { expect(discount.target.id).to eq reservation.id }
|
60
|
+
specify { expect(discount.original_price).to eq 640.00 }
|
61
|
+
specify { expect(discount.discounted_price).to eq 380.00 }
|
62
|
+
specify { expect(discount.discount).to eq(-260.00) }
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'the discount applied on the first extra pick' do
|
66
|
+
let(:discount) do
|
67
|
+
VCR.use_cassette('booking_discounts') do
|
68
|
+
booking.discount_on(extra_pick_without_discount)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
specify { expect(discount.target.type).to eq 'Reservation' }
|
73
|
+
specify { expect(discount.target.id).to eq extra_pick_without_discount.id }
|
74
|
+
specify { expect(discount.original_price).to eq 120 }
|
75
|
+
specify { expect(discount.discounted_price).to eq 120 }
|
76
|
+
specify { expect(discount.discount).to eq 0 }
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'the total discount applied on the first extra pick' do
|
80
|
+
let(:discount) do
|
81
|
+
VCR.use_cassette('booking_discounts') do
|
82
|
+
booking.total_discount_on(extra_pick_without_discount)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
specify { expect(discount.target.type).to eq 'Reservation' }
|
87
|
+
specify { expect(discount.target.id).to eq extra_pick_without_discount.id }
|
88
|
+
specify { expect(discount.original_price).to eq 120 }
|
89
|
+
specify { expect(discount.discounted_price).to eq 120 }
|
90
|
+
specify { expect(discount.discount).to eq 0 }
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'the discount applied on second extra pick' do
|
94
|
+
let(:discount) do
|
95
|
+
VCR.use_cassette('booking_discounts') do
|
96
|
+
booking.discount_on(extra_pick_with_discount)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
specify { expect(discount.target.type).to eq 'Reservation' }
|
101
|
+
specify { expect(discount.target.id).to eq extra_pick_with_discount.id }
|
102
|
+
specify { expect(discount.original_price).to eq 120.00 }
|
103
|
+
specify { expect(discount.discounted_price).to eq 60.00 }
|
104
|
+
specify { expect(discount.discount).to eq(-60.00) }
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'the total discount applied on second extra pick' do
|
108
|
+
let(:discount) do
|
109
|
+
VCR.use_cassette('booking_discounts') do
|
110
|
+
booking.total_discount_on(extra_pick_with_discount)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
specify { expect(discount.target.type).to eq 'Reservation' }
|
115
|
+
specify { expect(discount.target.id).to eq extra_pick_with_discount.id }
|
116
|
+
specify { expect(discount.original_price).to eq 120.00 }
|
117
|
+
specify { expect(discount.discounted_price).to eq 60.00 }
|
118
|
+
specify { expect(discount.discount).to eq(-60.00) }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'quick_travel/passenger_type'
|
3
|
+
|
4
|
+
describe QuickTravel::PassengerType do
|
5
|
+
context '#all' do
|
6
|
+
subject(:all) do
|
7
|
+
VCR.use_cassette('passenger_all') { QuickTravel::PassengerType.all }
|
8
|
+
end
|
9
|
+
|
10
|
+
its(:class) { should == Array }
|
11
|
+
its(:length) { should == 3 }
|
12
|
+
|
13
|
+
context 'first element' do
|
14
|
+
subject { all.first }
|
15
|
+
its(:class) { should == QuickTravel::PassengerType }
|
16
|
+
its(:name) { should == 'Adult' }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context '#passenger_count_to_s' do
|
21
|
+
subject(:count) { QuickTravel::PassengerType.passenger_counts(hash) }
|
22
|
+
context 'when passengers types have zero counts' do
|
23
|
+
let(:hash) { { 1 => 2, 2 => 1, 3 => 0 } }
|
24
|
+
it { should eq ['2 Adults', '1 Child'] }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when passenger types are not specified' do
|
28
|
+
let(:hash) { { 1 => 2 } }
|
29
|
+
it { should eq ['2 Adults'] }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'quick_travel/payment_type'
|
2
|
+
require 'rspec/its'
|
3
|
+
|
4
|
+
describe QuickTravel::PaymentType do
|
5
|
+
subject(:payment_type) {
|
6
|
+
QuickTravel::PaymentType.new(payment_method: 'credit_card',
|
7
|
+
credit_card_brand: brand) }
|
8
|
+
|
9
|
+
context 'MasterCard' do
|
10
|
+
let(:brand) { 'MasterCard' }
|
11
|
+
its(:code) { should eq 'master_card' }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'American Express' do
|
15
|
+
let(:brand) { 'American Express' }
|
16
|
+
its(:code) { should eq 'american_express' }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'quick_travel/product'
|
3
|
+
|
4
|
+
describe QuickTravel::Product do
|
5
|
+
before do
|
6
|
+
VCR.use_cassette('product_show') do
|
7
|
+
today = '2016-03-01'.to_date
|
8
|
+
@product = QuickTravel::Product.find(6, # Executive Room
|
9
|
+
first_travel_date: today,
|
10
|
+
passenger_type_numbers: { '1' => 1 },
|
11
|
+
date_range: { start_date: today, end_date: today + 1 }
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should create a useful product object' do
|
17
|
+
expect(@product.pricing_details.minimum_price).to eq 400.to_money
|
18
|
+
# @product.pricing_details_for_rack_rate.should_not be_present # TODO: Record new VCRs with new QT code
|
19
|
+
end
|
20
|
+
|
21
|
+
# TODO: Record new VCRs with new QT code
|
22
|
+
# it 'should return a rack minimum price when requested due to agent being logged in' do
|
23
|
+
# VCR.use_cassette('product_show_as_agent') do
|
24
|
+
# today = '2013-02-14'.to_date
|
25
|
+
# @product = QuickTravel::Product.find(195,
|
26
|
+
# first_travel_date: today,
|
27
|
+
# passenger_type_numbers: {'1' => 1},
|
28
|
+
# rack_price_requested: true,
|
29
|
+
# date_range: {start_date: today, end_date: today + 1}
|
30
|
+
# )
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# @product.pricing_details_for_rack_rate.should be_present
|
34
|
+
# end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe QuickTravel::Product do
|
38
|
+
before do
|
39
|
+
VCR.use_cassette('product_date_range_bookability') do
|
40
|
+
@today = '2016-03-01'.to_date
|
41
|
+
@products = QuickTravel::Product.fetch_and_arrange_by_resource_id_and_date(
|
42
|
+
[3, 4, 6],
|
43
|
+
travel_date: @today,
|
44
|
+
duration: 7,
|
45
|
+
default_pax_type_numbers: { '1' => 1 },
|
46
|
+
passenger_type_numbers: { '1' => 2, '2' => 1 }
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'accommodation product today' do
|
52
|
+
subject(:product) { @products[6][@today.to_s] }
|
53
|
+
it { should be_an_instance_of QuickTravel::Product }
|
54
|
+
|
55
|
+
context 'pricing details' do
|
56
|
+
subject(:pricing_details) { product.pricing_details }
|
57
|
+
it { should be_an_instance_of QuickTravel::PricingDetails }
|
58
|
+
|
59
|
+
context 'price per pax type' do
|
60
|
+
let(:price_if_no_breakdown) { pricing_details.price_per_pax_type[0] }
|
61
|
+
it 'should breakdown prices even if just a total' do
|
62
|
+
expect(price_if_no_breakdown).to eq 300.to_money
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'minimum price' do
|
67
|
+
subject(:minimum_price) { pricing_details.minimum_price }
|
68
|
+
it { should eq 300.to_money } # $200 for 2 pax, $100 for extra passenger
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'adjustments' do
|
72
|
+
subject(:adjustments) { pricing_details.adjustments_to_apply }
|
73
|
+
it { should be_an_instance_of Array }
|
74
|
+
|
75
|
+
context 'first adjustment' do
|
76
|
+
subject(:adjustment) { adjustments.first }
|
77
|
+
it { should be_an_instance_of Hash }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/spec/region_spec.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'quick_travel/region'
|
3
|
+
|
4
|
+
describe QuickTravel::Region do
|
5
|
+
describe '#first' do
|
6
|
+
subject { QuickTravel::Region.first }
|
7
|
+
|
8
|
+
it 'should find a first instance of region from QuickTravel' do
|
9
|
+
VCR.use_cassette('region_show') do
|
10
|
+
expect(subject).to be_an_instance_of QuickTravel::Region
|
11
|
+
expect(subject.id).to be_an_instance_of Fixnum
|
12
|
+
expect(subject.name).to be_an_instance_of String
|
13
|
+
expect(subject.location_ids).to be_an_instance_of Array
|
14
|
+
expect(subject.location_ids[0]).to be_an_instance_of Fixnum
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#all' do
|
20
|
+
subject { QuickTravel::Region.all }
|
21
|
+
|
22
|
+
it 'Region.all method should return Array of Regions' do
|
23
|
+
VCR.use_cassette('region_index') do
|
24
|
+
expect(subject).to be_an_instance_of Array
|
25
|
+
expect(subject[0]).to be_an_instance_of QuickTravel::Region
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'quick_travel/reservation'
|
3
|
+
require 'quick_travel/booking'
|
4
|
+
|
5
|
+
describe QuickTravel::Reservation do
|
6
|
+
it 'should create a reservation with a booking' do
|
7
|
+
VCR.use_cassette('create_reservation_with_booking') do
|
8
|
+
reservation = QuickTravel::Reservation.create(
|
9
|
+
resource_id: '4',
|
10
|
+
first_travel_date: '2016-03-01',
|
11
|
+
passenger_types_numbers: { '1' => '2', '2' => '1' }
|
12
|
+
)
|
13
|
+
expect(reservation.booking_id).to eq 9
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should fail to create when no availability' do
|
18
|
+
VCR.use_cassette 'create_reservation_fail' do
|
19
|
+
begin
|
20
|
+
QuickTravel::Reservation.create(
|
21
|
+
resource_id: '4',
|
22
|
+
first_travel_date: '2099-09-10'
|
23
|
+
)
|
24
|
+
rescue QuickTravel::AdapterException => e
|
25
|
+
expect(e.message).to match(/^No services selected for/)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should fetch the sub reservations' do
|
31
|
+
resource_names = nil
|
32
|
+
VCR.use_cassette('reservation_with_extra_picks') do
|
33
|
+
@booking = QuickTravel::Booking.find(1)
|
34
|
+
@reservation = @booking.reservations.first
|
35
|
+
sub_reservations = @reservation.sub_reservations
|
36
|
+
resource_names = sub_reservations.map(&:resource).map(&:name)
|
37
|
+
end
|
38
|
+
expect(resource_names).to eq ['Travel Insurance - Declined', 'QBE Travel Insurance - Policy E']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe QuickTravel::Reservation do
|
43
|
+
before(:each) do
|
44
|
+
@reservation = QuickTravel::Reservation.new(gross_including_packaged_item_in_cents: 265)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should show me the money' do
|
48
|
+
expect(@reservation.gross_including_packaged_item).to be_an_instance_of Money
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'quick_travel/resource'
|
3
|
+
|
4
|
+
describe QuickTravel::Resource do
|
5
|
+
before do
|
6
|
+
VCR.use_cassette('resource_show') do
|
7
|
+
@resource = QuickTravel::Resource.find(6)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should fetch a resource' do
|
12
|
+
expect(@resource.name).to eq 'Executive Room'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should find fare bases of a resource' do
|
16
|
+
VCR.use_cassette('resource_fare_bases') do
|
17
|
+
picks = @resource.sub_resources
|
18
|
+
expect(picks.size).to eq 2
|
19
|
+
expect(picks.map(&:name)).to eq ['QBE Travel Insurance - Policy E', 'Travel Insurance - Declined']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'bundler/setup'
|
10
|
+
|
11
|
+
require 'rspec/its'
|
12
|
+
require 'date' # Needed for stamp
|
13
|
+
require 'stamp' # Some reasons stamp doesn't load automatically?
|
14
|
+
require 'vcr'
|
15
|
+
|
16
|
+
qt_key = ENV['QT_KEY'] || 'test_key'
|
17
|
+
VCR.configure do |c|
|
18
|
+
c.cassette_library_dir = 'spec/support/cassettes'
|
19
|
+
c.default_cassette_options = { match_requests_on: [:method, :uri, :body] }
|
20
|
+
c.filter_sensitive_data('<QT_KEY>') { qt_key }
|
21
|
+
c.hook_into :fakeweb
|
22
|
+
end
|
23
|
+
|
24
|
+
MINIMUM_COVERAGE = 74
|
25
|
+
|
26
|
+
if ENV['COVERAGE']
|
27
|
+
require 'simplecov'
|
28
|
+
require 'simplecov-rcov'
|
29
|
+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
30
|
+
SimpleCov.start do
|
31
|
+
add_filter '/vendor/'
|
32
|
+
add_filter '/spec/'
|
33
|
+
add_group 'lib', 'lib'
|
34
|
+
end
|
35
|
+
SimpleCov.at_exit do
|
36
|
+
SimpleCov.result.format!
|
37
|
+
percent = SimpleCov.result.covered_percent
|
38
|
+
unless percent >= MINIMUM_COVERAGE
|
39
|
+
puts "Coverage must be above #{MINIMUM_COVERAGE}%. It is #{'%.2f' % percent}%"
|
40
|
+
Kernel.exit(1)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
require 'quick_travel/config'
|
46
|
+
QuickTravel.configure do |c|
|
47
|
+
c.url = 'http://0.0.0.0:8080'
|
48
|
+
c.access_key = qt_key
|
49
|
+
end
|
50
|
+
|
51
|
+
require 'quick_travel/connection_error'
|
52
|
+
require 'quick_travel/constants'
|
53
|
+
require 'quick_travel/cache'
|
54
|
+
|
55
|
+
class HashCache
|
56
|
+
def initialize
|
57
|
+
@cache = {}
|
58
|
+
end
|
59
|
+
|
60
|
+
def read(name)
|
61
|
+
@cache[name]
|
62
|
+
end
|
63
|
+
|
64
|
+
def write(name, value)
|
65
|
+
@cache[name] = value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
QuickTravel::Cache.cache_store = HashCache.new
|
70
|
+
|
71
|
+
RSpec.configure do |config|
|
72
|
+
config.run_all_when_everything_filtered = true
|
73
|
+
config.filter_run :focus
|
74
|
+
config.before :each do
|
75
|
+
allow(QuickTravel::Adapter).to receive(:cache) { ActiveSupport::Cache::MemoryStore.new }
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://0.0.0.0:8080/front_office/bookings.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: booking[referral_code_id]=33&access_key=<QT_KEY>
|
9
|
+
headers:
|
10
|
+
content-length:
|
11
|
+
- '0'
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: ! 'OK '
|
16
|
+
headers:
|
17
|
+
p3p:
|
18
|
+
- CP="IDC DSP CAO COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
|
19
|
+
content-type:
|
20
|
+
- application/json; charset=utf-8
|
21
|
+
x-ua-compatible:
|
22
|
+
- IE=Edge,chrome=1
|
23
|
+
etag:
|
24
|
+
- ! '"f4a3881c4477a858ad2157aad8887436"'
|
25
|
+
cache-control:
|
26
|
+
- max-age=0, private, must-revalidate
|
27
|
+
x-request-id:
|
28
|
+
- bf709d73f2c947811bf2ec1153e361ac
|
29
|
+
x-runtime:
|
30
|
+
- '0.410944'
|
31
|
+
date:
|
32
|
+
- Thu, 28 Feb 2013 14:16:26 GMT
|
33
|
+
x-rack-cache:
|
34
|
+
- invalidate, pass
|
35
|
+
server:
|
36
|
+
- WEBrick/1.3.1 (Ruby/2.1.5/2014-11-13)
|
37
|
+
content-length:
|
38
|
+
- '1996'
|
39
|
+
connection:
|
40
|
+
- close
|
41
|
+
set-cookie:
|
42
|
+
- _session_id=c3f5b616d7b0a15b8634d496713152b2; path=/; HttpOnly
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: ! '{"id":3,"state":"new","reference":"222226","public_comments":null,"internal_comments":null,"customer_contact_name":null,"customer_contact_phone":null,"customer_contact_mobile":null,"customer_contact_email":null,"currency_iso_code":"AUD","country_id":14,"post_code":null,"referral_code_id":1,"total_adjustments_in_cents":0,"pre_adjusted_gross_in_cents":0,"nett_in_cents":0,"gross_in_cents":0,"commission_in_cents":0,"balance_in_cents":0,"paid_in_cents":0,"surcharge_in_cents":0,"deposit_in_cents":0,"web_site_name":"SeaLink","promo_code":null,"insurance_offered":false,"deposit_due_on":null,"balance_due_on":null,"first_travel_date":{"_type":"Date","_value":"2013-03-01"},"last_travel_date":null,"complete":true,"reason_not_complete":null,"discardable_in":60,"inactivatable_in":10,"notices":{"currency":["Currency
|
46
|
+
has changed to currency AUD. Please set currency as appropriate."]},"deposit_relevant":false,"passenger_ids":[],"vehicle_ids":[],"reservation_ids":[],"adjustment_ids":[],"todo_items":[],"confirmation_requests":[],"passengers_attributes":[],"vehicles_attributes":[],"reservations_attributes":[],"adjustments_attributes":[],"payments_attributes":[],"payment_types_attributes":[{"id":5,"name":"master","description":"master","payment_method":"credit_card","credit_card_brand":"MasterCard","transaction_fee":"0.0","active":true,"position":2,"surchargeable":false,"for_frequent_traveller_redemption":false,"comment_required":false,"external":true},{"id":4,"name":"visa","description":"visa","payment_method":"credit_card","credit_card_brand":"Visa","transaction_fee":"0.0","active":true,"position":3,"surchargeable":false,"for_frequent_traveller_redemption":false,"comment_required":false,"external":true},{"id":7,"name":"PayPal","description":"Payments
|
47
|
+
made via PayPal account","payment_method":"paypal","credit_card_brand":null,"transaction_fee":"0.0","active":true,"position":6,"surchargeable":false,"for_frequent_traveller_redemption":false,"comment_required":false,"external":true}]}'
|
48
|
+
http_version: '1.1'
|
49
|
+
recorded_at: Thu, 18 Dec 2014 07:33:16 GMT
|
50
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://0.0.0.0:8080/front_office/bookings.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: booking[referral_code_id]=33&access_key=<QT_KEY>
|
9
|
+
headers:
|
10
|
+
content-length:
|
11
|
+
- '0'
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: ! 'OK '
|
16
|
+
headers:
|
17
|
+
p3p:
|
18
|
+
- CP="IDC DSP CAO COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
|
19
|
+
content-type:
|
20
|
+
- application/json; charset=utf-8
|
21
|
+
x-ua-compatible:
|
22
|
+
- IE=Edge,chrome=1
|
23
|
+
etag:
|
24
|
+
- ! '"e1689d2a9cb6912f09c474b86aea54e1"'
|
25
|
+
cache-control:
|
26
|
+
- max-age=0, private, must-revalidate
|
27
|
+
x-request-id:
|
28
|
+
- 720751484abc6fe362e1e0cbba2de330
|
29
|
+
x-runtime:
|
30
|
+
- '0.400131'
|
31
|
+
date:
|
32
|
+
- Thu, 28 Feb 2013 14:16:27 GMT
|
33
|
+
x-rack-cache:
|
34
|
+
- invalidate, pass
|
35
|
+
server:
|
36
|
+
- WEBrick/1.3.1 (Ruby/2.1.5/2014-11-13)
|
37
|
+
content-length:
|
38
|
+
- '1996'
|
39
|
+
connection:
|
40
|
+
- close
|
41
|
+
set-cookie:
|
42
|
+
- _session_id=ae50d83b4e93bef8543f3f64075f38c7; path=/; HttpOnly
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: ! '{"id":4,"state":"new","reference":"222227","public_comments":null,"internal_comments":null,"customer_contact_name":null,"customer_contact_phone":null,"customer_contact_mobile":null,"customer_contact_email":null,"currency_iso_code":"AUD","country_id":14,"post_code":null,"referral_code_id":1,"total_adjustments_in_cents":0,"pre_adjusted_gross_in_cents":0,"nett_in_cents":0,"gross_in_cents":0,"commission_in_cents":0,"balance_in_cents":0,"paid_in_cents":0,"surcharge_in_cents":0,"deposit_in_cents":0,"web_site_name":"SeaLink","promo_code":null,"insurance_offered":false,"deposit_due_on":null,"balance_due_on":null,"first_travel_date":{"_type":"Date","_value":"2013-03-01"},"last_travel_date":null,"complete":true,"reason_not_complete":null,"discardable_in":60,"inactivatable_in":10,"notices":{"currency":["Currency
|
46
|
+
has changed to currency AUD. Please set currency as appropriate."]},"deposit_relevant":false,"passenger_ids":[],"vehicle_ids":[],"reservation_ids":[],"adjustment_ids":[],"todo_items":[],"confirmation_requests":[],"passengers_attributes":[],"vehicles_attributes":[],"reservations_attributes":[],"adjustments_attributes":[],"payments_attributes":[],"payment_types_attributes":[{"id":5,"name":"master","description":"master","payment_method":"credit_card","credit_card_brand":"MasterCard","transaction_fee":"0.0","active":true,"position":2,"surchargeable":false,"for_frequent_traveller_redemption":false,"comment_required":false,"external":true},{"id":4,"name":"visa","description":"visa","payment_method":"credit_card","credit_card_brand":"Visa","transaction_fee":"0.0","active":true,"position":3,"surchargeable":false,"for_frequent_traveller_redemption":false,"comment_required":false,"external":true},{"id":7,"name":"PayPal","description":"Payments
|
47
|
+
made via PayPal account","payment_method":"paypal","credit_card_brand":null,"transaction_fee":"0.0","active":true,"position":6,"surchargeable":false,"for_frequent_traveller_redemption":false,"comment_required":false,"external":true}]}'
|
48
|
+
http_version: '1.1'
|
49
|
+
recorded_at: Thu, 18 Dec 2014 07:33:17 GMT
|
50
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,53 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://0.0.0.0:8080/api/bookings/1/discount.json?
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: access_key=<QT_KEY>
|
9
|
+
headers:
|
10
|
+
content-length:
|
11
|
+
- '0'
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: ! 'OK '
|
16
|
+
headers:
|
17
|
+
p3p:
|
18
|
+
- CP="IDC DSP CAO COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
|
19
|
+
content-type:
|
20
|
+
- application/json; charset=utf-8
|
21
|
+
x-ua-compatible:
|
22
|
+
- IE=Edge,chrome=1
|
23
|
+
etag:
|
24
|
+
- ! '"2a403d410606562f02412577ffa6eb55"'
|
25
|
+
cache-control:
|
26
|
+
- max-age=0, private, must-revalidate
|
27
|
+
x-request-id:
|
28
|
+
- 7df9edb80489b280e505428e9f9c0903
|
29
|
+
x-runtime:
|
30
|
+
- '0.032943'
|
31
|
+
date:
|
32
|
+
- Thu, 28 Feb 2013 14:10:21 GMT
|
33
|
+
x-rack-cache:
|
34
|
+
- miss
|
35
|
+
server:
|
36
|
+
- WEBrick/1.3.1 (Ruby/2.1.5/2014-11-13)
|
37
|
+
content-length:
|
38
|
+
- '1201'
|
39
|
+
connection:
|
40
|
+
- close
|
41
|
+
set-cookie:
|
42
|
+
- _session_id=5d633d455a32553f1ff76d29f7616e48; path=/; HttpOnly
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: ! '{"target":{"type":"Booking","id":1},"original_price_in_cents":64000,"discounted_price_in_cents":38000,"discount_in_cents":-26000,"reason":"Test
|
46
|
+
Discount Hilton and QBE Get Me","reservation_discounts":[{"target":{"type":"Reservation","id":1},"original_price_in_cents":64000,"discounted_price_in_cents":38000,"discount_in_cents":-26000,"reason":"Test
|
47
|
+
Discount Hilton and QBE Get Me","root":{"target":{"type":"Reservation","id":1},"original_price_in_cents":40000,"discounted_price_in_cents":20000,"discount_in_cents":-20000,"reason":"Test
|
48
|
+
Discount Hilton"},"children":[{"target":{"type":"Reservation","id":3},"original_price_in_cents":12000,"discounted_price_in_cents":12000,"discount_in_cents":0,"reason":"","root":{"target":{"type":"Reservation","id":3},"original_price_in_cents":12000,"discounted_price_in_cents":12000,"discount_in_cents":0,"reason":""},"children":[]},{"target":{"type":"Reservation","id":2},"original_price_in_cents":12000,"discounted_price_in_cents":6000,"discount_in_cents":-6000,"reason":"QBE
|
49
|
+
Get Me","root":{"target":{"type":"Reservation","id":2},"original_price_in_cents":12000,"discounted_price_in_cents":6000,"discount_in_cents":-6000,"reason":"QBE
|
50
|
+
Get Me"},"children":[]}]}]}'
|
51
|
+
http_version: '1.1'
|
52
|
+
recorded_at: Thu, 18 Dec 2014 07:27:10 GMT
|
53
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://0.0.0.0:8080/api/bookings/3/documents.json?last_group=true®enerate=false
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: access_key=<QT_KEY>
|
9
|
+
headers:
|
10
|
+
content-length:
|
11
|
+
- '0'
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: ! 'OK '
|
16
|
+
headers:
|
17
|
+
p3p:
|
18
|
+
- CP="IDC DSP CAO COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
|
19
|
+
content-type:
|
20
|
+
- application/json; charset=utf-8
|
21
|
+
x-ua-compatible:
|
22
|
+
- IE=Edge,chrome=1
|
23
|
+
etag:
|
24
|
+
- ! '"d751713988987e9331980363e24189ce"'
|
25
|
+
cache-control:
|
26
|
+
- max-age=0, private, must-revalidate
|
27
|
+
x-request-id:
|
28
|
+
- dda534836aa87de16e4676661b86732d
|
29
|
+
x-runtime:
|
30
|
+
- '0.025246'
|
31
|
+
date:
|
32
|
+
- Thu, 28 Feb 2013 14:16:27 GMT
|
33
|
+
x-rack-cache:
|
34
|
+
- miss
|
35
|
+
server:
|
36
|
+
- WEBrick/1.3.1 (Ruby/2.1.5/2014-11-13)
|
37
|
+
content-length:
|
38
|
+
- '2'
|
39
|
+
connection:
|
40
|
+
- close
|
41
|
+
set-cookie:
|
42
|
+
- _session_id=b6531aad203363dea39988a351a9b961; path=/; HttpOnly
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: ! '[]'
|
46
|
+
http_version: '1.1'
|
47
|
+
recorded_at: Thu, 18 Dec 2014 07:33:16 GMT
|
48
|
+
recorded_with: VCR 2.9.3
|