entity_store_sequel 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 361d28851423cc180b280e05f09e16ba108a2e45
|
4
|
+
data.tar.gz: 7e2b036a72a4ecc2e3d5798adec32f9b2b7ee689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4eb8021d8ff9ed24ab68e23efff0a4b2bb14fac2f1871016d3342e8b707291f905490d4b4f6cfbf3e40449ab7e30f4b32686a6b5a70f89a86a66208d3010da9
|
7
|
+
data.tar.gz: 47849c8300bf7bbe69dfaf46c9d7fb0e441b07a73b4da9164be5ecdf0ffc115aae0585584ff61d63d118252637dc8fd26a9202cc76bc188841315cbf51ef0c54
|
@@ -61,6 +61,14 @@ module EntityStoreSequel
|
|
61
61
|
def ensure_indexes
|
62
62
|
end
|
63
63
|
|
64
|
+
def clear_entity_events(id, excluded_types)
|
65
|
+
events.where(_entity_id: id).each do |event|
|
66
|
+
next if excluded_types.include?(event[:_type])
|
67
|
+
|
68
|
+
events.where(id: event[:id]).delete
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
64
72
|
def add_entity(entity, id = BSON::ObjectId.new)
|
65
73
|
entities.insert(:id => id.to_s, :_type => entity.class.name, :version => entity.version)
|
66
74
|
id.to_s
|
@@ -114,6 +114,36 @@ describe PostgresEntityStore do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
describe "#clear_entity_events" do
|
118
|
+
let(:entity_id) { random_object_id }
|
119
|
+
let(:second_entity_id) { random_object_id }
|
120
|
+
|
121
|
+
let(:first_event) { DummyEntityNameSet.new(:entity_id => entity_id, :entity_version => 1, :name => random_string) }
|
122
|
+
let(:second_event) { DummyEntityNameSet.new(:entity_id => entity_id, :entity_version => 2, :name => random_string) }
|
123
|
+
let(:third_event) { DummyEntityNameSet.new(:entity_id => entity_id, :entity_version => 2, :name => random_string) }
|
124
|
+
let(:unrelated_event) { DummyEntityNameSet.new(:entity_id => second_entity_id, :entity_version => 4, :name => random_string) }
|
125
|
+
let(:fourth_event) { DummyEntityNameSet.new(:entity_id => entity_id, :entity_version => 3, :name => random_string) }
|
126
|
+
|
127
|
+
before do
|
128
|
+
store.add_events([ second_event, unrelated_event, first_event, third_event, fourth_event ])
|
129
|
+
end
|
130
|
+
|
131
|
+
subject { store.clear_entity_events(entity_id, []) }
|
132
|
+
|
133
|
+
it "clears the events from the entity" do
|
134
|
+
subject
|
135
|
+
events = store.get_events( [ id: entity_id ])[entity_id]
|
136
|
+
expect(events).to be_empty
|
137
|
+
end
|
138
|
+
|
139
|
+
it "does not delete unrelated the events" do
|
140
|
+
subject
|
141
|
+
events = store.get_events( [ id: second_entity_id ])[second_entity_id]
|
142
|
+
expect(events.count).to eq(1)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
|
117
147
|
describe "#get_entities" do
|
118
148
|
let(:entity_class) { DummyEntityWithDate }
|
119
149
|
let(:entity_date) { random_time }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: entity_store_sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Binns
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.4.5.1
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Sequel body for Entity Store
|