saucy 0.12.5 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -0
- data/Rakefile +3 -0
- data/app/models/canceled_account.rb +18 -0
- data/app/models/signup.rb +1 -0
- data/app/views/plans/edit.html.erb +8 -0
- data/lib/generators/saucy/features/templates/features/manage_plan.feature +1 -0
- data/lib/generators/saucy/features/templates/features/trial_plans.feature +9 -0
- data/lib/generators/saucy/install/install_generator.rb +4 -0
- data/lib/saucy/account.rb +8 -0
- data/spec/environment.rb +2 -0
- data/spec/models/account_spec.rb +13 -0
- data/spec/models/canceled_account_spec.rb +47 -0
- data/spec/models/signup_spec.rb +10 -0
- metadata +7 -5
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
0.13.0
|
2
|
+
|
3
|
+
* Populate braintree customer email with admin email its not set
|
4
|
+
* Keep track of canceled accounts, this is a non-backwards compatible change and when upgrading saucy you will need to run the following:
|
5
|
+
|
6
|
+
bundle exec rake saucy_engine:install:migrations db:migrate
|
7
|
+
|
8
|
+
* Allow users in an expired trial to delete their account
|
9
|
+
|
10
|
+
With this release you will also want to regenerate the saucy features (`rails g saucy:features`), or look at the commit diffs and
|
11
|
+
introduce the above two changes yourself.
|
12
|
+
|
1
13
|
0.12.5
|
2
14
|
|
3
15
|
* 0.12.3 and 0.12.14 were built using the wrong version of ruby/rubygems
|
data/Rakefile
CHANGED
@@ -5,6 +5,9 @@ require 'rubygems/package_task'
|
|
5
5
|
require 'cucumber/rake/task'
|
6
6
|
require 'rspec/core/rake_task'
|
7
7
|
|
8
|
+
APP_RAKEFILE = File.expand_path("../tmp/aruba/testapp/Rakefile", __FILE__)
|
9
|
+
load 'rails/tasks/engine.rake'
|
10
|
+
|
8
11
|
desc 'Default: run all tests'
|
9
12
|
task :default => [:spec, :cucumber]
|
10
13
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CanceledAccount < ActiveRecord::Base
|
2
|
+
attr_accessor :account
|
3
|
+
|
4
|
+
belongs_to :plan
|
5
|
+
|
6
|
+
before_validation :populate_from_account, :on => :create, :if => :account
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def populate_from_account
|
11
|
+
self.name = account.name
|
12
|
+
self.keyword = account.keyword
|
13
|
+
self.billing_email = account.customer.email
|
14
|
+
self.memberships = account.memberships.to_json(:include => { :user => { :only => [:email, :name, :created_at]}}, :only => [:admin, :created_at])
|
15
|
+
self.plan = account.plan
|
16
|
+
self.started_at = account.created_at
|
17
|
+
end
|
18
|
+
end
|
data/app/models/signup.rb
CHANGED
@@ -27,6 +27,14 @@
|
|
27
27
|
|
28
28
|
<%= form.buttons do %>
|
29
29
|
<%= form.commit_button "Upgrade" %>
|
30
|
+
<% if @account.expired? %>
|
31
|
+
<li>
|
32
|
+
<%= link_to t(".delete.expired", :default => "No thanks, just delete my account"),
|
33
|
+
@account,
|
34
|
+
:method => :delete,
|
35
|
+
:confirm => "Are you sure? All data will be irreversibly deleted." %>
|
36
|
+
</li>
|
37
|
+
<% end %>
|
30
38
|
<% end %>
|
31
39
|
<% end %>
|
32
40
|
|
@@ -37,6 +37,7 @@ Feature: Manage Plan
|
|
37
37
|
Then I should see "Upgrade Your Plan"
|
38
38
|
When I choose the "Basic" plan
|
39
39
|
Then I should see "Billing Information"
|
40
|
+
And I should not see "No thanks, just delete my account"
|
40
41
|
And I fill in "Cardholder name" with "Ralph Robot"
|
41
42
|
And I fill in "Billing email" with "accounting@example.com"
|
42
43
|
And I fill in "Card number" with "4111111111111111"
|
@@ -37,6 +37,15 @@ Feature: Trial plans
|
|
37
37
|
And I should see "expired"
|
38
38
|
And the "Temp" plan should be disabled
|
39
39
|
|
40
|
+
Scenario: Delete an account with an expired plan
|
41
|
+
Given a "Temp" account exists with a name of "Test" created 30 days ago
|
42
|
+
And I am signed in as an admin of the "Test" account
|
43
|
+
When I go to the projects page for the "Test" account
|
44
|
+
Then I should be on the upgrade plan page for the "Test" account
|
45
|
+
And I should see "expired"
|
46
|
+
When I follow "No thanks, just delete my account"
|
47
|
+
Then I should see "Your account has been deleted"
|
48
|
+
|
40
49
|
Scenario: Sign up for a non-trial plan
|
41
50
|
When I go to the list of plans page
|
42
51
|
And I follow "Eternal"
|
data/lib/saucy/account.rb
CHANGED
@@ -33,6 +33,8 @@ module Saucy
|
|
33
33
|
|
34
34
|
before_create :set_trial_expiration
|
35
35
|
after_save :record_new_activations
|
36
|
+
|
37
|
+
before_destroy :create_canceled_account
|
36
38
|
end
|
37
39
|
|
38
40
|
module InstanceMethods
|
@@ -94,6 +96,12 @@ module Saucy
|
|
94
96
|
def projects_count
|
95
97
|
projects.active.count
|
96
98
|
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def create_canceled_account
|
103
|
+
CanceledAccount.create(:account => self)
|
104
|
+
end
|
97
105
|
end
|
98
106
|
|
99
107
|
module ClassMethods
|
data/spec/environment.rb
CHANGED
@@ -52,6 +52,7 @@ ActionController::Base.send :include, Rails.application.routes.url_helpers
|
|
52
52
|
|
53
53
|
require "./lib/generators/saucy/features/templates/factories"
|
54
54
|
require "./lib/generators/saucy/install/templates/create_saucy_tables"
|
55
|
+
#Dir["./db/migrate/*.rb"].each {|file| require file }
|
55
56
|
|
56
57
|
class ClearanceCreateUsers < ActiveRecord::Migration
|
57
58
|
def self.up
|
@@ -94,3 +95,4 @@ end
|
|
94
95
|
|
95
96
|
ClearanceCreateUsers.suppress_messages { ClearanceCreateUsers.migrate(:up) }
|
96
97
|
CreateSaucyTables.suppress_messages { CreateSaucyTables.migrate(:up) }
|
98
|
+
ActiveRecord::Migrator.up(ActiveRecord::Migrator.migrations_paths)
|
data/spec/models/account_spec.rb
CHANGED
@@ -344,3 +344,16 @@ describe Account, "with coupon" do
|
|
344
344
|
subject.reload.trial_expires_at.to_s.should == (free_months * 30).days.from_now.to_s
|
345
345
|
end
|
346
346
|
end
|
347
|
+
|
348
|
+
describe Account, "when destroyed" do
|
349
|
+
subject { Factory(:account) }
|
350
|
+
|
351
|
+
before do
|
352
|
+
CanceledAccount.stubs(:create)
|
353
|
+
end
|
354
|
+
|
355
|
+
it "creates a canceled account record" do
|
356
|
+
subject.destroy
|
357
|
+
CanceledAccount.should have_received(:create).with(:account => subject)
|
358
|
+
end
|
359
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CanceledAccount do
|
4
|
+
subject { CanceledAccount.create() }
|
5
|
+
|
6
|
+
it { should belong_to(:plan) }
|
7
|
+
|
8
|
+
it "doesn't populate anything" do
|
9
|
+
subject.name.should be_nil
|
10
|
+
subject.keyword.should be_nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe CanceledAccount, "given an account" do
|
15
|
+
let(:account) { Factory(:account, :billing_email => "billing@example.com") }
|
16
|
+
|
17
|
+
before do
|
18
|
+
Factory(:membership, :account => account)
|
19
|
+
end
|
20
|
+
|
21
|
+
subject { CanceledAccount.create(:account => account) }
|
22
|
+
|
23
|
+
it "populates its name and keyword from the given account" do
|
24
|
+
subject.name.should == account.name
|
25
|
+
subject.keyword.should == account.keyword
|
26
|
+
end
|
27
|
+
|
28
|
+
it "populates the billing_email from the customer's email from the given account" do
|
29
|
+
subject.billing_email.should_not be_nil
|
30
|
+
subject.billing_email.should == account.customer.email
|
31
|
+
end
|
32
|
+
|
33
|
+
it "saves the memberships and users as json from the given account" do
|
34
|
+
memberships_json = account.memberships.to_json(:include => { :user => { :only => [:email, :name, :created_at]}}, :only => [:admin, :created_at])
|
35
|
+
subject.memberships.should == memberships_json
|
36
|
+
JSON.parse(subject.memberships).should be
|
37
|
+
end
|
38
|
+
|
39
|
+
it "populates the plan from the given account" do
|
40
|
+
subject.plan_id.should == account.plan_id
|
41
|
+
subject.plan.should == account.plan
|
42
|
+
end
|
43
|
+
|
44
|
+
it "populates the started_at from the given account's creation date" do
|
45
|
+
subject.started_at.should == account.created_at
|
46
|
+
end
|
47
|
+
end
|
data/spec/models/signup_spec.rb
CHANGED
@@ -89,6 +89,16 @@ describe Signup, "with a valid user and account" do
|
|
89
89
|
it "gives it's user a name that is the first part of it's email" do
|
90
90
|
subject.user.name.should == "user"
|
91
91
|
end
|
92
|
+
|
93
|
+
it "uses the user's email as it's billing_email" do
|
94
|
+
subject.account.customer.email.should == email
|
95
|
+
end
|
96
|
+
|
97
|
+
it "uses doesn't override billing_email if one is supplied" do
|
98
|
+
new_signup = Factory.build(:signup, :email => email, :billing_email => "billing@example.com")
|
99
|
+
new_signup.save
|
100
|
+
new_signup.account.customer.email.should == "billing@example.com"
|
101
|
+
end
|
92
102
|
end
|
93
103
|
|
94
104
|
describe Signup, "with an email with symbols in it" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saucy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 13
|
9
|
+
- 0
|
10
|
+
version: 0.13.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- thoughtbot, inc.
|
@@ -20,7 +20,7 @@ autorequire:
|
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
22
|
|
23
|
-
date: 2011-10-
|
23
|
+
date: 2011-10-14 00:00:00 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: clearance
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- app/helpers/limits_helper.rb
|
180
180
|
- app/mailers/billing_mailer.rb
|
181
181
|
- app/mailers/invitation_mailer.rb
|
182
|
+
- app/models/canceled_account.rb
|
182
183
|
- app/models/coupon.rb
|
183
184
|
- app/models/invitation.rb
|
184
185
|
- app/models/limit.rb
|
@@ -308,6 +309,7 @@ files:
|
|
308
309
|
- spec/mailers/billing_mailer_spec.rb
|
309
310
|
- spec/mailers/invitiation_mailer_spec.rb
|
310
311
|
- spec/models/account_spec.rb
|
312
|
+
- spec/models/canceled_account_spec.rb
|
311
313
|
- spec/models/coupon_spec.rb
|
312
314
|
- spec/models/invitation_spec.rb
|
313
315
|
- spec/models/limit_spec.rb
|