Sha256: d524e9d8ff2c57edec0546ff7605ea8de6715f05a08ff87837e15e5ae1a65b01

Contents?: true

Size: 1.15 KB

Versions: 8

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

8 entries across 8 versions & 3 rubygems

Version Path
mongoid-rspec-1.13.0 spec/unit/associations_spec.rb
mongoid-rspec-2.0.0 spec/unit/associations_spec.rb
mongoid-rspec-2.0.0.rc1 spec/unit/associations_spec.rb
glebtv-mongoid-rspec-3.0.0 spec/unit/associations_spec.rb
mongoid4-rspec-1.11.0 spec/unit/associations_spec.rb
glebtv-mongoid-rspec-1.12.0 spec/unit/associations_spec.rb
mongoid-rspec-1.11.0 spec/unit/associations_spec.rb
mongoid-rspec-1.10.0 spec/unit/associations_spec.rb