Sha256: 699c8cc3991e86ec989da81b1affd04d7da9a918a192a23a4e1037a40aebfc31

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

require 'test_helper'
require 'models'

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

  context "type_key_name" do
    should "be _type" do
      OneAssociation.new(:foo).type_key_name.should == '_type'
    end
  end

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

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

  context "proxy_class" do
    should "be OneProxy for one" do
      base = OneAssociation.new(:status)
      base.proxy_class.should == OneProxy
    end

    should "be OneAsProxy for one with :as option" do
      base = OneAssociation.new(:message, :as => :messagable)
      base.proxy_class.should == OneAsProxy
    end

    should "be OneEmbeddedProxy for one embedded" do
      base = OneAssociation.new(:media)
      base.proxy_class.should == OneEmbeddedProxy
    end

    should "be OneEmbeddedPolymorphicProxy for polymorphic one embedded" do
      base = OneAssociation.new(:media, :polymorphic => true)
      base.proxy_class.should == OneEmbeddedPolymorphicProxy
    end
  end

end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
mongo_mapper-0.12.0 test/unit/associations/test_one_association.rb
lookout-mongo_mapper-0.11.3 test/unit/associations/test_one_association.rb
mongo_mapper-0.11.2 test/unit/associations/test_one_association.rb
jamieorc-mongo_mapper-0.11.1.1 test/unit/associations/test_one_association.rb
mongo_mapper-0.11.1 test/unit/associations/test_one_association.rb
mongo_mapper-0.11.0 test/unit/associations/test_one_association.rb