saucy 0.12.2 → 0.12.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/saucy/subscription.rb +14 -8
- data/spec/models/subscription_spec.rb +31 -0
- metadata +88 -125
data/CHANGELOG.md
CHANGED
data/lib/saucy/subscription.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'airbrake'
|
2
|
+
|
1
3
|
module Saucy
|
2
4
|
module Subscription
|
3
5
|
extend ActiveSupport::Concern
|
@@ -228,14 +230,18 @@ module Saucy
|
|
228
230
|
def update_subscriptions!
|
229
231
|
recently_billed = where("next_billing_date <= ?", Time.now)
|
230
232
|
recently_billed.each do |account|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
233
|
+
begin
|
234
|
+
account.subscription_status = account.subscription.status
|
235
|
+
account.next_billing_date = account.subscription.next_billing_date
|
236
|
+
account.save!
|
237
|
+
if account.past_due?
|
238
|
+
BillingMailer.problem(account).deliver!
|
239
|
+
else
|
240
|
+
BillingMailer.receipt(account, account.most_recent_transaction).deliver!
|
241
|
+
Saucy::Notifications.notify_observers("billed", :account => account)
|
242
|
+
end
|
243
|
+
rescue Exception => e
|
244
|
+
Airbrake.notify(e)
|
239
245
|
end
|
240
246
|
end
|
241
247
|
end
|
@@ -307,6 +307,37 @@ describe Account, "with a paid subscription" do
|
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
310
|
+
context "when there is an error" do
|
311
|
+
before(:each) do
|
312
|
+
Airbrake.stubs(:notify => true)
|
313
|
+
@subscription = mock
|
314
|
+
@subscription.stubs(:status).raises(RuntimeError)
|
315
|
+
Account.any_instance.stubs(:subscription).returns(@subscription)
|
316
|
+
end
|
317
|
+
|
318
|
+
it "notifies Airbrake if expiring account notifications fail" do
|
319
|
+
Timecop.travel(subject.next_billing_date + 1.day) do
|
320
|
+
Account.update_subscriptions!
|
321
|
+
Airbrake.should have_received(:notify).once()
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
it "delivers the rest of the emails even if one fails" do
|
326
|
+
Factory(:account,
|
327
|
+
:cardholder_name => "Ralph Robot",
|
328
|
+
:billing_email => "ralph@example.com",
|
329
|
+
:card_number => "4111111111111111",
|
330
|
+
:verification_code => "123",
|
331
|
+
:expiration_month => 5,
|
332
|
+
:expiration_year => 2012,
|
333
|
+
:plan => Factory(:paid_plan))
|
334
|
+
Timecop.travel(subject.next_billing_date + 1.day) do
|
335
|
+
Account.update_subscriptions!
|
336
|
+
@subscription.should have_received(:status).twice()
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
310
341
|
context "when billing didn't work" do
|
311
342
|
let(:subscription) { FakeBraintree.subscriptions[subject.subscription_token] }
|
312
343
|
|
metadata
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: saucy
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 12
|
8
|
-
- 2
|
9
|
-
version: 0.12.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.12.3
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- thoughtbot, inc.
|
13
9
|
- Joe Ferris
|
14
10
|
- Mike Burns
|
@@ -18,130 +14,103 @@ authors:
|
|
18
14
|
autorequire:
|
19
15
|
bindir: bin
|
20
16
|
cert_chain: []
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
dependencies:
|
25
|
-
- !ruby/object:Gem::Dependency
|
17
|
+
date: 2011-10-07 00:00:00.000000000Z
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
26
20
|
name: clearance
|
27
|
-
|
28
|
-
|
29
|
-
requirements:
|
21
|
+
requirement: &70365143039700 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
30
24
|
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
segments:
|
33
|
-
- 0
|
34
|
-
- 11
|
35
|
-
- 2
|
25
|
+
- !ruby/object:Gem::Version
|
36
26
|
version: 0.11.2
|
37
27
|
type: :runtime
|
38
|
-
version_requirements: *id001
|
39
|
-
- !ruby/object:Gem::Dependency
|
40
|
-
name: formtastic
|
41
28
|
prerelease: false
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
29
|
+
version_requirements: *70365143039700
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: formtastic
|
32
|
+
requirement: &70365143072740 !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.2'
|
50
38
|
type: :runtime
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: railties
|
54
39
|
prerelease: false
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
40
|
+
version_requirements: *70365143072740
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
43
|
+
requirement: &70365143072280 !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
63
48
|
version: 3.0.3
|
64
49
|
type: :runtime
|
65
|
-
version_requirements: *id003
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
|
-
name: braintree
|
68
50
|
prerelease: false
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
51
|
+
version_requirements: *70365143072280
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: braintree
|
54
|
+
requirement: &70365143071820 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
77
59
|
version: 2.6.2
|
78
60
|
type: :runtime
|
79
|
-
version_requirements: *id004
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: sham_rack
|
82
61
|
prerelease: false
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
62
|
+
version_requirements: *70365143071820
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: sham_rack
|
65
|
+
requirement: &70365143071360 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - =
|
69
|
+
- !ruby/object:Gem::Version
|
91
70
|
version: 1.3.3
|
92
71
|
type: :runtime
|
93
|
-
version_requirements: *id005
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: sinatra
|
96
72
|
prerelease: false
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
73
|
+
version_requirements: *70365143071360
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: sinatra
|
76
|
+
requirement: &70365143070900 !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
105
81
|
version: 1.1.2
|
106
82
|
type: :runtime
|
107
|
-
version_requirements: *id006
|
108
|
-
- !ruby/object:Gem::Dependency
|
109
|
-
name: airbrake
|
110
83
|
prerelease: false
|
111
|
-
|
112
|
-
|
84
|
+
version_requirements: *70365143070900
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: airbrake
|
87
|
+
requirement: &70365143070440 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
113
90
|
- - ~>
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
segments:
|
116
|
-
- 3
|
117
|
-
- 0
|
118
|
-
- 4
|
91
|
+
- !ruby/object:Gem::Version
|
119
92
|
version: 3.0.4
|
120
93
|
type: :runtime
|
121
|
-
version_requirements: *id007
|
122
|
-
- !ruby/object:Gem::Dependency
|
123
|
-
name: aruba
|
124
94
|
prerelease: false
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
95
|
+
version_requirements: *70365143070440
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: aruba
|
98
|
+
requirement: &70365143069980 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - =
|
102
|
+
- !ruby/object:Gem::Version
|
133
103
|
version: 0.2.6
|
134
104
|
type: :development
|
135
|
-
|
136
|
-
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: *70365143069980
|
107
|
+
description: Clearance-based Rails engine for Software as a Service (Saas) that provides
|
108
|
+
account and project management
|
137
109
|
email: support@thoughtbot.com
|
138
110
|
executables: []
|
139
|
-
|
140
111
|
extensions: []
|
141
|
-
|
142
112
|
extra_rdoc_files: []
|
143
|
-
|
144
|
-
files:
|
113
|
+
files:
|
145
114
|
- CHANGELOG.md
|
146
115
|
- Gemfile
|
147
116
|
- Gemfile.lock
|
@@ -313,37 +282,31 @@ files:
|
|
313
282
|
- spec/support/clearance_matchers.rb
|
314
283
|
- spec/support/notifications.rb
|
315
284
|
- spec/views/accounts/_account.html.erb_spec.rb
|
316
|
-
has_rdoc: true
|
317
285
|
homepage: http://github.com/thoughtbot/saucy
|
318
286
|
licenses: []
|
319
|
-
|
320
287
|
post_install_message:
|
321
288
|
rdoc_options: []
|
322
|
-
|
323
|
-
require_paths:
|
289
|
+
require_paths:
|
324
290
|
- lib
|
325
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
requirements:
|
334
|
-
- -
|
335
|
-
- !ruby/object:Gem::Version
|
336
|
-
|
337
|
-
- 0
|
338
|
-
version: "0"
|
291
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
292
|
+
none: false
|
293
|
+
requirements:
|
294
|
+
- - ! '>='
|
295
|
+
- !ruby/object:Gem::Version
|
296
|
+
version: '0'
|
297
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
298
|
+
none: false
|
299
|
+
requirements:
|
300
|
+
- - ! '>='
|
301
|
+
- !ruby/object:Gem::Version
|
302
|
+
version: '0'
|
339
303
|
requirements: []
|
340
|
-
|
341
304
|
rubyforge_project:
|
342
|
-
rubygems_version: 1.
|
305
|
+
rubygems_version: 1.8.6
|
343
306
|
signing_key:
|
344
307
|
specification_version: 3
|
345
308
|
summary: Clearance-based Rails engine for SaaS
|
346
|
-
test_files:
|
309
|
+
test_files:
|
347
310
|
- features/run_features.feature
|
348
311
|
- features/step_definitions/clearance_steps.rb
|
349
312
|
- features/step_definitions/rails_steps.rb
|