mongo-ruby-driver/test/unit/grid_test.rb
Kyle Banker 68af3dbe8f Allow the setting of safe mode globally on the Connection,
DB, and Collection levels. The safe mode setting will
automatically be inherited down the hierarchy Connection ->
DB -> Collection -> (insert, update, remove). This default
can be overridden at any time. Connection#safe, DB#safe, and
Collection#safe will yield the current default value.
2010-11-03 17:36:08 -04:00

50 lines
1.1 KiB
Ruby

require './test/test_helper'
class GridTest < Test::Unit::TestCase
context "GridFS: " do
setup do
@conn = stub()
@conn.stubs(:safe)
@db = DB.new("testing", @conn)
@files = mock()
@chunks = mock()
@db.expects(:[]).with('fs.files').returns(@files)
@db.expects(:[]).with('fs.chunks').returns(@chunks)
@db.stubs(:safe)
end
context "Grid classe with standard connections" do
setup do
@conn.expects(:slave_ok?).returns(false)
end
should "create indexes for Grid" do
@chunks.expects(:create_index)
Grid.new(@db)
end
should "create indexes for GridFileSystem" do
@files.expects(:create_index)
@chunks.expects(:create_index)
GridFileSystem.new(@db)
end
end
context "Grid classes with slave connection" do
setup do
@conn.expects(:slave_ok?).returns(true)
end
should "not create indexes for Grid" do
Grid.new(@db)
end
should "not create indexes for GridFileSystem" do
GridFileSystem.new(@db)
end
end
end
end