saucy 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
data/lib/saucy/plan.rb CHANGED
@@ -11,6 +11,22 @@ module Saucy
11
11
  def self.ordered
12
12
  order('price desc')
13
13
  end
14
+
15
+ def self.paid_by_price
16
+ paid.ordered
17
+ end
18
+
19
+ def self.trial
20
+ free.first
21
+ end
22
+
23
+ def self.paid
24
+ where('price > 0')
25
+ end
26
+
27
+ def self.free
28
+ where('price = 0')
29
+ end
14
30
  end
15
31
 
16
32
  module InstanceMethods
@@ -6,6 +6,22 @@ describe Plan do
6
6
  it { should have_many(:limits) }
7
7
  it { should have_many(:accounts) }
8
8
  it { should validate_presence_of(:name) }
9
+
10
+ it "finds ordered paid plans" do
11
+ Factory(:plan, :name => "Free", :price => 0)
12
+ Factory(:plan, :name => "Two", :price => 2)
13
+ Factory(:plan, :name => "One", :price => 1)
14
+ Factory(:plan, :name => "Three", :price => 3)
15
+
16
+ Plan.paid_by_price.to_a.map(&:name).should == %w(Three Two One)
17
+ end
18
+
19
+ it "finds the trial plan" do
20
+ paid = Factory(:plan, :name => "Paid", :price => 1)
21
+ trial = Factory(:plan, :name => "Free", :price => 0)
22
+
23
+ Plan.trial.should == trial
24
+ end
9
25
  end
10
26
 
11
27
  describe Plan, "free" 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: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 12
10
- version: 0.2.12
9
+ - 13
10
+ version: 0.2.13
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-01-31 00:00:00 -05:00
20
+ date: 2011-02-01 00:00:00 -05:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency