saucy 0.2.8.1 → 0.2.9
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/app/controllers/accounts_controller.rb +6 -0
- data/app/views/accounts/edit.html.erb +7 -2
- data/config/routes.rb +1 -1
- data/lib/generators/saucy/features/templates/features/manage_account.feature +10 -0
- data/lib/saucy/account.rb +5 -0
- data/lib/saucy/fake_braintree.rb +5 -0
- data/spec/controllers/accounts_controller_spec.rb +21 -0
- data/spec/models/account_spec.rb +5 -0
- metadata +28 -29
@@ -5,9 +5,8 @@
|
|
5
5
|
<%= render :partial => 'tab_bar' %>
|
6
6
|
|
7
7
|
<div class="plan current">
|
8
|
-
<h3>Your Plan</h3>
|
8
|
+
<h3>Your Plan (<%= link_to "Upgrade", edit_account_plan_path(current_account), :id => "upgrade-account" %>)</h3>
|
9
9
|
<%= render @account.plan %>
|
10
|
-
<%= link_to "Upgrade", edit_account_plan_path(@account) %>
|
11
10
|
</div>
|
12
11
|
|
13
12
|
<%= content_tag_for :div, @account do -%>
|
@@ -19,6 +18,12 @@
|
|
19
18
|
|
20
19
|
<%= form.buttons do %>
|
21
20
|
<%= form.commit_button "Update" %>
|
21
|
+
<li>
|
22
|
+
<%= link_to t(".delete", :default => "Delete my account"),
|
23
|
+
@account,
|
24
|
+
:method => :delete,
|
25
|
+
:confirm => "Are you sure? All data will be irreversibly deleted." %>
|
26
|
+
</li>
|
22
27
|
<% end %>
|
23
28
|
<% end %>
|
24
29
|
<% end -%>
|
data/config/routes.rb
CHANGED
@@ -24,3 +24,13 @@ Feature: Manage account
|
|
24
24
|
Then I should see "Projection"
|
25
25
|
When I follow "Users"
|
26
26
|
Then I should see "captain@awesome.com"
|
27
|
+
|
28
|
+
Scenario: Delete account
|
29
|
+
Given an account exists with a name of "Chocolate"
|
30
|
+
And I am signed in as an admin of the "Chocolate" account
|
31
|
+
When I go to the settings page for the "Chocolate" account
|
32
|
+
And I follow "Delete"
|
33
|
+
Then I should see "Your account has been deleted"
|
34
|
+
When I go to the dashboard page
|
35
|
+
Then I should not see "Chocolate"
|
36
|
+
|
data/lib/saucy/account.rb
CHANGED
@@ -38,6 +38,7 @@ module Saucy
|
|
38
38
|
|
39
39
|
before_create :create_customer
|
40
40
|
before_create :create_subscription, :if => :billed?
|
41
|
+
after_destroy :destroy_customer
|
41
42
|
|
42
43
|
memoize :customer
|
43
44
|
memoize :subscription
|
@@ -170,6 +171,10 @@ module Saucy
|
|
170
171
|
handle_customer_result(result)
|
171
172
|
end
|
172
173
|
|
174
|
+
def destroy_customer
|
175
|
+
Braintree::Customer.delete(customer_token)
|
176
|
+
end
|
177
|
+
|
173
178
|
def handle_customer_result(result)
|
174
179
|
if result.success?
|
175
180
|
self.customer_token = result.customer.id
|
data/lib/saucy/fake_braintree.rb
CHANGED
@@ -84,6 +84,11 @@ ShamRack.at("www.braintreegateway.com", 443).sinatra do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
delete "/merchants/:merchant_id/customers/:id" do
|
88
|
+
FakeBraintree.customers[params["id"]] = nil
|
89
|
+
[200, { "Content-Encoding" => "gzip" }, ActiveSupport::Gzip.compress("")]
|
90
|
+
end
|
91
|
+
|
87
92
|
post "/merchants/:merchant_id/subscriptions" do
|
88
93
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<subscription>\n <plan-id type=\"integer\">2</plan-id>\n <payment-method-token>b22x</payment-method-token>\n</subscription>\n"
|
89
94
|
subscription = Hash.from_xml(request.body).delete("subscription")
|
@@ -8,6 +8,7 @@ describe AccountsController, "routes" do
|
|
8
8
|
to(:action => :create, :plan_id => :abc) }
|
9
9
|
it { should route(:put, "/accounts/1").to(:action => :update, :id => 1) }
|
10
10
|
it { should route(:get, "/accounts/1/edit").to(:action => :edit, :id => 1) }
|
11
|
+
it { should route(:delete, "/accounts/1").to(:action => :destroy, :id => 1) }
|
11
12
|
end
|
12
13
|
|
13
14
|
describe AccountsController, "new" do
|
@@ -183,6 +184,26 @@ describe AccountsController, "edit", :as => :account_admin do
|
|
183
184
|
end
|
184
185
|
end
|
185
186
|
|
187
|
+
describe AccountsController, "destroy", :as => :account_admin do
|
188
|
+
before do
|
189
|
+
Account.stubs(:find_by_keyword! => account)
|
190
|
+
account.stubs(:destroy)
|
191
|
+
delete :destroy, :id => account.to_param
|
192
|
+
end
|
193
|
+
|
194
|
+
it "redirects to the root url" do
|
195
|
+
should redirect_to("/")
|
196
|
+
end
|
197
|
+
|
198
|
+
it "sets the flash" do
|
199
|
+
should set_the_flash.to(/deleted/i)
|
200
|
+
end
|
201
|
+
|
202
|
+
it "deletes the account" do
|
203
|
+
account.should have_received(:destroy)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
186
207
|
describe AccountsController, "permissions", :as => :account_member do
|
187
208
|
it { should deny_access.
|
188
209
|
on(:get, :edit, :id => account.to_param).
|
data/spec/models/account_spec.rb
CHANGED
@@ -180,6 +180,11 @@ describe Account, "with a paid plan" do
|
|
180
180
|
subject.customer.email.should == "jrobot@example.com"
|
181
181
|
subject.credit_card.cardholder_name.should == "Jim Robot"
|
182
182
|
end
|
183
|
+
|
184
|
+
it "deletes the customer when deleted" do
|
185
|
+
subject.destroy
|
186
|
+
FakeBraintree.customers[subject.customer_token].should be_nil
|
187
|
+
end
|
183
188
|
end
|
184
189
|
|
185
190
|
describe Account, "with a free plan" do
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saucy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 0.2.8.1
|
9
|
+
- 9
|
10
|
+
version: 0.2.9
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- thoughtbot, inc.
|
@@ -18,13 +17,14 @@ autorequire:
|
|
18
17
|
bindir: bin
|
19
18
|
cert_chain: []
|
20
19
|
|
21
|
-
date: 2011-01-
|
20
|
+
date: 2011-01-19 00:00:00 -05:00
|
22
21
|
default_executable:
|
23
22
|
dependencies:
|
24
23
|
- !ruby/object:Gem::Dependency
|
25
|
-
|
24
|
+
type: :runtime
|
26
25
|
prerelease: false
|
27
|
-
|
26
|
+
name: formtastic
|
27
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ">="
|
@@ -34,12 +34,12 @@ dependencies:
|
|
34
34
|
- 1
|
35
35
|
- 2
|
36
36
|
version: "1.2"
|
37
|
-
|
38
|
-
version_requirements: *id001
|
37
|
+
requirement: *id001
|
39
38
|
- !ruby/object:Gem::Dependency
|
40
|
-
|
39
|
+
type: :runtime
|
41
40
|
prerelease: false
|
42
|
-
|
41
|
+
name: railties
|
42
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
43
43
|
none: false
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -50,12 +50,12 @@ dependencies:
|
|
50
50
|
- 0
|
51
51
|
- 3
|
52
52
|
version: 3.0.3
|
53
|
-
|
54
|
-
version_requirements: *id002
|
53
|
+
requirement: *id002
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
|
-
|
55
|
+
type: :runtime
|
57
56
|
prerelease: false
|
58
|
-
|
57
|
+
name: braintree
|
58
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
59
59
|
none: false
|
60
60
|
requirements:
|
61
61
|
- - ">="
|
@@ -66,12 +66,12 @@ dependencies:
|
|
66
66
|
- 6
|
67
67
|
- 2
|
68
68
|
version: 2.6.2
|
69
|
-
|
70
|
-
version_requirements: *id003
|
69
|
+
requirement: *id003
|
71
70
|
- !ruby/object:Gem::Dependency
|
72
|
-
|
71
|
+
type: :runtime
|
73
72
|
prerelease: false
|
74
|
-
|
73
|
+
name: sham_rack
|
74
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - "="
|
@@ -82,12 +82,12 @@ dependencies:
|
|
82
82
|
- 3
|
83
83
|
- 3
|
84
84
|
version: 1.3.3
|
85
|
-
|
86
|
-
version_requirements: *id004
|
85
|
+
requirement: *id004
|
87
86
|
- !ruby/object:Gem::Dependency
|
88
|
-
|
87
|
+
type: :runtime
|
89
88
|
prerelease: false
|
90
|
-
|
89
|
+
name: sinatra
|
90
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
91
91
|
none: false
|
92
92
|
requirements:
|
93
93
|
- - "="
|
@@ -98,12 +98,12 @@ dependencies:
|
|
98
98
|
- 1
|
99
99
|
- 2
|
100
100
|
version: 1.1.2
|
101
|
-
|
102
|
-
version_requirements: *id005
|
101
|
+
requirement: *id005
|
103
102
|
- !ruby/object:Gem::Dependency
|
104
|
-
|
103
|
+
type: :development
|
105
104
|
prerelease: false
|
106
|
-
|
105
|
+
name: aruba
|
106
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|
109
109
|
- - "="
|
@@ -114,8 +114,7 @@ dependencies:
|
|
114
114
|
- 2
|
115
115
|
- 6
|
116
116
|
version: 0.2.6
|
117
|
-
|
118
|
-
version_requirements: *id006
|
117
|
+
requirement: *id006
|
119
118
|
description: Clearance-based Rails engine for Software as a Service (Saas) that provides account and project management
|
120
119
|
email: support@thoughtbot.com
|
121
120
|
executables: []
|