Sha256: 7185dde712889c497c39cace00352c7653c977dfdd6901d6c8f699c57671603c

Contents?: true

Size: 1.03 KB

Versions: 27

Compression:

Stored size: 1.03 KB

Contents

require File.join(File.dirname(__FILE__), "/../../../spec_helper.rb")

describe Mongoid::Associations::BelongsToAssociation do

  before do
    @parent = Name.new(:first_name => "Drexel")
    @document = stub(:parent => @parent)
  end

  describe "#find" do

    before do
      @association = Mongoid::Associations::BelongsToAssociation.new(@document)
    end

    context "when finding by id" do

      it "returns the document in the array with that id" do
        name = @association.find(Mongo::ObjectID.new)
        name.should == @parent
      end

    end

  end

  context "when decorating" do

    before do
      @association = Mongoid::Associations::BelongsToAssociation.new(@document)
    end

    context "when getting values" do

      it "delegates to the document" do
        @association.first_name.should == "Drexel"
      end

    end

    context "when setting values" do

      it "delegates to the document" do
        @association.first_name = "Test"
        @association.first_name.should == "Test"
      end

    end

  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
mongoid-0.4.1 spec/unit/mongoid/associations/belongs_to_association_spec.rb
mongoid-0.4.0 spec/unit/mongoid/associations/belongs_to_association_spec.rb
mongoid-0.3.4 spec/unit/mongoid/associations/belongs_to_association_spec.rb
mongoid-0.3.3 spec/unit/mongoid/associations/belongs_to_association_spec.rb
mongoid-0.3.2 spec/unit/mongoid/associations/belongs_to_association_spec.rb
mongoid-0.3.1 spec/unit/mongoid/associations/belongs_to_association_spec.rb
mongoid-0.3.0 spec/unit/mongoid/associations/belongs_to_association_spec.rb