Sha256: a1e1ea01f74f37d3aa2e82e86f1b23e303b9909595dcabc71f794fbeffa427e7

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe "Associations" do
  describe User do
    it { should have_many(:articles).with_foreign_key(:author_id).ordered_by(:title) }

    it { should have_one(:record).with_autobuild }

    it { should have_many(:comments).with_dependent(:destroy).with_autosave }

    it { should embed_one :profile }

    it { should have_and_belong_to_many(:children).of_type(User) }
  end

  describe Profile do
    it { should be_embedded_in(:user).as_inverse_of(:profile) }
  end

  describe Article do
    it { should belong_to(:author).of_type(User).as_inverse_of(:articles).with_index }
    it { should embed_many(:comments).with_cascading_callbacks }
    it { should embed_one(:permalink) }
  end

  describe Comment do
    it { should be_embedded_in(:article).as_inverse_of(:comments).with_polymorphism }
    it { should belong_to(:user).as_inverse_of(:comments) }
  end

  describe Record do
    it { should belong_to(:user).as_inverse_of(:record) }
  end

  describe Permalink do
    it { should be_embedded_in(:linkable).as_inverse_of(:link) }
  end

  describe Site do
    it { should have_many(:users).as_inverse_of(:site).ordered_by(:email.desc) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-rspec-1.9.0 spec/unit/associations_spec.rb