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 CHANGED
@@ -5,7 +5,7 @@
5
5
  # A client library for interacting with the Fastly web acceleration service
6
6
  class Fastly
7
7
  # The current version of the library
8
- VERSION = "0.96"
8
+ VERSION = "0.97"
9
9
 
10
10
  require 'fastly/fetcher'
11
11
  require 'fastly/client'
@@ -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 list_invoices(year=nil, month=nil)
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
- list = client.get(Fastly::Invoice.list_path(opts))
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
- assert_raise(Fastly::Error) {
27
- customer = @client.get('/current_customer')
28
- }
29
- assert_equal nil, customer
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
- assert_raise(Fastly::Error) {
41
- current_customer = @fastly.current_customer
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
- invoices = @fastly.list_invoices
155
- services = @fastly.list_services
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-1
168
- month = 12 if month == 0
169
-
170
- invoices = @fastly.list_invoices(year, month)
171
- services = @fastly.list_services
172
- begin
173
- customer = @fastly.current_customer
174
- services = services.select { |s| s.customer_id == customer.id }
175
- rescue
176
- end
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
@@ -45,6 +45,7 @@ class FullLoginTest < Test::Unit::TestCase
45
45
  assert_equal customer.id, tmp_customer.id
46
46
 
47
47
  tmp_user = customer.owner
48
+ assert tmp_user
48
49
  assert_equal user.id, tmp_user.id
49
50
  end
50
51
 
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: 203
4
+ hash: 201
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 96
9
- version: "0.96"
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 00:00:00 Z
17
+ date: 2012-01-27 00:00:00 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: json