ticketevolution-ruby 0.7.11 → 0.7.16
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ext/hash.rb +1 -0
- data/lib/faraday/localhost_header.rb +36 -0
- data/lib/ticket_evolution.rb +15 -1
- data/lib/ticket_evolution/accounts/transactions.rb +8 -0
- data/lib/ticket_evolution/address.rb +4 -0
- data/lib/ticket_evolution/clients.rb +4 -0
- data/lib/ticket_evolution/clients/addresses.rb +14 -0
- data/lib/ticket_evolution/clients/credit_cards.rb +2 -0
- data/lib/ticket_evolution/core/collection.rb +5 -3
- data/lib/ticket_evolution/core/connection.rb +3 -0
- data/lib/ticket_evolution/core/model.rb +1 -0
- data/lib/ticket_evolution/core/model/parental_behavior.rb +3 -1
- data/lib/ticket_evolution/modules/destroy.rb +1 -1
- data/lib/ticket_evolution/offices/credit_cards.rb +10 -0
- data/lib/ticket_evolution/order.rb +8 -0
- data/lib/ticket_evolution/orders.rb +27 -0
- data/lib/ticket_evolution/orders/payments.rb +8 -0
- data/lib/ticket_evolution/payment.rb +4 -0
- data/lib/ticket_evolution/service_fee.rb +4 -0
- data/lib/ticket_evolution/settings.rb +42 -0
- data/lib/ticket_evolution/shipping_setting.rb +4 -0
- data/lib/ticket_evolution/taken_ticket.rb +4 -0
- data/lib/ticket_evolution/{transactions.rb → taken_tickets.rb} +1 -2
- data/lib/ticket_evolution/ticket_group.rb +15 -0
- data/lib/ticket_evolution/ticket_groups.rb +30 -0
- data/lib/ticket_evolution/ticket_groups/ticket_holds.rb +7 -0
- data/lib/ticket_evolution/ticket_hold.rb +4 -0
- data/lib/ticket_evolution/version.rb +1 -1
- data/spec/fixtures/fake.rb +30 -0
- data/spec/fixtures/net/endpoints/settings.yml +80 -0
- data/spec/fixtures/net/endpoints/settings_service_fees.yml +41 -0
- data/spec/lib/ext/hash_spec.rb +9 -0
- data/spec/lib/faraday/localhost_header_spec.rb +61 -0
- data/spec/lib/ticket_evolution/{transactions_spec.rb → accounts/transactions_spec.rb} +2 -2
- data/spec/lib/ticket_evolution/clients/addresses_spec.rb +13 -0
- data/spec/lib/ticket_evolution/clients_spec.rb +11 -0
- data/spec/lib/ticket_evolution/core/collection_spec.rb +79 -29
- data/spec/lib/ticket_evolution/core/model_spec.rb +6 -0
- data/spec/lib/ticket_evolution/offices/credit_cards_spec.rb +12 -0
- data/spec/lib/ticket_evolution/orders/payments_spec.rb +10 -0
- data/spec/lib/ticket_evolution/orders_spec.rb +11 -0
- data/spec/lib/ticket_evolution/payment_spec.rb +7 -0
- data/spec/lib/ticket_evolution/service_fee_spec.rb +7 -0
- data/spec/lib/ticket_evolution/settings_spec.rb +32 -0
- data/spec/lib/ticket_evolution/shipping_setting_spec.rb +7 -0
- data/spec/lib/ticket_evolution/taken_tickets_spec.rb +12 -0
- data/spec/lib/ticket_evolution/ticket_group_spec.rb +41 -0
- data/spec/lib/ticket_evolution/ticket_groups/ticket_holds_spec.rb +9 -0
- data/spec/lib/ticket_evolution/ticket_groups_spec.rb +45 -0
- data/spec/lib/ticket_evolution/ticket_hold_spec.rb +7 -0
- data/spec/shared_examples/endpoints/destroy.rb +0 -1
- metadata +61 -26
data/spec/fixtures/fake.rb
CHANGED
@@ -79,6 +79,36 @@ class Fake
|
|
79
79
|
r
|
80
80
|
end
|
81
81
|
|
82
|
+
def self.list_response_with_unique_categories
|
83
|
+
r = self.response
|
84
|
+
r.body = {
|
85
|
+
:connection => Fake.connection,
|
86
|
+
"current_page" => 1,
|
87
|
+
"per_page" => 2,
|
88
|
+
"brokerages" => [
|
89
|
+
{
|
90
|
+
"url" => "/brokerages/1",
|
91
|
+
"updated_at" => "2011-12-18T19:06:19Z",
|
92
|
+
"natb_member" => true,
|
93
|
+
"name" => "National Event Company",
|
94
|
+
"id" => "1",
|
95
|
+
"abbreviation" => "NECO"
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"url" => "/brokerages/2",
|
99
|
+
"updated_at" => "2011-12-18T17:30:06Z",
|
100
|
+
"natb_member" => true,
|
101
|
+
"name" => "Golden Tickets",
|
102
|
+
"id" => "2",
|
103
|
+
"abbreviation" => "Golden Tickets"
|
104
|
+
}
|
105
|
+
],
|
106
|
+
"total_entries" => 1379,
|
107
|
+
"unique_categories" => [1,2,3,4,5]
|
108
|
+
}
|
109
|
+
r
|
110
|
+
end
|
111
|
+
|
82
112
|
def self.create_response(endpoint = nil, connection = Fake.connection, number = 1)
|
83
113
|
r = self.response
|
84
114
|
r.body = {
|
@@ -0,0 +1,80 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: https://api.sandbox.ticketevolution.com:443/settings/shipping
|
6
|
+
body: !!null
|
7
|
+
headers:
|
8
|
+
x-signature:
|
9
|
+
- WHd27OtPC4QiHuQvUCzFcPqNghgmfGbro1i6U3pVFPI=
|
10
|
+
x-token:
|
11
|
+
- b2b5a7a33b1a78896ed1b53d81c5c9cc
|
12
|
+
accept:
|
13
|
+
- application/vnd.ticketevolution.api+json; version=8
|
14
|
+
accept-encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
response: !ruby/struct:VCR::Response
|
17
|
+
status: !ruby/struct:VCR::ResponseStatus
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
content-type:
|
22
|
+
- application/vnd.ticketevolution.api+json; version=8; charset=utf-8
|
23
|
+
transfer-encoding:
|
24
|
+
- chunked
|
25
|
+
status:
|
26
|
+
- '200'
|
27
|
+
x-powered-by:
|
28
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.11
|
29
|
+
etag:
|
30
|
+
- ! '"6112da850ca26595698e455adafcae04"'
|
31
|
+
cache-control:
|
32
|
+
- max-age=0, private, must-revalidate
|
33
|
+
x-runtime:
|
34
|
+
- '0.043076'
|
35
|
+
x-ua-compatible:
|
36
|
+
- IE=Edge,chrome=1
|
37
|
+
server:
|
38
|
+
- nginx/1.0.14 + Phusion Passenger 3.0.11 (mod_rails/mod_rack)
|
39
|
+
body: ! '{"settings":[]}'
|
40
|
+
http_version: '1.1'
|
41
|
+
- !ruby/struct:VCR::HTTPInteraction
|
42
|
+
request: !ruby/struct:VCR::Request
|
43
|
+
method: :get
|
44
|
+
uri: https://api.sandbox.ticketevolution.com:443/settings/service_fees
|
45
|
+
body: !!null
|
46
|
+
headers:
|
47
|
+
x-signature:
|
48
|
+
- Vh5xP6gw/jnKg50wEAOniiNeSxL50Uksg1LYFFkFmpg=
|
49
|
+
x-token:
|
50
|
+
- b2b5a7a33b1a78896ed1b53d81c5c9cc
|
51
|
+
accept:
|
52
|
+
- application/vnd.ticketevolution.api+json; version=8
|
53
|
+
accept-encoding:
|
54
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
55
|
+
response: !ruby/struct:VCR::Response
|
56
|
+
status: !ruby/struct:VCR::ResponseStatus
|
57
|
+
code: 404
|
58
|
+
message: Not Found
|
59
|
+
headers:
|
60
|
+
content-type:
|
61
|
+
- application/vnd.ticketevolution.api+json; version=8; charset=utf-8
|
62
|
+
transfer-encoding:
|
63
|
+
- chunked
|
64
|
+
status:
|
65
|
+
- '404'
|
66
|
+
x-powered-by:
|
67
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.11
|
68
|
+
x-runtime:
|
69
|
+
- '0.031390'
|
70
|
+
cache-control:
|
71
|
+
- no-cache
|
72
|
+
x-ua-compatible:
|
73
|
+
- IE=Edge,chrome=1
|
74
|
+
server:
|
75
|
+
- nginx/1.0.14 + Phusion Passenger 3.0.11 (mod_rails/mod_rack)
|
76
|
+
set-cookie:
|
77
|
+
- SERVERID=app001.sandbox; path=/
|
78
|
+
body: ! '{"error":"The endpoint you requested doesn''t exist. You may have mistyped
|
79
|
+
the address or the resource may have moved."}'
|
80
|
+
http_version: '1.1'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: https://api.sandbox.ticketevolution.com:443/settings/service_fees
|
6
|
+
body: !!null
|
7
|
+
headers:
|
8
|
+
x-signature:
|
9
|
+
- Vh5xP6gw/jnKg50wEAOniiNeSxL50Uksg1LYFFkFmpg=
|
10
|
+
x-token:
|
11
|
+
- b2b5a7a33b1a78896ed1b53d81c5c9cc
|
12
|
+
accept:
|
13
|
+
- application/vnd.ticketevolution.api+json; version=8
|
14
|
+
accept-encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
response: !ruby/struct:VCR::Response
|
17
|
+
status: !ruby/struct:VCR::ResponseStatus
|
18
|
+
code: 404
|
19
|
+
message: Not Found
|
20
|
+
headers:
|
21
|
+
content-type:
|
22
|
+
- application/vnd.ticketevolution.api+json; version=8; charset=utf-8
|
23
|
+
transfer-encoding:
|
24
|
+
- chunked
|
25
|
+
status:
|
26
|
+
- '404'
|
27
|
+
x-powered-by:
|
28
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.11
|
29
|
+
x-runtime:
|
30
|
+
- '0.032803'
|
31
|
+
cache-control:
|
32
|
+
- no-cache
|
33
|
+
x-ua-compatible:
|
34
|
+
- IE=Edge,chrome=1
|
35
|
+
server:
|
36
|
+
- nginx/1.0.14 + Phusion Passenger 3.0.11 (mod_rails/mod_rack)
|
37
|
+
set-cookie:
|
38
|
+
- SERVERID=app001.sandbox; path=/
|
39
|
+
body: ! '{"error":"The endpoint you requested doesn''t exist. You may have mistyped
|
40
|
+
the address or the resource may have moved."}'
|
41
|
+
http_version: '1.1'
|
data/spec/lib/ext/hash_spec.rb
CHANGED
@@ -24,5 +24,14 @@ describe 'Hash' do
|
|
24
24
|
keys = ordered_hash.keys.clone
|
25
25
|
keys.sort_by{|x|x.to_s}.should == ordered_hash.keys
|
26
26
|
end
|
27
|
+
|
28
|
+
context "when a value is an array" do
|
29
|
+
let(:hash) { { :one => [2, 3, 1], :two => ['b', 'a', 'c'] } }
|
30
|
+
|
31
|
+
it "should sort the array" do
|
32
|
+
ordered_hash[:one].should == [1, 2, 3]
|
33
|
+
ordered_hash[:two].should == ['a', 'b', 'c']
|
34
|
+
end
|
35
|
+
end
|
27
36
|
end
|
28
37
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rspec/autorun'
|
2
|
+
require 'faraday/localhost_header'
|
3
|
+
require 'uri'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
describe FaradayLocalhostHeader do
|
7
|
+
let(:url) { URI("http://#{hostname}:8080/hello") }
|
8
|
+
let(:patterns) do
|
9
|
+
[ /(?:^|\.)lvh\.me$/i, /(?:^|\.)((?:\d+\.){4})xip\.io$/i ]
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:env) do
|
13
|
+
{ :url => url, :request_headers => {} }
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:app) do
|
17
|
+
described_class.new lambda {|env| env }, patterns
|
18
|
+
end
|
19
|
+
|
20
|
+
subject do
|
21
|
+
result_env = app.call env
|
22
|
+
OpenStruct.new :url => result_env[:url].to_s,
|
23
|
+
:host_header => result_env[:request_headers]['Host']
|
24
|
+
end
|
25
|
+
|
26
|
+
context "normal domain" do
|
27
|
+
let(:hostname) { 'example.com' }
|
28
|
+
its(:url) { should eq('http://example.com:8080/hello') }
|
29
|
+
its(:host_header) { should be_nil }
|
30
|
+
end
|
31
|
+
|
32
|
+
context "using lvh.me" do
|
33
|
+
let(:hostname) { 'lvh.me' }
|
34
|
+
its(:url) { should eq('http://127.0.0.1:8080/hello') }
|
35
|
+
its(:host_header) { should eq('lvh.me') }
|
36
|
+
end
|
37
|
+
|
38
|
+
context "using lvh.me with subdomains" do
|
39
|
+
let(:hostname) { 'api.staging.lvh.me' }
|
40
|
+
its(:url) { should eq('http://127.0.0.1:8080/hello') }
|
41
|
+
its(:host_header) { should eq('api.staging.lvh.me') }
|
42
|
+
end
|
43
|
+
|
44
|
+
context "regular xip.io" do
|
45
|
+
let(:hostname) { 'xip.io' }
|
46
|
+
its(:url) { should eq('http://xip.io:8080/hello') }
|
47
|
+
its(:host_header) { should be_nil }
|
48
|
+
end
|
49
|
+
|
50
|
+
context "xip.io with ip" do
|
51
|
+
let(:hostname) { '10.0.0.1.xip.io' }
|
52
|
+
its(:url) { should eq('http://10.0.0.1:8080/hello') }
|
53
|
+
its(:host_header) { should eq('10.0.0.1.xip.io') }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "xip.io with subdomain" do
|
57
|
+
let(:hostname) { 'api.10.0.0.1.xip.io' }
|
58
|
+
its(:url) { should eq('http://10.0.0.1:8080/hello') }
|
59
|
+
its(:host_header) { should eq('api.10.0.0.1.xip.io') }
|
60
|
+
end
|
61
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TicketEvolution::Transactions do
|
4
|
-
let(:klass) { TicketEvolution::Transactions }
|
3
|
+
describe TicketEvolution::Accounts::Transactions do
|
4
|
+
let(:klass) { TicketEvolution::Accounts::Transactions }
|
5
5
|
let(:single_klass) { TicketEvolution::Transaction }
|
6
6
|
|
7
7
|
it_behaves_like 'a ticket_evolution endpoint class'
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe TicketEvolution::Clients::Addresses do
|
4
4
|
let(:klass) { TicketEvolution::Clients::Addresses }
|
5
5
|
let(:single_klass) { TicketEvolution::Address }
|
6
|
+
let(:instance) { klass.new({:parent => Fake.connection}) }
|
6
7
|
let(:update_base) { {'url' => '/clients/1/addresses/1'} }
|
7
8
|
|
8
9
|
it_behaves_like 'a ticket_evolution endpoint class'
|
@@ -10,4 +11,16 @@ describe TicketEvolution::Clients::Addresses do
|
|
10
11
|
it_behaves_like 'a list endpoint'
|
11
12
|
it_behaves_like 'a show endpoint'
|
12
13
|
it_behaves_like 'an update endpoint'
|
14
|
+
|
15
|
+
describe "#fedex_check" do
|
16
|
+
context "with params" do
|
17
|
+
let(:params) { }
|
18
|
+
|
19
|
+
it "should pass call request as a GET, passing params" do
|
20
|
+
instance.should_receive(:request).with(:GET, "/1/fedex_check", params)
|
21
|
+
instance.fedex_check(1)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
13
26
|
end
|
@@ -33,6 +33,17 @@ describe TicketEvolution::Clients do
|
|
33
33
|
same_client.name.should == name
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
describe '#create_from_office' do
|
38
|
+
use_vcr_cassette 'endpoints/clients/create_from_office'
|
39
|
+
|
40
|
+
let(:instance) { klass.new({ :parent => connection })}
|
41
|
+
|
42
|
+
it "creates a client from a given office_id" do
|
43
|
+
instance.should_receive(:request).with(:POST, '/create_from_office/1', nil)
|
44
|
+
instance.create_from_office({ :office_id => 1})
|
45
|
+
end
|
46
|
+
end
|
36
47
|
end
|
37
48
|
|
38
49
|
describe "chained endpoints" do
|
@@ -2,46 +2,96 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe TicketEvolution::Collection do
|
4
4
|
subject { TicketEvolution::Collection.build_from_response(response, 'brokerages', TicketEvolution::Brokerage) }
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
context "without unique_categories" do
|
6
|
+
let(:response) { Fake.list_response }
|
7
|
+
|
8
|
+
context "#build_from_response" do
|
9
|
+
it { should be_instance_of(TicketEvolution::Collection) }
|
10
|
+
it { should be_kind_of(Enumerable) }
|
11
|
+
its(:per_page) { should == 2 }
|
12
|
+
its(:total_entries) { should == 1379 }
|
13
|
+
its(:current_page) { should == 1 }
|
14
|
+
its(:status_code) { should == 200 }
|
15
|
+
its(:code) { should == 200 }
|
16
|
+
its(:unique_categories) { should be_nil }
|
17
|
+
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
context "#each" do
|
20
|
+
it "iterates through all the entries" do
|
21
|
+
subject.size.should == 2
|
22
|
+
subject.each do |entry|
|
23
|
+
entry.should be_instance_of TicketEvolution::Brokerage
|
24
|
+
end
|
22
25
|
end
|
23
26
|
end
|
24
|
-
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
describe "#last" do
|
29
|
+
it "should pass the request to the @entries array" do
|
30
|
+
subject.entries.should_receive(:last)
|
29
31
|
|
30
|
-
|
32
|
+
subject.last
|
33
|
+
end
|
31
34
|
end
|
32
|
-
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
describe "#all" do
|
37
|
+
it "should alias entries" do
|
38
|
+
subject.all.should == subject.entries
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#[]" do
|
43
|
+
it "should pass the request to the @entries array" do
|
44
|
+
subject.entries.should_receive(:[]).with(1)
|
45
|
+
|
46
|
+
subject[1]
|
47
|
+
end
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
40
|
-
|
41
|
-
|
42
|
-
|
51
|
+
context "with unique_categories" do
|
52
|
+
let(:response) { Fake.list_response_with_unique_categories }
|
53
|
+
|
54
|
+
context "#build_from_response" do
|
55
|
+
it { should be_instance_of(TicketEvolution::Collection) }
|
56
|
+
it { should be_kind_of(Enumerable) }
|
57
|
+
its(:per_page) { should == 2 }
|
58
|
+
its(:total_entries) { should == 1379 }
|
59
|
+
its(:current_page) { should == 1 }
|
60
|
+
its(:status_code) { should == 200 }
|
61
|
+
its(:code) { should == 200 }
|
62
|
+
its(:unique_categories) { should == [1,2,3,4,5] }
|
63
|
+
end
|
64
|
+
|
65
|
+
context "#each" do
|
66
|
+
it "iterates through all the entries" do
|
67
|
+
subject.size.should == 2
|
68
|
+
subject.each do |entry|
|
69
|
+
entry.should be_instance_of TicketEvolution::Brokerage
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#last" do
|
75
|
+
it "should pass the request to the @entries array" do
|
76
|
+
subject.entries.should_receive(:last)
|
43
77
|
|
44
|
-
|
78
|
+
subject.last
|
79
|
+
end
|
45
80
|
end
|
81
|
+
|
82
|
+
describe "#all" do
|
83
|
+
it "should alias entries" do
|
84
|
+
subject.all.should == subject.entries
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#[]" do
|
89
|
+
it "should pass the request to the @entries array" do
|
90
|
+
subject.entries.should_receive(:[]).with(1)
|
91
|
+
|
92
|
+
subject[1]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
46
96
|
end
|
47
97
|
end
|
@@ -111,6 +111,12 @@ describe TicketEvolution::Model do
|
|
111
111
|
instance.endpoint.class.should == instance.plural_class
|
112
112
|
end
|
113
113
|
|
114
|
+
context "when using child_endpoint" do
|
115
|
+
it "should return a child instance" do
|
116
|
+
instance.email_addresses_endpoint.should be_a TicketEvolution::Clients::EmailAddresses
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
114
120
|
context "when this model is a child" do
|
115
121
|
context "which was generated by a call to it's parent" do
|
116
122
|
let(:child) { instance.email_addresses.first }
|