eventus 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Eventus
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -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.db.collection('eventus_commits').drop
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)) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: