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.28.1 spec/models/membership_spec.rb
saucy-0.4.0 spec/models/membership_spec.rb
saucy-0.3.4 spec/models/membership_spec.rb
saucy-0.3.3 spec/models/membership_spec.rb
saucy-0.3.2 spec/models/membership_spec.rb
saucy-0.3.1 spec/models/membership_spec.rb
saucy-0.3.0 spec/models/membership_spec.rb
saucy-0.2.45 spec/models/membership_spec.rb
saucy-0.2.44 spec/models/membership_spec.rb
saucy-0.2.43 spec/models/membership_spec.rb
saucy-0.2.42 spec/models/membership_spec.rb
saucy-0.2.41 spec/models/membership_spec.rb
saucy-0.2.40 spec/models/membership_spec.rb
saucy-0.2.39 spec/models/membership_spec.rb
saucy-0.2.38 spec/models/membership_spec.rb
saucy-0.2.36 spec/models/membership_spec.rb
saucy-0.2.35 spec/models/membership_spec.rb
saucy-0.2.34 spec/models/membership_spec.rb
saucy-0.2.33 spec/models/membership_spec.rb
saucy-0.2.32 spec/models/membership_spec.rb