eventus 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/eventus/persistence/mongo.rb +3 -1
- data/lib/eventus/version.rb +1 -1
- data/spec/persistence/mongo_spec.rb +14 -1
- metadata +1 -1
@@ -3,12 +3,14 @@ require 'mongo'
|
|
3
3
|
module Eventus
|
4
4
|
module Persistence
|
5
5
|
class Mongo
|
6
|
-
attr_reader :db
|
6
|
+
attr_reader :db, :commits
|
7
7
|
|
8
8
|
def initialize(uri, options={})
|
9
9
|
collection_name = options.delete(:collection) || 'eventus_commits'
|
10
10
|
@db = build_db(uri, options)
|
11
11
|
@commits = db.collection(collection_name)
|
12
|
+
@commits.ensure_index :sid => ::Mongo::ASCENDING
|
13
|
+
@commits.ensure_index :sid => ::Mongo::ASCENDING, :min => ::Mongo::ASCENDING
|
12
14
|
end
|
13
15
|
|
14
16
|
def commit(events)
|
data/lib/eventus/version.rb
CHANGED
@@ -5,8 +5,11 @@ describe Eventus::Persistence::Mongo do
|
|
5
5
|
let(:uuid) { UUID.new }
|
6
6
|
|
7
7
|
before(:all) do
|
8
|
+
#Wipe collection
|
9
|
+
Eventus::Persistence::Mongo.new(MONGO_URI).commits.drop
|
10
|
+
|
8
11
|
@persistence = Eventus::Persistence::Mongo.new(MONGO_URI)
|
9
|
-
@persistence.
|
12
|
+
@persistence.commits.remove
|
10
13
|
end
|
11
14
|
|
12
15
|
it "should store complex objects" do
|
@@ -35,6 +38,16 @@ describe Eventus::Persistence::Mongo do
|
|
35
38
|
result.map{|r| r['body']}.should == ["one", "two", "three", "four", "five", "six"]
|
36
39
|
end
|
37
40
|
|
41
|
+
it "should create an index on sid" do
|
42
|
+
indexes = persistence.commits.index_information
|
43
|
+
indexes.any? { |_,v| v['key'] == {'sid' => 1} }.should == true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should create an index on sid, min" do
|
47
|
+
indexes = persistence.commits.index_information
|
48
|
+
indexes.any? { |_,v| v['key'] == {'sid' => 1, 'min' => 1} }.should == true
|
49
|
+
end
|
50
|
+
|
38
51
|
describe "when events exist" do
|
39
52
|
let(:id) { uuid.generate :compact }
|
40
53
|
let(:events) { create_commit(id, 1, *(1..5)) }
|