Sha256: cb6249d9973868fe26058598f3d978cc2cd372c617dd3bcfbb065a52e9ef1c89

Contents?: true

Size: 1.18 KB

Versions: 62

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', '_type', 'for_all']
      FirstItem.column_names.sort.should == ['_id', '_type', 'first_only', 'for_all']
      SecondItem.column_names.sort.should == ['_id', '_type', '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

62 entries across 62 versions & 8 rubygems

Version Path
jonbell-mongo_mapper-0.8.6 test/unit/test_rails_compatibility.rb
mongo_mapper-0.9.0 test/unit/test_rails_compatibility.rb
ign-mongo_mapper-0.8.6.2 test/unit/test_rails_compatibility.rb
ign-mongo_mapper-0.8.6.1 test/unit/test_rails_compatibility.rb
ssherman-mongo_mapper-0.8.6 test/unit/test_rails_compatibility.rb
mongo_mapper-0.8.6 test/unit/test_rails_compatibility.rb
mongo_mapper-0.8.5 test/unit/test_rails_compatibility.rb
honkster-mongo_mapper-0.8.4 test/unit/test_rails_compatibility.rb
mongo_mapper-0.8.4 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.19 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.18 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.17 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.16 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.15 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.14 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.13 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.12 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.11 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.10 test/unit/test_rails_compatibility.rb
mongo_mapper-unstable-2010.08.09 test/unit/test_rails_compatibility.rb