validates_timeliness 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c7247761bf59a4add26640ddb732b6bdf816312be3083e972976062d4a43459
|
4
|
+
data.tar.gz: ab777d06c23790afbbc56a6a5a173fb8ea98034f52e9903d996c77a20e415574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fde85a854481b993e1353a092a5340a62c2c299e2a8f75c8802f334203673e05a64e5323d8af6b1cd3e9c8bd2c8a0b8c6c78dd160aa6630eda7bfb06e10f4166
|
7
|
+
data.tar.gz: 5d202ab44a0397c7fbacac804c0bd2e52fdb37c8db672d22340681d01ce70a95a735d6e85e65f0d7ac72c0b6cbbcd159cf3fb715c566dff544e93436b40d103a
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
= [
|
1
|
+
= 5.0.1 [2023-01-12]
|
2
|
+
* Ensure Date value is converted to time in zone for zone aware attributes
|
3
|
+
* Use ActiveSupport #change method to zero out usec
|
4
|
+
|
5
|
+
= 5.0.0 [2021-04-03]
|
2
6
|
* Fix DateTimeSelect extension support (AquisTech)
|
3
7
|
* Relaxed Timeliness dependency version which allows for >= 0.4.0 with
|
4
8
|
threadsafety fix for use_us_formats and use_euro_formats for hot switching
|
@@ -19,12 +19,13 @@ module ValidatesTimeliness
|
|
19
19
|
when :date
|
20
20
|
value.to_date
|
21
21
|
when :datetime
|
22
|
-
value.is_a?(Time) ? value : value.to_time
|
22
|
+
value.is_a?(Time) ? value : (time_zone_aware? ? value.in_time_zone : value.to_time)
|
23
23
|
else
|
24
24
|
value
|
25
25
|
end
|
26
|
+
|
26
27
|
if ignore_usec && value.is_a?(Time)
|
27
|
-
|
28
|
+
value.change(usec: 0)
|
28
29
|
else
|
29
30
|
value
|
30
31
|
end
|
@@ -59,30 +59,61 @@ RSpec.describe ValidatesTimeliness::Converter do
|
|
59
59
|
|
60
60
|
describe "for datetime type" do
|
61
61
|
let(:type) { :datetime }
|
62
|
-
let(:time_zone_aware) { true }
|
63
62
|
|
64
|
-
it
|
65
|
-
expect(type_cast_value(
|
63
|
+
it 'should return nil for invalid value types' do
|
64
|
+
expect(type_cast_value(12)).to eq(nil)
|
66
65
|
end
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
expect(type_cast_value(Time.utc(2010, 1, 1, 12, 34, 56))).to eq(value)
|
71
|
-
end
|
67
|
+
context "time zone aware" do
|
68
|
+
let(:time_zone_aware) { true }
|
72
69
|
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
around { |example|
|
71
|
+
Time.use_zone("Perth", &example)
|
72
|
+
}
|
73
|
+
|
74
|
+
it "should return Date as Time value" do
|
75
|
+
Time.use_zone('London') do
|
76
|
+
result = type_cast_value(Date.new(2010, 1, 1))
|
77
|
+
expected = Time.zone.local(2010, 1, 1, 0, 0, 0)
|
78
|
+
|
79
|
+
expect(result).to eq(expected)
|
80
|
+
expect(result.zone).to eq(expected.zone)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return same Time value" do
|
85
|
+
value = Time.utc(2010, 1, 1, 12, 34, 56)
|
86
|
+
expect(type_cast_value(value)).to eq(value)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return as Time with same component values" do
|
90
|
+
expect(type_cast_value(DateTime.civil_from_format(:utc, 2010, 1, 1, 12, 34, 56))).to eq(Time.utc(2010, 1, 1, 12, 34, 56))
|
91
|
+
end
|
76
92
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
93
|
+
it "should return same Time in correct zone if timezone aware" do
|
94
|
+
value = Time.utc(2010, 1, 1, 12, 34, 56)
|
95
|
+
result = type_cast_value(value)
|
96
|
+
|
97
|
+
expect(result).to eq(Time.zone.local(2010, 1, 1, 20, 34, 56))
|
98
|
+
expect(result.zone).to eq('AWST')
|
99
|
+
end
|
82
100
|
end
|
83
101
|
|
84
|
-
|
85
|
-
|
102
|
+
context "not time zone aware" do
|
103
|
+
let(:time_zone_aware) { false }
|
104
|
+
|
105
|
+
it "should return Date as Time value" do
|
106
|
+
expect(type_cast_value(Date.new(2010, 1, 1))).to eq(Time.local(2010, 1, 1, 0, 0, 0))
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should return same Time value" do
|
110
|
+
value = Time.utc(2010, 1, 1, 12, 34, 56)
|
111
|
+
expect(type_cast_value(Time.utc(2010, 1, 1, 12, 34, 56))).to eq(value)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should return as Time with same component values" do
|
115
|
+
expect(type_cast_value(DateTime.civil_from_format(:utc, 2010, 1, 1, 12, 34, 56))).to eq(Time.utc(2010, 1, 1, 12, 34, 56))
|
116
|
+
end
|
86
117
|
end
|
87
118
|
end
|
88
119
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_timeliness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Meehan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: timeliness
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
106
|
+
rubygems_version: 3.1.6
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Date and time validation plugin for Rails which allows custom formats
|