Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RUBY-193 don't create gridfs indexes when slave_ok
- Loading branch information
Showing
3 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require './test/test_helper' | ||
|
||
class GridTest < Test::Unit::TestCase | ||
|
||
context "GridFS: " do | ||
setup do | ||
@conn = stub() | ||
@db = DB.new("testing", @conn) | ||
@files = mock() | ||
@chunks = mock() | ||
|
||
@db.expects(:[]).with('fs.files').returns(@files) | ||
@db.expects(:[]).with('fs.chunks').returns(@chunks) | ||
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 |