Sha256: 6222e4bf2f2cd1a8e04bd1cc4e4e66adc6bfcc827321f4abea525db93e6e830a

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'


module OneAssociationSpec
  include MarkMapper::Plugins::Associations
  describe "OneAssociation" do

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

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

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

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

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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mark_mapper-0.0.6 spec/unit/associations/one_association_spec.rb
mark_mapper-0.0.5 spec/unit/associations/one_association_spec.rb
mark_mapper-0.0.4 spec/unit/associations/one_association_spec.rb
mark_mapper-0.0.3 spec/unit/associations/one_association_spec.rb
mark_mapper-0.0.2 spec/unit/associations/one_association_spec.rb
mark_mapper-0.0.1 spec/unit/associations/one_association_spec.rb