Sha256: 8f04c8fded87d6199ed41da8a0631e873250e2029bd4084d993b70c546721995

Contents?: true

Size: 1.11 KB

Versions: 69

Compression:

Stored size: 1.11 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).dependent(:destroy) }
  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

69 entries across 69 versions & 2 rubygems

Version Path
saucy-0.16.1 spec/models/membership_spec.rb
saucy-0.16.0 spec/models/membership_spec.rb
saucy-0.15.2 spec/models/membership_spec.rb
saucy-0.15.1 spec/models/membership_spec.rb
saucy-0.15.0 spec/models/membership_spec.rb
saucy-0.14.5 spec/models/membership_spec.rb
saucy-0.14.3 spec/models/membership_spec.rb
saucy-0.10.10 spec/models/membership_spec.rb
saucy-0.14.2 spec/models/membership_spec.rb
saucy-0.14.1 spec/models/membership_spec.rb
saucy-0.14.0 spec/models/membership_spec.rb
saucy-0.13.3 spec/models/membership_spec.rb
saucy-0.13.2 spec/models/membership_spec.rb
saucy-0.10.9 spec/models/membership_spec.rb
saucy-0.10.8 spec/models/membership_spec.rb
saucy-0.13.1 spec/models/membership_spec.rb
saucy-0.13.0 spec/models/membership_spec.rb
saucy-0.12.5 spec/models/membership_spec.rb
saucy-0.12.4 spec/models/membership_spec.rb
saucy-0.12.3 spec/models/membership_spec.rb