sequel_bitemporal 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sequel/plugins/bitemporal.rb +2 -0
- data/sequel_bitemporal.gemspec +2 -2
- data/spec/bitemporal_date_spec.rb +20 -0
- data/spec/support/db.rb +1 -0
- metadata +41 -16
@@ -215,7 +215,9 @@ module Sequel
|
|
215
215
|
end
|
216
216
|
|
217
217
|
def expire_previous_versions
|
218
|
+
master_changes = values.select{|k| changed_columns.include? k}
|
218
219
|
lock!
|
220
|
+
set master_changes
|
219
221
|
expired = versions_dataset.where expired_at: nil
|
220
222
|
expired = expired.exclude "valid_from=valid_to"
|
221
223
|
expired = expired.exclude "valid_to<=?", pending_version.valid_from
|
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.4.
|
6
|
+
s.version = "0.4.10"
|
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"
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_runtime_dependency "sequel", "~> 3.30.0"
|
19
19
|
|
20
20
|
s.add_development_dependency "sqlite3"
|
21
|
-
s.add_development_dependency "rspec", "~> 2.
|
21
|
+
s.add_development_dependency "rspec", "~> 2.10.0"
|
22
22
|
s.add_development_dependency "timecop"
|
23
23
|
s.add_development_dependency "rake"
|
24
24
|
end
|
@@ -298,6 +298,20 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
298
298
|
| King Size | 94 | 2009-11-29 | | 2009-11-29 | MAX DATE | true |
|
299
299
|
}
|
300
300
|
end
|
301
|
+
it "can expire invalid versions" do
|
302
|
+
master = @master_class.new.update_attributes name: "Single Standard", price: 98
|
303
|
+
master.current_version.price = nil
|
304
|
+
master.current_version.should_not be_valid
|
305
|
+
master.current_version.save validate: false
|
306
|
+
Timecop.freeze Date.today+1
|
307
|
+
master.update_attributes price: 94, partial_update: true
|
308
|
+
master.should have_versions %Q{
|
309
|
+
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
310
|
+
| Single Standard | | 2009-11-28 | 2009-11-29 | 2009-11-28 | MAX DATE | |
|
311
|
+
| Single Standard | | 2009-11-29 | | 2009-11-28 | 2009-11-29 | |
|
312
|
+
| Single Standard | 94 | 2009-11-29 | | 2009-11-29 | MAX DATE | true |
|
313
|
+
}
|
314
|
+
end
|
301
315
|
it "allows eager loading with conditions on current version" do
|
302
316
|
master = @master_class.new
|
303
317
|
master.update_attributes name: "Single Standard", price: 98
|
@@ -432,6 +446,12 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
432
446
|
Object.send :remove_const, :MyName
|
433
447
|
Object.send :remove_const, :MyNameVersion
|
434
448
|
end
|
449
|
+
it "can update master and current version at the same time" do
|
450
|
+
master = @master_class.new.update_attributes name: "Single Standard", price: 98
|
451
|
+
master.disabled = true
|
452
|
+
master.update_attributes price: 94, partial_update: true
|
453
|
+
master.reload.disabled.should be_true
|
454
|
+
end
|
435
455
|
end
|
436
456
|
|
437
457
|
describe "Sequel::Plugins::Bitemporal", "with audit" do
|
data/spec/support/db.rb
CHANGED
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.
|
4
|
+
version: 0.4.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-05-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sequel
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,15 @@ dependencies:
|
|
22
22
|
version: 3.30.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 3.30.0
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: sqlite3
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
36
|
- - ! '>='
|
@@ -33,21 +38,31 @@ dependencies:
|
|
33
38
|
version: '0'
|
34
39
|
type: :development
|
35
40
|
prerelease: false
|
36
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
37
47
|
- !ruby/object:Gem::Dependency
|
38
48
|
name: rspec
|
39
|
-
requirement:
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
40
50
|
none: false
|
41
51
|
requirements:
|
42
52
|
- - ~>
|
43
53
|
- !ruby/object:Gem::Version
|
44
|
-
version: 2.
|
54
|
+
version: 2.10.0
|
45
55
|
type: :development
|
46
56
|
prerelease: false
|
47
|
-
version_requirements:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.10.0
|
48
63
|
- !ruby/object:Gem::Dependency
|
49
64
|
name: timecop
|
50
|
-
requirement:
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
51
66
|
none: false
|
52
67
|
requirements:
|
53
68
|
- - ! '>='
|
@@ -55,10 +70,15 @@ dependencies:
|
|
55
70
|
version: '0'
|
56
71
|
type: :development
|
57
72
|
prerelease: false
|
58
|
-
version_requirements:
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
59
79
|
- !ruby/object:Gem::Dependency
|
60
80
|
name: rake
|
61
|
-
requirement:
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
62
82
|
none: false
|
63
83
|
requirements:
|
64
84
|
- - ! '>='
|
@@ -66,7 +86,12 @@ dependencies:
|
|
66
86
|
version: '0'
|
67
87
|
type: :development
|
68
88
|
prerelease: false
|
69
|
-
version_requirements:
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
70
95
|
description: Bitemporal versioning for sequel, fully tested.
|
71
96
|
email:
|
72
97
|
- joseph.halter@thetalentbox.com
|
@@ -102,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
127
|
version: '0'
|
103
128
|
segments:
|
104
129
|
- 0
|
105
|
-
hash:
|
130
|
+
hash: -2831244389033292323
|
106
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
132
|
none: false
|
108
133
|
requirements:
|
@@ -111,10 +136,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
136
|
version: '0'
|
112
137
|
segments:
|
113
138
|
- 0
|
114
|
-
hash:
|
139
|
+
hash: -2831244389033292323
|
115
140
|
requirements: []
|
116
141
|
rubyforge_project:
|
117
|
-
rubygems_version: 1.8.
|
142
|
+
rubygems_version: 1.8.24
|
118
143
|
signing_key:
|
119
144
|
specification_version: 3
|
120
145
|
summary: Bitemporal versioning for sequel.
|