Sha256: 69f1074a46658d38ea5a853185233ea8270be1d328ad44c7b72617117dc02929

Contents?: true

Size: 1.18 KB

Versions: 58

Compression:

Stored size: 1.18 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)
    end
    
    should "alias one to has_one" do
      FirstItem.should respond_to(:has_one)
    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

58 entries across 58 versions & 7 rubygems

Version Path
numon-0.0.1 test/unit/test_rails_compatibility.rb
mongo_mapper-0.7.2 test/unit/test_rails_compatibility.rb
mongo_mapper-0.7.1 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.3.8 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.3.5 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.3.4 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.3.3 test/unit/test_rails_compatibility.rb
drogus-mongo_mapper-0.6.10 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.28 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.27 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.26 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.25 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.24 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.23 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.22 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.19 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.18 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.17 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.16 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.2.15 test/unit/test_rails_compatibility.rb