recurly 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of recurly might be problematic. Click here for more details.

Files changed (59) hide show
  1. data/lib/recurly/base.rb +4 -3
  2. data/lib/recurly/version.rb +1 -1
  3. data/spec/integration/billing_info_spec.rb +33 -0
  4. data/spec/vcr/account/accept-language-account/1301979678.yml +4 -4
  5. data/spec/vcr/account/close/1301979678.yml +11 -11
  6. data/spec/vcr/account/create/1301979678.yml +4 -4
  7. data/spec/vcr/account/create-blank/1301979678.yml +2 -2
  8. data/spec/vcr/account/create-duplicate/1301979678.yml +6 -6
  9. data/spec/vcr/account/create-min/1301979678.yml +4 -4
  10. data/spec/vcr/account/find/1301979678.yml +10 -10
  11. data/spec/vcr/account/list/1301979678.yml +74 -74
  12. data/spec/vcr/account/update/1301979678.yml +21 -21
  13. data/spec/vcr/billing/create/{1298594128.yml → 1302025874.yml} +20 -20
  14. data/spec/vcr/billing/destroy/{1298594128.yml → 1302025874.yml} +25 -25
  15. data/spec/vcr/billing/errors/1302025874.yml +126 -0
  16. data/spec/vcr/billing/find/{1298594128.yml → 1302025874.yml} +27 -27
  17. data/spec/vcr/billing/update/{1298594128.yml → 1302025874.yml} +27 -27
  18. data/spec/vcr/charge/create/1297746103.yml +20 -20
  19. data/spec/vcr/charge/delete-uninvoiced/1297746103.yml +23 -23
  20. data/spec/vcr/charge/list-all/1297746103.yml +31 -31
  21. data/spec/vcr/charge/list-invoiced/1297746103.yml +53 -53
  22. data/spec/vcr/charge/list-pending/1297746103.yml +31 -31
  23. data/spec/vcr/charge/lookup/1297746103.yml +16 -16
  24. data/spec/vcr/coupon/create/1299714521.yml +11 -11
  25. data/spec/vcr/coupon/destroy/1299714521.yml +10 -10
  26. data/spec/vcr/credit/create/1299714599.yml +16 -16
  27. data/spec/vcr/credit/delete/1299714599.yml +21 -21
  28. data/spec/vcr/credit/list/1299714599.yml +31 -31
  29. data/spec/vcr/credit/lookup/1299714599.yml +16 -16
  30. data/spec/vcr/invoice/create/1297746103.yml +30 -30
  31. data/spec/vcr/invoice/create-no-charges/1297746103.yml +10 -10
  32. data/spec/vcr/invoice/list/1297746103.yml +45 -45
  33. data/spec/vcr/invoice/lookup/1297746103.yml +32 -32
  34. data/spec/vcr/plan/all.yml +6 -6
  35. data/spec/vcr/plan/find.yml +6 -6
  36. data/spec/vcr/plan/update.yml +6 -6
  37. data/spec/vcr/subscription/addons/add/1301885121.yml +31 -31
  38. data/spec/vcr/subscription/addons/create/1301885121.yml +19 -19
  39. data/spec/vcr/subscription/addons/remove/1301885121.yml +31 -31
  40. data/spec/vcr/subscription/cancel/1301881900.yml +35 -35
  41. data/spec/vcr/subscription/cancel-with-code/1301881900.yml +43 -43
  42. data/spec/vcr/subscription/change1/1301881900.yml +31 -31
  43. data/spec/vcr/subscription/change2/1301881900.yml +31 -31
  44. data/spec/vcr/subscription/create/1301881900.yml +13 -13
  45. data/spec/vcr/subscription/find/1301881900.yml +19 -19
  46. data/spec/vcr/subscription/reactivate/1301881900.yml +36 -36
  47. data/spec/vcr/subscription/refund-full/1301881900.yml +28 -28
  48. data/spec/vcr/subscription/refund-none/1301881900.yml +28 -28
  49. data/spec/vcr/subscription/refund-partial/1301881900.yml +28 -28
  50. data/spec/vcr/transaction/all/1301883347.yml +55 -55
  51. data/spec/vcr/transaction/create-no-account/1301883347.yml +5 -5
  52. data/spec/vcr/transaction/create-with-account/1301883347.yml +13 -13
  53. data/spec/vcr/transaction/list-filled/1301883347.yml +45 -45
  54. data/spec/vcr/transaction/list-initial/1301883347.yml +13 -13
  55. data/spec/vcr/transaction/lookup/1301883347.yml +41 -41
  56. data/spec/vcr/transaction/refund/1301883347.yml +19 -19
  57. data/spec/vcr/transaction/void/1301883347.yml +26 -26
  58. data/spec/vcr/transparent/post-url/1301879142.yml +9 -9
  59. metadata +12 -10
data/lib/recurly/base.rb CHANGED
@@ -105,10 +105,11 @@ module Recurly
105
105
  message = error['message']
106
106
 
107
107
  if field.blank?
108
- errors[:base] << message
108
+ errors.add :base, message
109
+ next
109
110
  end
110
111
 
111
- humanized_name = field.humanize.downcase
112
+ humanized_name = field.to_s.humanize.downcase
112
113
  message = message[(humanized_name.size + 1)..-1] if message[0, humanized_name.size + 1].downcase == "#{humanized_name} "
113
114
 
114
115
  errors.add field.to_sym, message
@@ -121,7 +122,7 @@ module Recurly
121
122
  end
122
123
  end
123
124
 
124
- errors[:base] << message
125
+ errors.add :base, message
125
126
  end
126
127
  end
127
128
  end
@@ -1,3 +1,3 @@
1
1
  module Recurly #:nodoc
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
@@ -111,5 +111,38 @@ module Recurly
111
111
  }.to raise_error ActiveResource::ResourceNotFound
112
112
  end
113
113
  end
114
+
115
+ describe "set the appropriate error" do
116
+ use_vcr_cassette "billing/errors/#{timestamp}"
117
+ let(:account){ Factory.create_account("billing-errors-#{timestamp}") }
118
+
119
+ it "should set an error on base if the card number is blank" do
120
+ @billing_attributes = Factory.billing_attributes({
121
+ :account_code => account.account_code,
122
+ :first_name => account.first_name,
123
+ :last_name => account.last_name,
124
+ :credit_card => {
125
+ :number => '',
126
+ },
127
+ })
128
+
129
+ billing_info = BillingInfo.create(@billing_attributes)
130
+ billing_info.errors[:base].count.should == 1
131
+ end
132
+
133
+ it "should set an error if the card number is invalid" do
134
+ @billing_attributes = Factory.billing_attributes({
135
+ :account_code => account.account_code,
136
+ :first_name => account.first_name,
137
+ :last_name => account.last_name,
138
+ :credit_card => {
139
+ :number => '4000-0000-0000-0002',
140
+ },
141
+ })
142
+
143
+ billing_info = BillingInfo.create(@billing_attributes)
144
+ billing_info.errors.count.should == 1
145
+ end
146
+ end
114
147
  end
115
148
  end
@@ -39,13 +39,13 @@
39
39
  location:
40
40
  - http://app.recurly.local:3000/accounts/account1-french-1301979678
41
41
  x-runtime:
42
- - "410"
42
+ - "653"
43
43
  content-type:
44
44
  - application/xml; charset=utf-8
45
45
  content-length:
46
46
  - "585"
47
47
  set-cookie:
48
- - _recurly_session=78f3d47f16335f1637aae2e1f7a55b58; domain=.recurly.local; path=/; HttpOnly
48
+ - _recurly_session=3f7bb9cdba35677fd3059b70801e498f; domain=.recurly.local; path=/; HttpOnly
49
49
  connection:
50
50
  - close
51
51
  server:
@@ -62,8 +62,8 @@
62
62
  <company_name>Recurly Ruby Gem</company_name>
63
63
  <balance_in_cents type="integer">0</balance_in_cents>
64
64
  <closed type="boolean">false</closed>
65
- <hosted_login_token>72d7a2698291442c9d190fd7964886f1</hosted_login_token>
66
- <created_at type="datetime">2011-04-05T05:13:31Z</created_at>
65
+ <hosted_login_token>d0eeb511e23842c1a0639a4d9c254454</hosted_login_token>
66
+ <created_at type="datetime">2011-04-05T19:39:07Z</created_at>
67
67
  <state>active</state>
68
68
  </account>
69
69
 
@@ -39,13 +39,13 @@
39
39
  location:
40
40
  - http://app.recurly.local:3000/accounts/account-close-1301979678
41
41
  x-runtime:
42
- - "260"
42
+ - "386"
43
43
  content-type:
44
44
  - application/xml; charset=utf-8
45
45
  content-length:
46
46
  - "581"
47
47
  set-cookie:
48
- - _recurly_session=2aaa7892408c6fcc89f7c8af997161f1; domain=.recurly.local; path=/; HttpOnly
48
+ - _recurly_session=959d6d6bc89a68c40355b4640667c18f; domain=.recurly.local; path=/; HttpOnly
49
49
  connection:
50
50
  - close
51
51
  server:
@@ -62,8 +62,8 @@
62
62
  <company_name>Recurly Ruby Gem</company_name>
63
63
  <balance_in_cents type="integer">0</balance_in_cents>
64
64
  <closed type="boolean">false</closed>
65
- <hosted_login_token>1e9adf47b89a4fdda1ae4286c0377655</hosted_login_token>
66
- <created_at type="datetime">2011-04-05T05:13:20Z</created_at>
65
+ <hosted_login_token>51817519b9f04d40b55b7d814d7f0547</hosted_login_token>
66
+ <created_at type="datetime">2011-04-05T19:38:52Z</created_at>
67
67
  <state>active</state>
68
68
  </account>
69
69
 
@@ -90,13 +90,13 @@
90
90
  cache-control:
91
91
  - no-cache
92
92
  x-runtime:
93
- - "280"
93
+ - "674"
94
94
  content-type:
95
95
  - application/xml; charset=utf-8
96
96
  content-length:
97
97
  - "1"
98
98
  set-cookie:
99
- - _recurly_session=66fd174af38f731f69e127e91d43e6d6; domain=.recurly.local; path=/; HttpOnly
99
+ - _recurly_session=1aaf5360a93701ec0b77d38c9b491e61; domain=.recurly.local; path=/; HttpOnly
100
100
  connection:
101
101
  - close
102
102
  server:
@@ -125,17 +125,17 @@
125
125
  message: OK
126
126
  headers:
127
127
  x-runtime:
128
- - "233"
128
+ - "372"
129
129
  content-type:
130
130
  - application/xml; charset=utf-8
131
131
  etag:
132
- - "\"8d3c629b2bdb0b49d4299cd0a9ddf29a\""
132
+ - "\"cf0446d5715951e4cc9666193af16150\""
133
133
  cache-control:
134
134
  - private, max-age=0, must-revalidate
135
135
  content-length:
136
136
  - "580"
137
137
  set-cookie:
138
- - _recurly_session=81d34193a0dc04db21d106606ec1bd05; domain=.recurly.local; path=/; HttpOnly
138
+ - _recurly_session=d2cf4862f501fe9ef038695a160e79ed; domain=.recurly.local; path=/; HttpOnly
139
139
  connection:
140
140
  - close
141
141
  server:
@@ -152,8 +152,8 @@
152
152
  <company_name>Recurly Ruby Gem</company_name>
153
153
  <balance_in_cents type="integer">0</balance_in_cents>
154
154
  <closed type="boolean">true</closed>
155
- <hosted_login_token>1e9adf47b89a4fdda1ae4286c0377655</hosted_login_token>
156
- <created_at type="datetime">2011-04-05T05:13:20Z</created_at>
155
+ <hosted_login_token>51817519b9f04d40b55b7d814d7f0547</hosted_login_token>
156
+ <created_at type="datetime">2011-04-05T19:38:52Z</created_at>
157
157
  <state>closed</state>
158
158
  </account>
159
159
 
@@ -39,13 +39,13 @@
39
39
  location:
40
40
  - http://app.recurly.local:3000/accounts/account-create-1301979678
41
41
  x-runtime:
42
- - "450"
42
+ - "380"
43
43
  content-type:
44
44
  - application/xml; charset=utf-8
45
45
  content-length:
46
46
  - "583"
47
47
  set-cookie:
48
- - _recurly_session=f03efef23b2546f21d2a2eb468d35b40; domain=.recurly.local; path=/; HttpOnly
48
+ - _recurly_session=a6620e8995822e2d0fa1e86a8dd5a30b; domain=.recurly.local; path=/; HttpOnly
49
49
  connection:
50
50
  - close
51
51
  server:
@@ -62,8 +62,8 @@
62
62
  <company_name>Recurly Ruby Gem</company_name>
63
63
  <balance_in_cents type="integer">0</balance_in_cents>
64
64
  <closed type="boolean">false</closed>
65
- <hosted_login_token>ab02259944264bb59259af6a69f917f3</hosted_login_token>
66
- <created_at type="datetime">2011-04-05T05:12:00Z</created_at>
65
+ <hosted_login_token>348c2a6404d541fca19f97711d25bd4d</hosted_login_token>
66
+ <created_at type="datetime">2011-04-05T19:37:25Z</created_at>
67
67
  <state>active</state>
68
68
  </account>
69
69
 
@@ -33,13 +33,13 @@
33
33
  cache-control:
34
34
  - no-cache
35
35
  x-runtime:
36
- - "275"
36
+ - "402"
37
37
  content-type:
38
38
  - application/xml; charset=utf-8
39
39
  content-length:
40
40
  - "186"
41
41
  set-cookie:
42
- - _recurly_session=c20a45e8d0ec88b24423165204a8297d; domain=.recurly.local; path=/; HttpOnly
42
+ - _recurly_session=9111a3a894c1286c22cb1be2db9253ea; domain=.recurly.local; path=/; HttpOnly
43
43
  connection:
44
44
  - close
45
45
  server:
@@ -35,13 +35,13 @@
35
35
  location:
36
36
  - http://app.recurly.local:3000/accounts/account-exists
37
37
  x-runtime:
38
- - "257"
38
+ - "388"
39
39
  content-type:
40
40
  - application/xml; charset=utf-8
41
41
  content-length:
42
42
  - "520"
43
43
  set-cookie:
44
- - _recurly_session=2fff90022fb854f6c5b682d92be61009; domain=.recurly.local; path=/; HttpOnly
44
+ - _recurly_session=2ee91ff89ab5b3f2bbd5992341e4c222; domain=.recurly.local; path=/; HttpOnly
45
45
  connection:
46
46
  - close
47
47
  server:
@@ -58,8 +58,8 @@
58
58
  <company_name></company_name>
59
59
  <balance_in_cents type="integer">0</balance_in_cents>
60
60
  <closed type="boolean">false</closed>
61
- <hosted_login_token>00ddcb8f6a0844a3b07699cd57d812e4</hosted_login_token>
62
- <created_at type="datetime">2011-04-05T05:13:27Z</created_at>
61
+ <hosted_login_token>a3d7cc100f2a4682aaf97c109c39ba9e</hosted_login_token>
62
+ <created_at type="datetime">2011-04-05T19:39:02Z</created_at>
63
63
  <state>active</state>
64
64
  </account>
65
65
 
@@ -98,13 +98,13 @@
98
98
  cache-control:
99
99
  - no-cache
100
100
  x-runtime:
101
- - "277"
101
+ - "669"
102
102
  content-type:
103
103
  - application/xml; charset=utf-8
104
104
  content-length:
105
105
  - "132"
106
106
  set-cookie:
107
- - _recurly_session=0b040a0c74413b49458bf06212f3226a; domain=.recurly.local; path=/; HttpOnly
107
+ - _recurly_session=0e651159e41aa33d2962cd59cb957517; domain=.recurly.local; path=/; HttpOnly
108
108
  connection:
109
109
  - close
110
110
  server:
@@ -35,13 +35,13 @@
35
35
  location:
36
36
  - http://app.recurly.local:3000/accounts/d00d-1301979678
37
37
  x-runtime:
38
- - "253"
38
+ - "381"
39
39
  content-type:
40
40
  - application/xml; charset=utf-8
41
41
  content-length:
42
42
  - "522"
43
43
  set-cookie:
44
- - _recurly_session=94ac70a1a051c64c8745d4e2cd5c4976; domain=.recurly.local; path=/; HttpOnly
44
+ - _recurly_session=d08e4ed31d98adee87b8dca95493a8aa; domain=.recurly.local; path=/; HttpOnly
45
45
  connection:
46
46
  - close
47
47
  server:
@@ -58,8 +58,8 @@
58
58
  <company_name></company_name>
59
59
  <balance_in_cents type="integer">0</balance_in_cents>
60
60
  <closed type="boolean">false</closed>
61
- <hosted_login_token>8738732c3b574f15bccc39cc4c090304</hosted_login_token>
62
- <created_at type="datetime">2011-04-05T05:12:01Z</created_at>
61
+ <hosted_login_token>7dbb7ce567384d84850c138f966a1b15</hosted_login_token>
62
+ <created_at type="datetime">2011-04-05T19:37:28Z</created_at>
63
63
  <state>active</state>
64
64
  </account>
65
65
 
@@ -39,13 +39,13 @@
39
39
  location:
40
40
  - http://app.recurly.local:3000/accounts/account-get-1301979678
41
41
  x-runtime:
42
- - "256"
42
+ - "376"
43
43
  content-type:
44
44
  - application/xml; charset=utf-8
45
45
  content-length:
46
46
  - "577"
47
47
  set-cookie:
48
- - _recurly_session=72ba38c67776bdce7f015ca96d6a696d; domain=.recurly.local; path=/; HttpOnly
48
+ - _recurly_session=66f382336b15626ead04ebb8f9ab5dfd; domain=.recurly.local; path=/; HttpOnly
49
49
  connection:
50
50
  - close
51
51
  server:
@@ -62,8 +62,8 @@
62
62
  <company_name>Recurly Ruby Gem</company_name>
63
63
  <balance_in_cents type="integer">0</balance_in_cents>
64
64
  <closed type="boolean">false</closed>
65
- <hosted_login_token>32e4430c040e4fe9afd45fb12c9004af</hosted_login_token>
66
- <created_at type="datetime">2011-04-05T05:12:03Z</created_at>
65
+ <hosted_login_token>de5c810d258047dea48bc9aeddc2ced0</hosted_login_token>
66
+ <created_at type="datetime">2011-04-05T19:37:30Z</created_at>
67
67
  <state>active</state>
68
68
  </account>
69
69
 
@@ -90,17 +90,17 @@
90
90
  message: OK
91
91
  headers:
92
92
  x-runtime:
93
- - "229"
93
+ - "354"
94
94
  content-type:
95
95
  - application/xml; charset=utf-8
96
96
  etag:
97
- - "\"456629927f3a8df7fcaa92c2e98ebcca\""
97
+ - "\"d7698bb87177b42e48b8f73733a6549a\""
98
98
  cache-control:
99
99
  - private, max-age=0, must-revalidate
100
100
  content-length:
101
101
  - "577"
102
102
  set-cookie:
103
- - _recurly_session=0372cb99b64de8f6ac57187045a52a47; domain=.recurly.local; path=/; HttpOnly
103
+ - _recurly_session=3d05c99afd16003e287668a94ab9c0fe; domain=.recurly.local; path=/; HttpOnly
104
104
  connection:
105
105
  - close
106
106
  server:
@@ -117,8 +117,8 @@
117
117
  <company_name>Recurly Ruby Gem</company_name>
118
118
  <balance_in_cents type="integer">0</balance_in_cents>
119
119
  <closed type="boolean">false</closed>
120
- <hosted_login_token>32e4430c040e4fe9afd45fb12c9004af</hosted_login_token>
121
- <created_at type="datetime">2011-04-05T05:12:03Z</created_at>
120
+ <hosted_login_token>de5c810d258047dea48bc9aeddc2ced0</hosted_login_token>
121
+ <created_at type="datetime">2011-04-05T19:37:30Z</created_at>
122
122
  <state>active</state>
123
123
  </account>
124
124
 
@@ -151,7 +151,7 @@
151
151
  content-length:
152
152
  - "93"
153
153
  set-cookie:
154
- - _recurly_session=55fb191de1c3df427fe600b095eda781; domain=.recurly.local; path=/; HttpOnly
154
+ - _recurly_session=e55def341fa4fd1bde228f64c5143b26; domain=.recurly.local; path=/; HttpOnly
155
155
  connection:
156
156
  - close
157
157
  server: