sequel_bitemporal 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,6 +56,7 @@ module Sequel
56
56
  if !new? && attributes.delete(:partial_update) && current_version
57
57
  current_attributes = current_version.values.dup
58
58
  current_attributes.delete :id
59
+ current_attributes.delete :valid_from
59
60
  attributes = current_attributes.merge attributes
60
61
  end
61
62
  self.attributes = attributes
@@ -109,7 +110,7 @@ module Sequel
109
110
  def prepare_pending_version
110
111
  point_in_time = Time.now
111
112
  pending_version.created_at = point_in_time
112
- pending_version.valid_from = point_in_time if !pending_version.valid_from || pending_version.valid_from.to_time<point_in_time
113
+ pending_version.valid_from ||= point_in_time
113
114
  end
114
115
 
115
116
  def save_pending_version
@@ -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.1.2"
6
+ s.version = "0.1.3"
7
7
  s.authors = ["Joseph HALTER"]
8
8
  s.email = ["joseph.halter@thetalentbox.com"]
9
9
  s.homepage = "https://github.com/TalentBox/sequel_bitemporal"
@@ -70,12 +70,12 @@ describe "Sequel::Plugins::Bitemporal" do
70
70
  | Single Standard | 98 | 2009-11-28 | | 2009-11-28 | | true |
71
71
  }
72
72
  end
73
- it "prevents creating a new version in the past" do
73
+ it "allows creating a new version in the past" do
74
74
  master = @master_class.new
75
75
  master.update_attributes name: "Single Standard", price: 98, valid_from: Date.today-1
76
76
  master.should have_versions %Q{
77
77
  | name | price | created_at | expired_at | valid_from | valid_to | current |
78
- | Single Standard | 98 | 2009-11-28 | | 2009-11-28 | | true |
78
+ | Single Standard | 98 | 2009-11-28 | | 2009-11-27 | | true |
79
79
  }
80
80
  end
81
81
  it "allows creating a new version in the future" do
@@ -168,6 +168,8 @@ describe "Sequel::Plugins::Bitemporal" do
168
168
  # | Single Standard | 98 | 2009-11-28 | 2009-11-29 | 2009-11-28 | 2009-11-30 | |
169
169
  # | Single Standard | 98 | 2009-11-29 | | 2009-11-28 | | true |
170
170
  end
171
+ xit "doesn't do anything if unchanged" do
172
+ end
171
173
  it "overrides no future versions" do
172
174
  master = @master_class.new
173
175
  master.update_attributes name: "Single Standard", price: 98, valid_to: Date.today+2
@@ -217,8 +219,6 @@ describe "Sequel::Plugins::Bitemporal" do
217
219
  | King Size | 98 | 2009-11-29 | | 2009-11-29 | | true |
218
220
  }
219
221
  end
220
- xit "doesn't do anything if unchanged" do
221
- end
222
222
  it "allows deleting current version" do
223
223
  master = @master_class.new
224
224
  master.update_attributes name: "Single Standard", price: 98
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.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
16
- requirement: &2154275980 !ruby/object:Gem::Requirement
16
+ requirement: &2157973260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2154275980
24
+ version_requirements: *2157973260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2154275540 !ruby/object:Gem::Requirement
27
+ requirement: &2157972820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2154275540
35
+ version_requirements: *2157972820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: timecop
38
- requirement: &2154302740 !ruby/object:Gem::Requirement
38
+ requirement: &2158000040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2154302740
46
+ version_requirements: *2158000040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sequel
49
- requirement: &2154302320 !ruby/object:Gem::Requirement
49
+ requirement: &2157999620 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2154302320
57
+ version_requirements: *2157999620
58
58
  description: Bitemporal versioning for sequel, fully tested.
59
59
  email:
60
60
  - joseph.halter@thetalentbox.com