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: 0c310ad09d9b4c46c37e3c65753c468f320b6173
4
- data.tar.gz: aa05911221ca3d090312bc1f1a2db571e15292fc
3
+ metadata.gz: 361d28851423cc180b280e05f09e16ba108a2e45
4
+ data.tar.gz: 7e2b036a72a4ecc2e3d5798adec32f9b2b7ee689
5
5
  SHA512:
6
- metadata.gz: a209d82e693a10f10a902fbfbd6d181db7097b83917d0b262fa610220156680d464a83a036470f5b92711830a6af2c5833b02e0fcc451ed9a014507e0f00c63b
7
- data.tar.gz: aacc583d939547bb89377be02c27dead10946aebe0c7fdd0d40931d33e6997eb042f73405ac6d41ecc95f1a6df08ae07e14df59f1670c4ca6c34f85f75e3c399
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
@@ -1,3 +1,3 @@
1
1
  module EntityStoreSequel
2
- VERSION = "0.0.11".freeze
2
+ VERSION = "0.0.12".freeze
3
3
  end
@@ -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.11
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: 2017-12-01 00:00:00.000000000 Z
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.6.12
120
+ rubygems_version: 2.4.5.1
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Sequel body for Entity Store