saucy 0.2.32 → 0.2.33
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.
@@ -23,11 +23,13 @@ class CreateSaucyTables < ActiveRecord::Migration
|
|
23
23
|
table.boolean :notified_of_expiration, :default => false, :null => false
|
24
24
|
table.boolean :asked_to_activate, :default => false, :null => false
|
25
25
|
table.boolean :activated, :default => false, :null => false
|
26
|
+
table.datetime :trial_expires_at
|
26
27
|
end
|
27
28
|
add_index :accounts, :plan_id
|
28
29
|
add_index :accounts, :keyword
|
29
30
|
add_index :accounts, :next_billing_date
|
30
31
|
add_index :accounts, :created_at
|
32
|
+
add_index :accounts, :trial_expires_at
|
31
33
|
|
32
34
|
create_table :invitations do |table|
|
33
35
|
table.string :email
|
data/lib/saucy/account.rb
CHANGED
@@ -24,6 +24,8 @@ module Saucy
|
|
24
24
|
validates_format_of :keyword,
|
25
25
|
:with => %r{^[a-z0-9]+$},
|
26
26
|
:message => "must be only lower case letters."
|
27
|
+
|
28
|
+
before_create :set_trial_expiration
|
27
29
|
end
|
28
30
|
|
29
31
|
module InstanceMethods
|
@@ -56,12 +58,16 @@ module Saucy
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def past_trial?
|
59
|
-
|
61
|
+
trial_expires_at && trial_expires_at < Time.now
|
60
62
|
end
|
61
63
|
|
62
64
|
def admin_emails
|
63
65
|
admins.map(&:email)
|
64
66
|
end
|
67
|
+
|
68
|
+
def set_trial_expiration
|
69
|
+
self.trial_expires_at = 30.days.from_now(created_at || Time.now)
|
70
|
+
end
|
65
71
|
end
|
66
72
|
|
67
73
|
module ClassMethods
|
data/spec/models/account_spec.rb
CHANGED
@@ -93,6 +93,14 @@ describe Account do
|
|
93
93
|
Factory(:account, :created_at => 30.days.ago, :plan => forever).should_not be_expired
|
94
94
|
end
|
95
95
|
|
96
|
+
it "isn't expired without an expiration date after 30 days" do
|
97
|
+
trial = Factory(:plan, :trial => true)
|
98
|
+
account = Factory(:account, :created_at => 30.days.ago, :plan => trial)
|
99
|
+
account.trial_expires_at = nil
|
100
|
+
account.save!
|
101
|
+
account.should_not be_expired
|
102
|
+
end
|
103
|
+
|
96
104
|
it "sends notifications for expiring accounts" do
|
97
105
|
trial = Factory(:plan, :trial => true)
|
98
106
|
forever = Factory(:plan, :trial => false)
|
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: 85
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 33
|
10
|
+
version: 0.2.33
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- thoughtbot, inc.
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-
|
20
|
+
date: 2011-03-03 00:00:00 -05:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|