Sha256: 4f83c8f37da2904be7e19fe451b0d01d66e5abbfcff552526bb20d8355d1161b
Contents?: true
Size: 1.86 KB
Versions: 3
Compression:
Stored size: 1.86 KB
Contents
require 'spec_helper' describe Account do subject { Factory(:account) } it { should have_many(:account_memberships) } it { should have_many(:users).through(:account_memberships) } it { should have_many(:projects) } it { should validate_uniqueness_of(:name) } it { should validate_uniqueness_of(:url) } it { should validate_presence_of( :name) } it { should validate_presence_of(:url) } it { should_not allow_mass_assignment_of(:id) } it { should_not allow_mass_assignment_of(:updated_at) } it { should_not allow_mass_assignment_of(:created_at) } it { should allow_mass_assignment_of(:url) } [nil, "", "a b", "a.b", "a%b"].each do |value| it { should_not allow_value(value).for(:url).with_message(/letters/i) } end ["admin", "blog", "dev", "ftp", "mail", "pop", "pop3", "imap", "smtp", "staging", "stats", "status","www"].each do |value| it { should_not allow_value(value).for(:url).with_message(/reserved/i) } end ["foo", "f00", "37signals"].each do |value| it { should allow_value(value).for(:url) } end it "should give its url for to_param" do subject.to_param.should == subject.url end it "finds admin users" do admins = [Factory(:user), Factory(:user)] non_admin = Factory(:user) non_member = Factory(:user) admins.each do |admin| Factory(:account_membership, :user => admin, :account => subject, :admin => true) end Factory(:account_membership, :user => non_admin, :account => subject, :admin => false) result = subject.admins result.to_a.should =~ admins end it "has a member with a membership" do membership = Factory(:account_membership, :account => subject) should have_member(membership.user) end it "doesn't have a member without a membership" do membership = Factory(:account_membership, :account => subject) should_not have_member(Factory(:user)) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
saucy-0.1.3 | spec/models/account_spec.rb |
saucy-0.1.2 | spec/models/account_spec.rb |
saucy-0.1.1 | spec/models/account_spec.rb |