Sha256: e8c630108d0ef6f2a8ef9225a63154894ac3bf780361e839a4d500786d2ec05e

Contents?: true

Size: 928 Bytes

Versions: 2

Compression:

Stored size: 928 Bytes

Contents

require 'test_helper'
require 'models'

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

  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
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongo_mapper-0.10.1 test/unit/associations/test_one_association.rb
mongo_mapper-0.10.0 test/unit/associations/test_one_association.rb