Sha256: 7e5a31548a476deabd186c573fa3f70b14adfb83c3516d8646307a47e7b87c94
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
require 'spec_helper' describe Limit do subject { Factory(:limit) } it { should belong_to(:plan) } it { should validate_presence_of(:name) } it { should validate_presence_of(:value) } end describe Limit, "various kinds" do let!(:users) { Factory(:limit, :name => "users", :value => 1) } let!(:ssl) { Factory(:limit, :name => "ssl", :value => 0, :value_type => :boolean) } let!(:lighthouse) { Factory(:limit, :name => "lighthouse", :value => 1, :value_type => :boolean) } it "gives the numbered limits" do Limit.numbered.should == [users] end it "gives the boolean limits" do Limit.boolean.should == [ssl, lighthouse] end it "gives the limits by name" do Limit.named(:users).should == users end it "reports true for booleans with 1" do lighthouse.allowed?.should be end it "reports false for booleans with 0" do ssl.allowed?.should_not be end end describe Limit, "with account and limits" do subject { Factory(:limit, :name => "users", :value => 1) } before do @account = Factory(:account, :plan => subject.plan) end it "indicates whether the account is below the limit" do subject.within?(@account) end it "can query whether the given account is below the specified limit" do Limit.within?("users", @account) end it "indicates whether the specified account can add one" do Limit.can_add_one?("users", @account).should be Factory(:membership, :account => @account) Factory(:project, :account => @account) Limit.can_add_one?("users", @account).should_not be end it "returns true if there is no limit" do Limit.can_add_one?("nomatch", @account).should be Limit.within?("nomatch", @account).should be end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
saucy-0.3.2 | spec/models/limit_spec.rb |