fastly 0.96 → 0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/fastly.rb +1 -1
- data/lib/fastly/invoice.rb +2 -4
- data/test/api_key_test.rb +7 -8
- data/test/common.rb +13 -32
- data/test/full_login_test.rb +1 -0
- data/test/helper.rb +1 -1
- metadata +4 -4
data/lib/fastly.rb
CHANGED
data/lib/fastly/invoice.rb
CHANGED
@@ -94,15 +94,13 @@ class Fastly
|
|
94
94
|
# If a year and month are passed in returns the invoices for that whole month.
|
95
95
|
#
|
96
96
|
# Otherwise it returns the invoices for the current month so far.
|
97
|
-
def
|
97
|
+
def get_invoice(year=nil, month=nil)
|
98
98
|
opts = {}
|
99
99
|
unless year.nil? || month.nil?
|
100
100
|
opts[:year] = year
|
101
101
|
opts[:month] = month
|
102
102
|
end
|
103
|
-
|
104
|
-
return [] if list.nil?
|
105
|
-
list.map { |hash| Fastly::Invoice.new(hash, self) }
|
103
|
+
get(Fastly::Invoice, opts)
|
106
104
|
end
|
107
105
|
|
108
106
|
end
|
data/test/api_key_test.rb
CHANGED
@@ -23,10 +23,10 @@ class ApiKeyTest < Test::Unit::TestCase
|
|
23
23
|
user = @client.get('/current_user')
|
24
24
|
}
|
25
25
|
assert_equal nil, user
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
assert_equal
|
26
|
+
|
27
|
+
customer = @client.get('/current_customer')
|
28
|
+
assert customer
|
29
|
+
assert_equal @opts[:customer], customer['name']
|
30
30
|
end
|
31
31
|
|
32
32
|
|
@@ -37,10 +37,9 @@ class ApiKeyTest < Test::Unit::TestCase
|
|
37
37
|
}
|
38
38
|
assert_equal nil, current_user
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
assert_equal nil, current_customer
|
40
|
+
customer = @fastly.current_customer
|
41
|
+
assert customer
|
42
|
+
assert_equal @opts[:customer], customer.name
|
44
43
|
end
|
45
44
|
|
46
45
|
|
data/test/common.rb
CHANGED
@@ -150,39 +150,20 @@ module CommonTests
|
|
150
150
|
assert invoice
|
151
151
|
assert invoice.regions
|
152
152
|
assert_equal invoice.service_id, service.id
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
begin
|
157
|
-
customer = @fastly.current_customer
|
158
|
-
services = services.select { |s| s.customer_id == customer.id }
|
159
|
-
rescue
|
160
|
-
end
|
161
|
-
|
162
|
-
assert_equal invoices.size, services.size
|
163
|
-
assert_equal Fastly::Invoice, invoices[0].class
|
164
|
-
assert invoices[0].service_id
|
153
|
+
|
154
|
+
invoice = @fastly.get_invoice
|
155
|
+
assert_equal Fastly::Invoice, invoice.class
|
165
156
|
|
166
157
|
year = Time.now.year
|
167
|
-
month = Time.now.month
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
assert_equal invoices.size, services.size
|
179
|
-
assert_equal Fastly::Invoice, invoices[0].class
|
180
|
-
assert_equal year, invoices[0].start.year
|
181
|
-
assert_equal month, invoices[0].start.month
|
182
|
-
assert_equal 1, invoices[0].start.day
|
183
|
-
assert_equal year, invoices[0].end.year
|
184
|
-
assert_equal month, invoices[0].end.month
|
185
|
-
assert invoices[0].service_id
|
186
|
-
end
|
158
|
+
month = Time.now.month
|
159
|
+
|
160
|
+
invoice = @fastly.get_invoice(year, month)
|
161
|
+
assert_equal Fastly::Invoice, invoice.class
|
162
|
+
assert_equal year, invoice.start.year
|
163
|
+
assert_equal month, invoice.start.month
|
164
|
+
assert_equal 1, invoice.start.day
|
165
|
+
assert_equal year, invoice.end.year
|
166
|
+
assert_equal month, invoice.end.month
|
167
|
+
end
|
187
168
|
|
188
169
|
end
|
data/test/full_login_test.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -7,7 +7,7 @@ def login_opts(mode=:full)
|
|
7
7
|
opts["base_#{what}".to_sym] = ENV[key] if ENV.has_key?(key)
|
8
8
|
end
|
9
9
|
|
10
|
-
required = :full == mode ? [:user, :name, :password, :customer] : [:api_key]
|
10
|
+
required = :full == mode ? [:user, :name, :password, :customer] : [:api_key, :customer]
|
11
11
|
required.each do |what|
|
12
12
|
key ="FASTLY_TEST_#{what.to_s.upcase}"
|
13
13
|
unless ENV.has_key?(key)
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 201
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 97
|
9
|
+
version: "0.97"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Fastly Inc
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-01-
|
17
|
+
date: 2012-01-27 00:00:00 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: json
|