sequel_bitemporal 0.5.3 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sequel/plugins/bitemporal.rb +17 -16
- data/sequel_bitemporal.gemspec +1 -1
- data/spec/bitemporal_date_spec.rb +30 -30
- data/spec/bitemporal_time_spec.rb +17 -17
- metadata +2 -2
@@ -145,23 +145,19 @@ module Sequel
|
|
145
145
|
end
|
146
146
|
|
147
147
|
def attributes=(attributes)
|
148
|
-
if attributes.delete(:partial_update) && !@pending_version && !new? && current_version
|
149
|
-
@current_version_values = current_version.values
|
150
|
-
current_attributes = current_version.keys.inject({}) do |hash, key|
|
151
|
-
hash[key] = current_version.send key
|
152
|
-
hash
|
153
|
-
end
|
154
|
-
current_attributes.delete :valid_from
|
155
|
-
current_attributes.delete :valid_to
|
156
|
-
attributes = current_attributes.merge attributes
|
157
|
-
elsif !new? && current_version
|
158
|
-
@current_version_values = current_version.values
|
159
|
-
end
|
160
|
-
attributes.delete :id
|
161
148
|
if attributes_hold_changes? attributes
|
162
|
-
@pending_version ||=
|
149
|
+
@pending_version ||= begin
|
150
|
+
current_attributes = {}
|
151
|
+
current_version.keys.each do |key|
|
152
|
+
case key
|
153
|
+
when :id, :valid_from, :valid_to, :created_at, :expired_at
|
154
|
+
else
|
155
|
+
current_attributes[key] = current_version.send key
|
156
|
+
end
|
157
|
+
end if current_version?
|
158
|
+
model.version_class.new current_attributes
|
159
|
+
end
|
163
160
|
pending_version.set attributes
|
164
|
-
pending_version.master_id = id unless new?
|
165
161
|
end
|
166
162
|
end
|
167
163
|
|
@@ -332,8 +328,13 @@ module Sequel
|
|
332
328
|
propagated
|
333
329
|
end
|
334
330
|
|
331
|
+
def current_version?
|
332
|
+
!new? && current_version
|
333
|
+
end
|
334
|
+
|
335
335
|
def attributes_hold_changes?(attributes)
|
336
|
-
return true
|
336
|
+
return true unless current_version?
|
337
|
+
@current_version_values = current_version.values
|
337
338
|
attributes.detect do |key, new_value|
|
338
339
|
case key
|
339
340
|
when :master_id, :created_at, :expired_at
|
data/sequel_bitemporal.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "sequel_bitemporal"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.6.1"
|
7
7
|
s.authors = ["Joseph HALTER", "Jonathan TRON"]
|
8
8
|
s.email = ["joseph.halter@thetalentbox.com", "jonathan.tron@thetalentbox.com"]
|
9
9
|
s.homepage = "https://github.com/TalentBox/sequel_bitemporal"
|
@@ -75,8 +75,8 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
75
75
|
it "allows partial updating based on current version" do
|
76
76
|
master = @master_class.new
|
77
77
|
master.update_attributes name: "Single Standard", price: 98
|
78
|
-
master.update_attributes price: 94
|
79
|
-
master.update_attributes name: "King Size"
|
78
|
+
master.update_attributes price: 94
|
79
|
+
master.update_attributes name: "King Size"
|
80
80
|
master.should have_versions %Q{
|
81
81
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
82
82
|
| Single Standard | 98 | 2009-11-28 | 2009-11-28 | 2009-11-28 | MAX DATE | |
|
@@ -88,7 +88,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
88
88
|
master = @master_class.new
|
89
89
|
master.update_attributes name: "Single Standard", price: 98
|
90
90
|
Timecop.freeze Date.today+1
|
91
|
-
master.update_attributes price: 94
|
91
|
+
master.update_attributes price: 94
|
92
92
|
master.should have_versions %Q{
|
93
93
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
94
94
|
| Single Standard | 98 | 2009-11-28 | 2009-11-29 | 2009-11-28 | MAX DATE | |
|
@@ -100,7 +100,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
100
100
|
master = @master_class.new
|
101
101
|
master.update_attributes name: "Single Standard", price: 98, valid_to: Date.today+1
|
102
102
|
Timecop.freeze Date.today+1
|
103
|
-
master.update_attributes(price: 94
|
103
|
+
master.update_attributes(price: 94).should be_false
|
104
104
|
master.update_attributes name: "Single Standard", price: 94
|
105
105
|
master.should have_versions %Q{
|
106
106
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
@@ -112,7 +112,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
112
112
|
master = @master_class.new
|
113
113
|
master.update_attributes name: "Single Standard", price: 98
|
114
114
|
Timecop.freeze Date.today+1
|
115
|
-
master.update_attributes valid_to: Date.today+10
|
115
|
+
master.update_attributes valid_to: Date.today+10
|
116
116
|
master.should have_versions %Q{
|
117
117
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
118
118
|
| Single Standard | 98 | 2009-11-28 | 2009-11-29 | 2009-11-28 | MAX DATE | |
|
@@ -132,7 +132,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
132
132
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
133
133
|
| Single Standard | 98 | 2009-11-28 | | 2009-11-28 | 2009-11-30 | true |
|
134
134
|
}
|
135
|
-
master.update_attributes valid_to: nil
|
135
|
+
master.update_attributes valid_to: nil
|
136
136
|
master.should have_versions %Q{
|
137
137
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
138
138
|
| Single Standard | 98 | 2009-11-28 | 2009-11-29 | 2009-11-28 | 2009-11-30 | |
|
@@ -147,7 +147,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
147
147
|
it "don't create any new version without change" do
|
148
148
|
master = @master_class.new
|
149
149
|
master.update_attributes name: "Single Standard", price: 98
|
150
|
-
master.update_attributes price: 98
|
150
|
+
master.update_attributes price: 98
|
151
151
|
master.update_attributes name: "Single Standard", price: 98
|
152
152
|
master.should have_versions %Q{
|
153
153
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
@@ -158,8 +158,8 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
158
158
|
master = @master_class.new
|
159
159
|
master.update_attributes name: "Single Standard", price: 98
|
160
160
|
Timecop.freeze Date.today+1
|
161
|
-
master.update_attributes price: 98,
|
162
|
-
master.update_attributes price: 98,
|
161
|
+
master.update_attributes price: 98, valid_from: Date.today-2
|
162
|
+
master.update_attributes price: 98, valid_from: Date.today+1
|
163
163
|
master.should have_versions %Q{
|
164
164
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
165
165
|
| Single Standard | 98 | 2009-11-28 | | 2009-11-28 | MAX DATE | true |
|
@@ -176,7 +176,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
176
176
|
master.update_attributes name: "Single Standard", price: 94, valid_from: Date.today+2, valid_to: Date.today+4
|
177
177
|
master.update_attributes name: "Single Standard", price: 95, valid_from: Date.today+4, valid_to: Date.today+6
|
178
178
|
Timecop.freeze Date.today+1
|
179
|
-
master.update_attributes name: "King Size", valid_to: nil
|
179
|
+
master.update_attributes name: "King Size", valid_to: nil
|
180
180
|
master.should have_versions %Q{
|
181
181
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
182
182
|
| Single Standard | 98 | 2009-11-28 | 2009-11-29 | 2009-11-28 | 2009-11-30 | |
|
@@ -192,7 +192,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
192
192
|
master.update_attributes name: "Single Standard", price: 94, valid_from: Date.today+2, valid_to: Date.today+4
|
193
193
|
master.update_attributes name: "Single Standard", price: 95, valid_from: Date.today+4, valid_to: Date.today+6
|
194
194
|
Timecop.freeze Date.today+1
|
195
|
-
master.update_attributes name: "King Size", valid_to: Date.today+4
|
195
|
+
master.update_attributes name: "King Size", valid_to: Date.today+4
|
196
196
|
master.should have_versions %Q{
|
197
197
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
198
198
|
| Single Standard | 98 | 2009-11-28 | 2009-11-29 | 2009-11-28 | 2009-11-30 | |
|
@@ -209,7 +209,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
209
209
|
master.update_attributes name: "Single Standard", price: 94, valid_from: Date.today+2, valid_to: Date.today+4
|
210
210
|
master.update_attributes name: "Single Standard", price: 95, valid_from: Date.today+4, valid_to: Date.today+6
|
211
211
|
Timecop.freeze Date.today+1
|
212
|
-
master.update_attributes name: "King Size", valid_to: Time.utc(9999)
|
212
|
+
master.update_attributes name: "King Size", valid_to: Time.utc(9999)
|
213
213
|
master.should have_versions %Q{
|
214
214
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
215
215
|
| Single Standard | 98 | 2009-11-28 | 2009-11-29 | 2009-11-28 | 2009-11-30 | |
|
@@ -312,8 +312,8 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
312
312
|
master.update_attributes name: "Single Standard", price: 98
|
313
313
|
Timecop.freeze Date.today+1
|
314
314
|
master2 = @master_class.find id: master.id
|
315
|
-
master.update_attributes price: 94
|
316
|
-
master2.update_attributes name: "King Size"
|
315
|
+
master.update_attributes price: 94
|
316
|
+
master2.update_attributes name: "King Size"
|
317
317
|
master.should have_versions %Q{
|
318
318
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
319
319
|
| Single Standard | 98 | 2009-11-28 | 2009-11-29 | 2009-11-28 | MAX DATE | |
|
@@ -328,7 +328,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
328
328
|
master.current_version.should_not be_valid
|
329
329
|
master.current_version.save validate: false
|
330
330
|
Timecop.freeze Date.today+1
|
331
|
-
master.update_attributes price: 94
|
331
|
+
master.update_attributes price: 94
|
332
332
|
master.should have_versions %Q{
|
333
333
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
334
334
|
| Single Standard | | 2009-11-28 | 2009-11-29 | 2009-11-28 | MAX DATE | |
|
@@ -344,13 +344,13 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
344
344
|
master.update_attributes name: "Single Standard", price: 12, length: nil, width: 1
|
345
345
|
initial_today = Date.today
|
346
346
|
Timecop.freeze initial_today+1 do
|
347
|
-
master.update_attributes valid_from: initial_today+4, name: "King Size", price: 15, length: 2, width: 2
|
347
|
+
master.update_attributes valid_from: initial_today+4, name: "King Size", price: 15, length: 2, width: 2
|
348
348
|
end
|
349
349
|
Timecop.freeze initial_today+2 do
|
350
|
-
master.update_attributes valid_from: initial_today+3, length: 1, width: 1
|
350
|
+
master.update_attributes valid_from: initial_today+3, length: 1, width: 1
|
351
351
|
end
|
352
352
|
Timecop.freeze initial_today+3 do
|
353
|
-
master.update_attributes valid_from: initial_today+2, length: 3, width: 4
|
353
|
+
master.update_attributes valid_from: initial_today+2, length: 3, width: 4
|
354
354
|
end
|
355
355
|
master.should have_versions %Q{
|
356
356
|
| name | price | length | width | created_at | expired_at | valid_from | valid_to | current |
|
@@ -407,8 +407,8 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
407
407
|
master.update_attributes name: "Single Standard", price: 93, valid_from: Date.today+2, valid_to: Date.today+3
|
408
408
|
master.update_attributes name: "Single Standard", price: 91, valid_from: Date.today+3
|
409
409
|
Timecop.freeze Date.today+1
|
410
|
-
master.update_attributes price: 94
|
411
|
-
master.update_attributes price: 96,
|
410
|
+
master.update_attributes price: 94
|
411
|
+
master.update_attributes price: 96, valid_from: Date.today+2
|
412
412
|
master.should have_versions %Q{
|
413
413
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
414
414
|
| Single Standard | 98 | 2009-11-28 | | 2009-11-28 | 2009-11-29 | |
|
@@ -490,7 +490,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
490
490
|
master.name.should be_nil
|
491
491
|
master.update_attributes name: "Single Standard", price: 98
|
492
492
|
master.name.should == "Single Standard"
|
493
|
-
master.attributes = {name: "King Size"
|
493
|
+
master.attributes = {name: "King Size"}
|
494
494
|
master.name.should == "King Size"
|
495
495
|
end
|
496
496
|
it "avoids delegation with option delegate: false" do
|
@@ -519,7 +519,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
519
519
|
it "can update master and current version at the same time" do
|
520
520
|
master = @master_class.new.update_attributes name: "Single Standard", price: 98
|
521
521
|
master.disabled = true
|
522
|
-
master.update_attributes price: 94
|
522
|
+
master.update_attributes price: 94
|
523
523
|
master.reload.disabled.should be_true
|
524
524
|
end
|
525
525
|
it "uses current version for partial_update even if valid_from is specified" do
|
@@ -531,7 +531,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
531
531
|
| Single Standard | 98 | 2009-11-28 | | 2009-11-26 | 2009-11-28 | |
|
532
532
|
| Single Standard | 94 | 2009-11-28 | | 2009-11-28 | MAX DATE | true |
|
533
533
|
}
|
534
|
-
master.update_attributes name: "King Size",
|
534
|
+
master.update_attributes name: "King Size", valid_from: Date.today-2
|
535
535
|
master.should have_versions %Q{
|
536
536
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
537
537
|
| Single Standard | 98 | 2009-11-28 | 2009-11-28 | 2009-11-26 | 2009-11-28 | |
|
@@ -543,7 +543,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
543
543
|
master = @master_class.new
|
544
544
|
master.update_attributes name: "Single Standard", price: 98
|
545
545
|
Sequel::Plugins::Bitemporal.as_we_knew_it(Date.today+1) do
|
546
|
-
master.update_attributes name: "King Size"
|
546
|
+
master.update_attributes name: "King Size"
|
547
547
|
end
|
548
548
|
master.should have_versions %Q{
|
549
549
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
@@ -571,7 +571,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
571
571
|
}
|
572
572
|
Sequel::Plugins::Bitemporal.as_we_knew_it(Date.today+1) do
|
573
573
|
Sequel::Plugins::Bitemporal.at(Date.today-1) do
|
574
|
-
master.update_attributes name: "King Size"
|
574
|
+
master.update_attributes name: "King Size"
|
575
575
|
end
|
576
576
|
end
|
577
577
|
master.should have_versions %Q{
|
@@ -635,7 +635,7 @@ describe "Sequel::Plugins::Bitemporal", "with audit" do
|
|
635
635
|
Date.today,
|
636
636
|
author
|
637
637
|
)
|
638
|
-
master.update_attributes
|
638
|
+
master.update_attributes name: "King size", price: 98
|
639
639
|
end
|
640
640
|
it "generate a new audit for each future version update when propagating changes" do
|
641
641
|
propagate_per_column = @master_class.propagate_per_column
|
@@ -648,12 +648,12 @@ describe "Sequel::Plugins::Bitemporal", "with audit" do
|
|
648
648
|
initial_today = Date.today
|
649
649
|
Timecop.freeze initial_today+1 do
|
650
650
|
Sequel::Plugins::Bitemporal.at initial_today+4 do
|
651
|
-
master.update_attributes valid_from: initial_today+4, name: "King Size", price: 15, length: 2, width: 2
|
651
|
+
master.update_attributes valid_from: initial_today+4, name: "King Size", price: 15, length: 2, width: 2
|
652
652
|
end
|
653
653
|
end
|
654
654
|
Timecop.freeze initial_today+2 do
|
655
655
|
Sequel::Plugins::Bitemporal.at initial_today+3 do
|
656
|
-
master.update_attributes valid_from: initial_today+3, length: 1, width: 1
|
656
|
+
master.update_attributes valid_from: initial_today+3, length: 1, width: 1
|
657
657
|
end
|
658
658
|
end
|
659
659
|
@audit_class.should_receive(:audit).with(
|
@@ -672,7 +672,7 @@ describe "Sequel::Plugins::Bitemporal", "with audit" do
|
|
672
672
|
)
|
673
673
|
Timecop.freeze initial_today+3 do
|
674
674
|
Sequel::Plugins::Bitemporal.at initial_today+2 do
|
675
|
-
master.update_attributes valid_from: initial_today+2, length: 3, width: 4
|
675
|
+
master.update_attributes valid_from: initial_today+2, length: 3, width: 4
|
676
676
|
end
|
677
677
|
end
|
678
678
|
ensure
|
@@ -731,7 +731,7 @@ describe "Sequel::Plugins::Bitemporal", "with audit, specifying how to get the a
|
|
731
731
|
Date.today,
|
732
732
|
author
|
733
733
|
)
|
734
|
-
master.update_attributes
|
734
|
+
master.update_attributes name: "King size", price: 98
|
735
735
|
end
|
736
736
|
end
|
737
737
|
|
@@ -75,8 +75,8 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
75
75
|
it "allows partial updating based on current version" do
|
76
76
|
master = @master_class.new
|
77
77
|
master.update_attributes name: "Single Standard", price: 98
|
78
|
-
master.update_attributes price: 94
|
79
|
-
master.update_attributes name: "King Size"
|
78
|
+
master.update_attributes price: 94
|
79
|
+
master.update_attributes name: "King Size"
|
80
80
|
master.should have_versions %Q{
|
81
81
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
82
82
|
| Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
|
@@ -88,7 +88,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
88
88
|
master = @master_class.new
|
89
89
|
master.update_attributes name: "Single Standard", price: 98
|
90
90
|
Timecop.freeze Time.now+hour
|
91
|
-
master.update_attributes price: 94
|
91
|
+
master.update_attributes price: 94
|
92
92
|
master.should have_versions %Q{
|
93
93
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
94
94
|
| Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
|
@@ -100,7 +100,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
100
100
|
master = @master_class.new
|
101
101
|
master.update_attributes name: "Single Standard", price: 98, valid_to: Time.now+hour
|
102
102
|
Timecop.freeze Time.now+hour
|
103
|
-
master.update_attributes(price: 94
|
103
|
+
master.update_attributes(price: 94).should be_false
|
104
104
|
master.update_attributes name: "Single Standard", price: 94
|
105
105
|
master.should have_versions %Q{
|
106
106
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
@@ -112,7 +112,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
112
112
|
master = @master_class.new
|
113
113
|
master.update_attributes name: "Single Standard", price: 98
|
114
114
|
Timecop.freeze Time.now+hour
|
115
|
-
master.update_attributes valid_to: Time.now+10*hour
|
115
|
+
master.update_attributes valid_to: Time.now+10*hour
|
116
116
|
master.should have_versions %Q{
|
117
117
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
118
118
|
| Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
|
@@ -132,7 +132,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
132
132
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
133
133
|
| Single Standard | 98 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | true |
|
134
134
|
}
|
135
|
-
master.update_attributes valid_to: nil
|
135
|
+
master.update_attributes valid_to: nil
|
136
136
|
master.should have_versions %Q{
|
137
137
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
138
138
|
| Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
|
@@ -147,7 +147,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
147
147
|
it "don't create any new version without change " do
|
148
148
|
master = @master_class.new
|
149
149
|
master.update_attributes name: "Single Standard", price: 98
|
150
|
-
master.update_attributes price: 98
|
150
|
+
master.update_attributes price: 98
|
151
151
|
master.update_attributes name: "Single Standard", price: 98
|
152
152
|
master.should have_versions %Q{
|
153
153
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
@@ -158,8 +158,8 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
158
158
|
master = @master_class.new
|
159
159
|
master.update_attributes name: "Single Standard", price: 98
|
160
160
|
Timecop.freeze Time.now+hour
|
161
|
-
master.update_attributes price: 98,
|
162
|
-
master.update_attributes price: 98,
|
161
|
+
master.update_attributes price: 98, valid_from: Time.now-2*hour
|
162
|
+
master.update_attributes price: 98, valid_from: Time.now+1*hour
|
163
163
|
master.should have_versions %Q{
|
164
164
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
165
165
|
| Single Standard | 98 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | MAX TIME | true |
|
@@ -176,7 +176,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
176
176
|
master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour, valid_to: Time.now+4*hour
|
177
177
|
master.update_attributes name: "Single Standard", price: 95, valid_from: Time.now+4*hour, valid_to: Time.now+6*hour
|
178
178
|
Timecop.freeze Time.now+hour
|
179
|
-
master.update_attributes name: "King Size", valid_to: nil
|
179
|
+
master.update_attributes name: "King Size", valid_to: nil
|
180
180
|
master.should have_versions %Q{
|
181
181
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
182
182
|
| Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
|
@@ -192,7 +192,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
192
192
|
master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour, valid_to: Time.now+4*hour
|
193
193
|
master.update_attributes name: "Single Standard", price: 95, valid_from: Time.now+4*hour, valid_to: Time.now+6*hour
|
194
194
|
Timecop.freeze Time.now+hour
|
195
|
-
master.update_attributes name: "King Size", valid_to: Time.now+4*hour
|
195
|
+
master.update_attributes name: "King Size", valid_to: Time.now+4*hour
|
196
196
|
master.should have_versions %Q{
|
197
197
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
198
198
|
| Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
|
@@ -209,7 +209,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
209
209
|
master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour, valid_to: Time.now+4*hour
|
210
210
|
master.update_attributes name: "Single Standard", price: 95, valid_from: Time.now+4*hour, valid_to: Time.now+6*hour
|
211
211
|
Timecop.freeze Time.now+hour
|
212
|
-
master.update_attributes name: "King Size", valid_to: Time.utc(9999)
|
212
|
+
master.update_attributes name: "King Size", valid_to: Time.utc(9999)
|
213
213
|
master.should have_versions %Q{
|
214
214
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
215
215
|
| Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
|
@@ -280,8 +280,8 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
280
280
|
master.update_attributes name: "Single Standard", price: 98
|
281
281
|
Timecop.freeze Time.now+hour
|
282
282
|
master2 = @master_class.find id: master.id
|
283
|
-
master.update_attributes price: 94
|
284
|
-
master2.update_attributes name: "King Size"
|
283
|
+
master.update_attributes price: 94
|
284
|
+
master2.update_attributes name: "King Size"
|
285
285
|
master.should have_versions %Q{
|
286
286
|
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
287
287
|
| Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
|
@@ -327,7 +327,7 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
327
327
|
master = @master_class.new
|
328
328
|
master.update_attributes name: "Single Standard", price: 98
|
329
329
|
Timecop.freeze Time.now+1*hour
|
330
|
-
master.update_attributes price: 94
|
330
|
+
master.update_attributes price: 94
|
331
331
|
master.current_version.price.should == 94
|
332
332
|
Sequel::Plugins::Bitemporal.as_we_knew_it(Time.now-1*hour) do
|
333
333
|
master.current_version(true).price.should == 98
|
@@ -428,7 +428,7 @@ describe "Sequel::Plugins::Bitemporal", "with audit" do
|
|
428
428
|
Time.now,
|
429
429
|
author
|
430
430
|
)
|
431
|
-
master.update_attributes
|
431
|
+
master.update_attributes name: "King size", price: 98
|
432
432
|
end
|
433
433
|
end
|
434
434
|
|
@@ -483,7 +483,7 @@ describe "Sequel::Plugins::Bitemporal", "with audit, specifying how to get the a
|
|
483
483
|
Time.now,
|
484
484
|
author
|
485
485
|
)
|
486
|
-
master.update_attributes
|
486
|
+
master.update_attributes name: "King size", price: 98
|
487
487
|
end
|
488
488
|
end
|
489
489
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_bitemporal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sequel
|