Sha256: 2a3aa3f69b103ba6e12e85ed9896a6df08afad46645e8adf0df56435490541e0

Contents?: true

Size: 908 Bytes

Versions: 19

Compression:

Stored size: 908 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 "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 == ['_id', 'for_all']
      FirstItem.column_names.sort.should == ['_id', 'first_only', 'for_all']
      SecondItem.column_names.sort.should == ['_id', 'for_all', 'second_only']
    end
    
    should "alias new to new_record?" do
      instance = Item.new
      instance.new_record?.should == instance.new?
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
mongo_mapper-unstable-2009.11.8 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.11.6 test/unit/test_rails_compatibility.rb
djsun-mongo_mapper-0.5.8.2 test/unit/test_rails_compatibility.rb
djsun-mongo_mapper-0.5.8.1 test/unit/test_rails_compatibility.rb
djsun-mongo_mapper-0.5.6.6 test/unit/test_rails_compatibility.rb
djsun-mongo_mapper-0.5.6.5 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.11.2 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.10.31 test/unit/test_rails_compatibility.rb
mongo_mapper-0.5.8 test/unit/test_rails_compatibility.rb
mongo_mapper-0.5.7 test/unit/test_rails_compatibility.rb
djsun-mongo_mapper-0.5.6.4 test/unit/test_rails_compatibility.rb
djsun-mongo_mapper-0.5.6.3 test/unit/test_rails_compatibility.rb
djsun-mongo_mapper-0.5.6.2 test/unit/test_rails_compatibility.rb
djsun-mongo_mapper-0.5.6.1 test/unit/test_rails_compatibility.rb
mongo_mapper-0.5.6 test/unit/test_rails_compatibility.rb
djsun-mongo_mapper-0.5.5.3 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.10.16 test/unit/test_rails_compatibility.rb
djsun-mongo_mapper-0.5.5.2 test/unit/test_rails_compatibility.rb
mongo_mapper-0.5.5 test/unit/test_rails_compatibility.rb