Sha256: 98fc5e6c1decddea144ea099e98c7689470488f1ed590e52cf81046cff689e85

Contents?: true

Size: 1.81 KB

Versions: 11

Compression:

Stored size: 1.81 KB

Contents

require 'test_helper'
require 'models'

class ManyAssociationTest < Test::Unit::TestCase
  include MongoMapper::Plugins::Associations

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

    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
    should "be _type" do
      ManyAssociation.new(:foos).type_key_name.should == '_type'
    end
  end

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

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

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

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

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

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

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

end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
mongo_mapper-0.12.0 test/unit/associations/test_many_association.rb
lookout-mongo_mapper-0.11.3 test/unit/associations/test_many_association.rb
mongo_mapper-0.11.2 test/unit/associations/test_many_association.rb
jamieorc-mongo_mapper-0.11.1.1 test/unit/associations/test_many_association.rb
mongo_mapper-0.11.1 test/unit/associations/test_many_association.rb
mongo_mapper-0.11.0 test/unit/associations/test_many_association.rb
mongo_mapper-0.10.1 test/unit/associations/test_many_association.rb
mongo_mapper-0.10.0 test/unit/associations/test_many_association.rb
mongo_mapper-0.9.2 test/unit/associations/test_many_association.rb
mongo_mapper-0.9.1 test/unit/associations/test_many_association.rb
mongo_mapper-0.9.0 test/unit/associations/test_many_association.rb