Sha256: 9e7f24ea828bf0f6cf4f397544482b356aecf36542a43d6831173c0e288d5237

Contents?: true

Size: 1.16 KB

Versions: 20

Compression:

Stored size: 1.16 KB

Contents

require 'test_helper'

class TestRailsCompatibility < Test::Unit::TestCase
  class BigStuff
    include MongoMapper::Document
  end
  
  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
    
    should "implement human_name" do
      Item.human_name.should == 'Item'
    end
  end
  
  context "Document" do
    should "implement human_name" do
      BigStuff.human_name.should == 'Big Stuff'
    end
  end
end

Version data entries

20 entries across 20 versions & 5 rubygems

Version Path
tpitale-mongo_mapper-0.6.9 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.12.30 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.12.29 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.12.23 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.12.22 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.12.16 test/unit/test_rails_compatibility.rb
mongo_mapper-0.6.8 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.12.14 test/unit/test_rails_compatibility.rb
mongo_mapper-0.6.7 test/unit/test_rails_compatibility.rb
mongo_mapper-0.6.6 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.12.4 test/unit/test_rails_compatibility.rb
danielharan-mongo_mapper-0.6.5 test/unit/test_rails_compatibility.rb
mongo_mapper-0.6.5 test/unit/test_rails_compatibility.rb
webbynode-mongo_mapper-0.6.4 test/unit/test_rails_compatibility.rb
mongo_mapper-0.6.4 test/unit/test_rails_compatibility.rb
mongo_mapper-0.6.3 test/unit/test_rails_compatibility.rb
mongo_mapper-0.6.2 test/unit/test_rails_compatibility.rb
mongo_mapper-0.6.1 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2009.11.18 test/unit/test_rails_compatibility.rb
mongo_mapper-0.6.0 test/unit/test_rails_compatibility.rb