Sha256: e60b92ebd8dbe34b37a8cf3dd8a75949504e45cb7760e116418fb67ce5746048

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 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


describe Plan, "with prices" do
  let!(:free) { Factory(:plan, :price => 0) }
  let!(:least) { Factory(:plan, :price => 1) }
  let!(:most) { Factory(:plan, :price => 2) }

  it "gives them from most to least expensive when ordered" do
    Plan.ordered.should == [most, least, free]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
saucy-0.2.12 spec/models/plan_spec.rb
saucy-0.2.11 spec/models/plan_spec.rb