gallifrey 0.1.0.beta2 → 0.1.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gallifrey/event_store/sequel.rb +3 -4
- data/lib/gallifrey/version.rb +1 -1
- data/spec/gallifrey/event_store/sequel/coverage/index.html +2 -2
- data/spec/gallifrey/event_store/sequel/coverage/resultset.yml +20 -0
- data/spec/gallifrey/event_store/sequel/load_events_spec.rb +1 -2
- data/spec/gallifrey/event_store/sequel/save_events_spec.rb +4 -8
- metadata +1 -1
@@ -15,7 +15,6 @@ module Gallifrey
|
|
15
15
|
uuid :id, :null => false
|
16
16
|
text :type, :null => false
|
17
17
|
integer :version, :null => false
|
18
|
-
timestamp :updated_at, :null => false
|
19
18
|
primary_key [:id]
|
20
19
|
end
|
21
20
|
|
@@ -60,11 +59,11 @@ module Gallifrey
|
|
60
59
|
end
|
61
60
|
|
62
61
|
def save_events(aggregate_type, aggregate_id, events)
|
63
|
-
|
62
|
+
version = events.last.aggregate_version
|
64
63
|
|
65
64
|
update_count = @aggregates_table
|
66
65
|
.filter(:id => aggregate_id, :type => aggregate_type, :version => events.first.aggregate_version - 1)
|
67
|
-
.update(
|
66
|
+
.update(:version => version)
|
68
67
|
|
69
68
|
if update_count == 0
|
70
69
|
if aggregate_record = @aggregates_table.first(:id => aggregate_id)
|
@@ -72,7 +71,7 @@ module Gallifrey
|
|
72
71
|
raise(Conflict)
|
73
72
|
end
|
74
73
|
|
75
|
-
@aggregates_table.insert(
|
74
|
+
@aggregates_table.insert(:id => aggregate_id, :type => aggregate_type, :version => version)
|
76
75
|
end
|
77
76
|
|
78
77
|
events.each do |event|
|
data/lib/gallifrey/version.rb
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
<img src="./assets/0.4.4/loading.gif" alt="loading"/>
|
22
22
|
</div>
|
23
23
|
<div id="wrapper" style="display:none;">
|
24
|
-
<div class="timestamp">Generated <abbr class="timeago" title="2011-04-
|
24
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2011-04-17T22:45:48+10:00">2011-04-17T22:45:48+10:00</abbr></div>
|
25
25
|
<ul class="group_tabs"></ul>
|
26
26
|
|
27
27
|
<div id="content">
|
@@ -60,7 +60,7 @@
|
|
60
60
|
<div id="footer">
|
61
61
|
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.4.2
|
62
62
|
and simplecov-html v0.4.4<br/>
|
63
|
-
using /tmp/textmate-command-
|
63
|
+
using /tmp/textmate-command-80823.rb , /tmp/textmate-command-80967.rb , /tmp/textmate-command-81038.rb , /tmp/textmate-command-81111.rb , /tmp/textmate-command-81279.rb
|
64
64
|
</div>
|
65
65
|
|
66
66
|
<div class="source_files">
|
@@ -135,3 +135,23 @@
|
|
135
135
|
:original_result: {}
|
136
136
|
|
137
137
|
:created_at: 2011-04-16 21:15:18.522344 +10:00
|
138
|
+
"/tmp/textmate-command-80823.rb ":
|
139
|
+
:original_result: {}
|
140
|
+
|
141
|
+
:created_at: 2011-04-17 22:42:49.838884 +10:00
|
142
|
+
"/tmp/textmate-command-80967.rb ":
|
143
|
+
:original_result: {}
|
144
|
+
|
145
|
+
:created_at: 2011-04-17 22:45:02.971485 +10:00
|
146
|
+
"/tmp/textmate-command-81038.rb ":
|
147
|
+
:original_result: {}
|
148
|
+
|
149
|
+
:created_at: 2011-04-17 22:45:13.476721 +10:00
|
150
|
+
"/tmp/textmate-command-81111.rb ":
|
151
|
+
:original_result: {}
|
152
|
+
|
153
|
+
:created_at: 2011-04-17 22:45:23.489461 +10:00
|
154
|
+
"/tmp/textmate-command-81279.rb ":
|
155
|
+
:original_result: {}
|
156
|
+
|
157
|
+
:created_at: 2011-04-17 22:45:48.817479 +10:00
|
@@ -34,8 +34,7 @@ describe Gallifrey::EventStore::Sequel do
|
|
34
34
|
database[:aggregates].insert(
|
35
35
|
:id => aggregate_id,
|
36
36
|
:type => aggregate_type,
|
37
|
-
:version => events.first.aggregate_version - 1
|
38
|
-
:updated_at => Time.now
|
37
|
+
:version => events.first.aggregate_version - 1
|
39
38
|
)
|
40
39
|
|
41
40
|
events.each do |event|
|
@@ -38,8 +38,7 @@ describe Gallifrey::EventStore::Sequel do
|
|
38
38
|
it "records the aggregate" do
|
39
39
|
database[:aggregates].where(
|
40
40
|
:type => aggregate_type,
|
41
|
-
:version => events.last.aggregate_version
|
42
|
-
:updated_at => created_at
|
41
|
+
:version => events.last.aggregate_version
|
43
42
|
).should_not be_empty
|
44
43
|
end
|
45
44
|
|
@@ -68,8 +67,7 @@ describe Gallifrey::EventStore::Sequel do
|
|
68
67
|
database[:aggregates].insert(
|
69
68
|
:id => aggregate_id,
|
70
69
|
:type => aggregate_type,
|
71
|
-
:version => events.first.aggregate_version - 1
|
72
|
-
:updated_at => Time.now
|
70
|
+
:version => events.first.aggregate_version - 1
|
73
71
|
)
|
74
72
|
end
|
75
73
|
|
@@ -85,8 +83,7 @@ describe Gallifrey::EventStore::Sequel do
|
|
85
83
|
database[:aggregates].insert(
|
86
84
|
:id => aggregate_id,
|
87
85
|
:type => aggregate_type,
|
88
|
-
:version => events.first.aggregate_version - 1
|
89
|
-
:updated_at => events.last.created_at
|
86
|
+
:version => events.first.aggregate_version - 1
|
90
87
|
)
|
91
88
|
|
92
89
|
subject.save_events(aggregate_type, aggregate_id, events)
|
@@ -115,8 +112,7 @@ describe Gallifrey::EventStore::Sequel do
|
|
115
112
|
database[:aggregates].insert(
|
116
113
|
:id => aggregate_id,
|
117
114
|
:type => aggregate_type,
|
118
|
-
:version => events.last.aggregate_version + 1
|
119
|
-
:updated_at => events.last.created_at
|
115
|
+
:version => events.last.aggregate_version + 1
|
120
116
|
)
|
121
117
|
end
|
122
118
|
|