Sha256: 1f2a0dad95ace4f4ad51cf98789c57c08021ad184f6433c4ee1e85f082638e59

Contents?: true

Size: 1.23 KB

Versions: 14

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe Plan do
  subject { Factory(:plan) }

  it { should have_many(:limits) }
  it { should have_many(:accounts) }
  it { should validate_presence_of(:name) }
end

describe Plan, "free" do
  subject { Factory(:plan) }

  it "is free" do
    subject.free?.should be
  end

  it "is not billed" do
    subject.billed?.should_not be
  end
end

describe Plan, "paid" do
  subject { Factory(:paid_plan) }

  it "is not free" do
    subject.free?.should_not be
  end

  it "is billed" do
    subject.billed?.should be
  end
end

describe Plan, "with limits" do
  subject { Factory(:plan) }

  before do
    Factory(:limit, :name => "users", :value => 1, :plan => subject)
    Factory(:limit, :name => "ssl", :value => 0, :value_type => :boolean, :plan => subject)
    Factory(:limit, :name => "lighthouse", :value => 1, :value_type => :boolean, :plan => subject)
  end

  it "indicates whether or not more users can be created" do
    subject.can_add_more?(:users, 0).should be
    subject.can_add_more?(:users, 1).should_not be
    subject.can_add_more?(:users, 2).should_not be
  end

  it "indicates whether a plan can do something or not" do
    subject.allows?(:ssl).should_not be
    subject.allows?(:lighthouse).should be
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
saucy-0.2.10 spec/models/plan_spec.rb
saucy-0.2.9 spec/models/plan_spec.rb
saucy-0.2.8.1 spec/models/plan_spec.rb
saucy-0.2.8 spec/models/plan_spec.rb
saucy-0.2.7 spec/models/plan_spec.rb
saucy-0.2.6.1 spec/models/plan_spec.rb
saucy-0.2.6 spec/models/plan_spec.rb
saucy-0.2.5 spec/models/plan_spec.rb
saucy-0.2.4.1 spec/models/plan_spec.rb
saucy-0.2.4 spec/models/plan_spec.rb
saucy-0.2.3 spec/models/plan_spec.rb
saucy-0.2.2 spec/models/plan_spec.rb
saucy-0.2.1 spec/models/plan_spec.rb
saucy-0.2.0 spec/models/plan_spec.rb