i18n-sequel_bitemporal 1.0.2 → 1.0.3
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.
- checksums.yaml +4 -4
- data/lib/i18n/backend/sequel_bitemporal.rb +8 -1
- data/lib/i18n/sequel_bitemporal/version.rb +1 -1
- data/test/sequel_test.rb +18 -0
- data/test/test_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57e9252a463de8d43116d067cbe849cdf70a9647e8b7a3cb2dcdbc1016d86317
|
4
|
+
data.tar.gz: 6d504736bf4b6e300807bd9973049b3dcebcb3799f5ba9c61aa013374f8aa839
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19b6b5aade339b69265e235d812a1d488a3e0494b1816dd248023ac8d1022183ef86c1c8ae8f44cbbc304047917ecece3322c470f64d08398c1216b3c0bcf3df
|
7
|
+
data.tar.gz: 93a7efa3a130e5f4ef83ea6bc8804234380aca8df3d6f785b518c0130841a7136db177bc4b81f6e36a2949459d42598b176fce722e1a68c8e103c23bc645b94f
|
@@ -44,6 +44,7 @@ module I18n
|
|
44
44
|
|
45
45
|
def store_translations(locale, data, options = {})
|
46
46
|
escape = options.fetch(:escape, true)
|
47
|
+
point_in_time_for_new = options[:point_in_time_for_new]
|
47
48
|
valid_from_for_new = options[:valid_from_for_new]
|
48
49
|
flatten_translations(locale, data, escape, false).each do |key, value|
|
49
50
|
# Invalidate all keys matching current one:
|
@@ -56,7 +57,13 @@ module I18n
|
|
56
57
|
Translation.new(:locale => locale.to_s, :key => key.to_s)
|
57
58
|
translation.attributes = {:value => value}
|
58
59
|
translation.attributes[:valid_from] = valid_from_for_new if translation.new?
|
59
|
-
translation.
|
60
|
+
if point_in_time_for_new && translation.new?
|
61
|
+
::Sequel::Plugins::Bitemporal.as_we_knew_it point_in_time_for_new do
|
62
|
+
translation.save
|
63
|
+
end
|
64
|
+
else
|
65
|
+
translation.save
|
66
|
+
end
|
60
67
|
end
|
61
68
|
end
|
62
69
|
end
|
data/test/sequel_test.rb
CHANGED
@@ -67,6 +67,24 @@ class I18nBackendSequelBitemporalTest < I18nBitemporalTest
|
|
67
67
|
assert_equal valid_from_for_new, translation.current_version.valid_from
|
68
68
|
end
|
69
69
|
|
70
|
+
test "can specify point in time for the new translation" do
|
71
|
+
point_in_time_for_new = Time.parse("2001-01-01T12:00:00Z")
|
72
|
+
I18n.backend.store_translations(:es, {:"Pagina's" => "Pagina's"}, point_in_time_for_new: point_in_time_for_new )
|
73
|
+
translation = I18n::Backend::SequelBitemporal::Translation.locale(:es).lookup("Pagina's").limit(1).all.first
|
74
|
+
assert_equal "Pagina's", translation.value
|
75
|
+
assert_equal point_in_time_for_new, translation.current_version.created_at
|
76
|
+
end
|
77
|
+
|
78
|
+
test "can specify both point in time and valid_from for the new translation" do
|
79
|
+
point_in_time_for_new = Time.parse("2001-01-01T12:00:00Z")
|
80
|
+
valid_from_for_new = Date.parse("2001-01-01")
|
81
|
+
I18n.backend.store_translations(:es, {:"Pagina's" => "Pagina's"}, point_in_time_for_new: point_in_time_for_new, valid_from_for_new: valid_from_for_new )
|
82
|
+
translation = I18n::Backend::SequelBitemporal::Translation.locale(:es).lookup("Pagina's").limit(1).all.first
|
83
|
+
assert_equal "Pagina's", translation.value
|
84
|
+
assert_equal point_in_time_for_new, translation.current_version.created_at
|
85
|
+
assert_equal valid_from_for_new, translation.current_version.valid_from
|
86
|
+
end
|
87
|
+
|
70
88
|
with_mocha do
|
71
89
|
test "missing translations table does not cause an error in #available_locales" do
|
72
90
|
I18n::Backend::SequelBitemporal::Translation.expects(:available_locales).raises(::Sequel::Error)
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-sequel_bitemporal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Tron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|