Sha256: 91e23ebbb1cc5f830e055ce2bcf14fc9b0f8bbd577ba613ab9b856030c093a8c

Contents?: true

Size: 889 Bytes

Versions: 2

Compression:

Stored size: 889 Bytes

Contents

require 'test_helper'

class TestRailsCompatibility < Test::Unit::TestCase
  class Item
    include MongoMapper::EmbeddedDocument
    key :for_all, String
  end

  class FirstItem < Item  
    key :first_only, String
    many :second_items
  end

  class SecondItem < Item
    key :second_only, String
  end
  
  context "EmbeddedDocument" do
    should "raise error for to_param as embedded do not have id's" do
      lambda { Item.new.to_param }.should raise_error
    end
    
    should "alias many to has_many" do
      FirstItem.should respond_to(:has_many)
      FirstItem.method(:has_many).should == FirstItem.method(:many)
    end
    
    should "have column names" do
      Item.column_names.sort.should == ['for_all']
      FirstItem.column_names.sort.should == ['first_only', 'for_all']
      SecondItem.column_names.sort.should == ['for_all', 'second_only']
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jnunemaker-mongomapper-0.3.0 test/unit/test_rails_compatibility.rb
jnunemaker-mongomapper-0.3.1 test/unit/test_rails_compatibility.rb