Sha256: 847317b025ae564e239e0a752e4220859edc0aafb61657f98e48b438055396a1

Contents?: true

Size: 1.93 KB

Versions: 11

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'


module ManyAssociationSpec
  include MongoMapper::Plugins::Associations
  describe "ManyAssociation" do

    context "class_name" do
      it "should camelize the name" do
        ManyAssociation.new(:smart_people).class_name.should == 'SmartPerson'
      end

      it "should be changeable using class_name option" do
        base = ManyAssociation.new(:smart_people, :class_name => 'IntelligentPerson')
        base.class_name.should == 'IntelligentPerson'
      end
    end

    context "type_key_name" do
      it "should be _type" do
        ManyAssociation.new(:foos).type_key_name.should == '_type'
      end
    end

    context "embeddable?" do
      it "should be true if class is embeddable" do
        base = ManyAssociation.new(:medias)
        base.embeddable?.should be_truthy
      end

      it "should be false if class is not embeddable" do
        base = ManyAssociation.new(:statuses)
        base.embeddable?.should be_falsey
      end
    end

    context "proxy_class" do
      it "should be ManyDocumentsProxy for many" do
        base = ManyAssociation.new(:statuses)
        base.proxy_class.should == ManyDocumentsProxy
      end

      it "should be ManyPolymorphicProxy for polymorphic many" do
        base = ManyAssociation.new(:messages, :polymorphic => true)
        base.proxy_class.should == ManyPolymorphicProxy
      end

      it "should be ManyEmbeddedProxy for many embedded" do
        base = ManyAssociation.new(:medias)
        base.proxy_class.should == ManyEmbeddedProxy
      end

      it "should be ManyEmbeddedPolymorphicProxy for polymorphic many embedded" do
        base = ManyAssociation.new(:medias, :polymorphic => true)
        base.proxy_class.should == ManyEmbeddedPolymorphicProxy
      end

      it "should be InArrayProxy for many with :in option" do
        base = ManyAssociation.new(:messages, :in => :message_ids)
        base.proxy_class.should == InArrayProxy
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mongo_mapper-0.17.0 spec/unit/associations/many_association_spec.rb
mongo_mapper-0.16.0 spec/unit/associations/many_association_spec.rb
mongo_mapper-0.15.6 spec/unit/associations/many_association_spec.rb
mongo_mapper-0.15.5 spec/unit/associations/many_association_spec.rb
mongo_mapper-0.15.4 spec/unit/associations/many_association_spec.rb
mongo_mapper-0.15.3 spec/unit/associations/many_association_spec.rb
mongo_mapper-0.15.2 spec/unit/associations/many_association_spec.rb
mongo_mapper-0.15.1 spec/unit/associations/many_association_spec.rb
mongo_mapper-0.15.0 spec/unit/associations/many_association_spec.rb
mongo_mapper-0.14.0 spec/unit/associations/many_association_spec.rb
mongo_mapper-0.14.0.rc1 spec/unit/associations/many_association_spec.rb