Sha256: c643563a438a33f7884e7d3078359db99875f0be79568ded76df2b280b74c954

Contents?: true

Size: 1.09 KB

Versions: 66

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Membership do
  it { should belong_to(:account) }
  it { should belong_to(:user) }
  it { should validate_presence_of(:account_id) }
  it { should validate_presence_of(:user_id) }
  it { should have_many(:permissions) }
  it { should have_many(:projects).through(:permissions) }

  describe "given an existing account membership" do
    before { Factory(:membership) }
    it { should validate_uniqueness_of(:user_id).scoped_to(:account_id) }
  end

  it "delegates the user's name" do
    user = Factory(:user)
    membership = Factory(:membership, :user => user)

    membership.name.should == user.name
  end

  it "delegates the user's email" do
    user = Factory(:user)
    membership = Factory(:membership, :user => user)

    membership.email.should == user.email
  end

  it "returns memberships by name" do
    Factory(:membership, :user => Factory(:user, :name => "def"))
    Factory(:membership, :user => Factory(:user, :name => "abc"))
    Factory(:membership, :user => Factory(:user, :name => "ghi"))

    Membership.by_name.map(&:name).should == %w(abc def ghi)
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
saucy-0.2.31 spec/models/membership_spec.rb
saucy-0.2.30 spec/models/membership_spec.rb
saucy-0.2.29 spec/models/membership_spec.rb
saucy-0.2.28 spec/models/membership_spec.rb
saucy-0.2.27 spec/models/membership_spec.rb
saucy-0.2.26 spec/models/membership_spec.rb
saucy-0.2.25 spec/models/membership_spec.rb
saucy-0.2.24 spec/models/membership_spec.rb
saucy-0.2.21 spec/models/membership_spec.rb
saucy-0.2.20 spec/models/membership_spec.rb
saucy-0.2.18 spec/models/membership_spec.rb
saucy-0.2.17 spec/models/membership_spec.rb
saucy-0.2.16 spec/models/membership_spec.rb
saucy-0.2.15 spec/models/membership_spec.rb
saucy-0.2.14 spec/models/membership_spec.rb
saucy-0.2.13 spec/models/membership_spec.rb
saucy-0.2.12 spec/models/membership_spec.rb
saucy-0.2.11 spec/models/membership_spec.rb
saucy-0.2.10 spec/models/membership_spec.rb
saucy-0.2.9 spec/models/membership_spec.rb