sequel_bitemporal 0.6.9 → 0.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +2 -2
- data/lib/sequel/plugins/bitemporal.rb +5 -3
- data/sequel_bitemporal.gemspec +1 -1
- data/spec/bitemporal_serialization_spec.rb +37 -0
- data/spec/bitemporal_time_spec.rb +0 -1
- data/spec/spec_helper.rb +1 -0
- metadata +5 -3
data/.travis.yml
CHANGED
@@ -378,12 +378,13 @@ module Sequel
|
|
378
378
|
return false unless @pending_version
|
379
379
|
return true unless current_version?
|
380
380
|
@current_version_values = current_version.values
|
381
|
-
pending_version.
|
381
|
+
pending_version.columns.detect do |key|
|
382
|
+
new_value = pending_version.send key
|
382
383
|
case key
|
383
384
|
when :id, :master_id, :created_at, :expired_at
|
384
385
|
false
|
385
386
|
when :valid_from
|
386
|
-
|
387
|
+
pending_version.values.has_key?(:valid_from) && (
|
387
388
|
new_value<current_version.valid_from ||
|
388
389
|
(
|
389
390
|
current_version.valid_to &&
|
@@ -391,7 +392,8 @@ module Sequel
|
|
391
392
|
)
|
392
393
|
)
|
393
394
|
when :valid_to
|
394
|
-
|
395
|
+
pending_version.values.has_key?(:valid_to) &&
|
396
|
+
new_value!=current_version.valid_to
|
395
397
|
else
|
396
398
|
if model.version_uses_string_nilifier
|
397
399
|
new_value = nil if current_version.nil_string? key, new_value
|
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.
|
6
|
+
s.version = "0.6.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"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
describe "Sequel::Plugins::Bitemporal" do
|
5
|
+
include DbHelpers
|
6
|
+
before :all do
|
7
|
+
db_setup
|
8
|
+
@version_class.instance_eval do
|
9
|
+
plugin :serialization
|
10
|
+
serialize_attributes :json, :name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
subject{ @master_class.new.update_attributes name: {test: 1}, price: 18 }
|
14
|
+
it "serializes as expected" do
|
15
|
+
subject.name.should == {"test" => 1}
|
16
|
+
end
|
17
|
+
it "doesn't create a new version when value hasn't changed" do
|
18
|
+
name = subject.name.dup
|
19
|
+
name["test"] = 1
|
20
|
+
subject.attributes = {name: name}
|
21
|
+
lambda{ subject.save }.should_not change(@version_class, :count)
|
22
|
+
end
|
23
|
+
it "doesn't create a new version when value is the same" do
|
24
|
+
subject.attributes = {name: {"test" => 1}}
|
25
|
+
lambda{ subject.save }.should_not change(@version_class, :count)
|
26
|
+
end
|
27
|
+
it "does create a new version when value has changed" do
|
28
|
+
name = subject.name.dup
|
29
|
+
name["test"] = 0
|
30
|
+
subject.attributes = {name: name}
|
31
|
+
lambda{ subject.save }.should change(@version_class, :count).by 1
|
32
|
+
end
|
33
|
+
it "does create a new version when value is not the same" do
|
34
|
+
subject.attributes = {name: {"test" => 0}}
|
35
|
+
lambda{ subject.save }.should change(@version_class, :count).by 1
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sequel_bitemporal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.
|
5
|
+
version: 0.6.10
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Joseph HALTER
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/sequel_bitemporal.rb
|
110
110
|
- sequel_bitemporal.gemspec
|
111
111
|
- spec/bitemporal_date_spec.rb
|
112
|
+
- spec/bitemporal_serialization_spec.rb
|
112
113
|
- spec/bitemporal_time_spec.rb
|
113
114
|
- spec/spec_helper.rb
|
114
115
|
- spec/support/bitemporal_matchers.rb
|
@@ -125,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
126
|
- !ruby/object:Gem::Version
|
126
127
|
segments:
|
127
128
|
- 0
|
128
|
-
hash:
|
129
|
+
hash: 334151624443386652
|
129
130
|
version: '0'
|
130
131
|
none: false
|
131
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -134,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
135
|
- !ruby/object:Gem::Version
|
135
136
|
segments:
|
136
137
|
- 0
|
137
|
-
hash:
|
138
|
+
hash: 334151624443386652
|
138
139
|
version: '0'
|
139
140
|
none: false
|
140
141
|
requirements: []
|
@@ -145,6 +146,7 @@ specification_version: 3
|
|
145
146
|
summary: Bitemporal versioning for sequel.
|
146
147
|
test_files:
|
147
148
|
- spec/bitemporal_date_spec.rb
|
149
|
+
- spec/bitemporal_serialization_spec.rb
|
148
150
|
- spec/bitemporal_time_spec.rb
|
149
151
|
- spec/spec_helper.rb
|
150
152
|
- spec/support/bitemporal_matchers.rb
|