validates_timeliness 6.0.0 → 6.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: a72c9c656e7bb6b4987658858001d6654a591b12a2aa6322f2b38a932ef4c7b5
|
4
|
+
data.tar.gz: b8449806435f41af895a80c61a7e641f42d4581aaee40183781a222ea027876a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68e98f1017b315190106b17608ce8d5df1977f101154c91a89fea550b2546b10ec569b6ba79ff51ae4efd760bc61e91756e7561624b8e8da7ae281d407c012a4
|
7
|
+
data.tar.gz: bda2a3e5f833ed1e3467e5e3ee2c2030d964187e9c23611c2afa1265c76096590332ae1739d8196c429eca57a2f8720a1c2e67cb87e75ba8a777f1c7f8939e56
|
@@ -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
|
@@ -63,30 +63,61 @@ RSpec.describe ValidatesTimeliness::Converter do
|
|
63
63
|
|
64
64
|
describe "for datetime type" do
|
65
65
|
let(:type) { :datetime }
|
66
|
-
let(:time_zone_aware) { true }
|
67
66
|
|
68
|
-
it
|
69
|
-
expect(type_cast_value(
|
67
|
+
it 'should return nil for invalid value types' do
|
68
|
+
expect(type_cast_value(12)).to eq(nil)
|
70
69
|
end
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
expect(type_cast_value(Time.utc(2010, 1, 1, 12, 34, 56))).to eq(value)
|
75
|
-
end
|
71
|
+
context "time zone aware" do
|
72
|
+
let(:time_zone_aware) { true }
|
76
73
|
|
77
|
-
|
78
|
-
|
79
|
-
|
74
|
+
around { |example|
|
75
|
+
Time.use_zone("Perth", &example)
|
76
|
+
}
|
77
|
+
|
78
|
+
it "should return Date as Time value" do
|
79
|
+
Time.use_zone('London') do
|
80
|
+
result = type_cast_value(Date.new(2010, 1, 1))
|
81
|
+
expected = Time.zone.local(2010, 1, 1, 0, 0, 0)
|
82
|
+
|
83
|
+
expect(result).to eq(expected)
|
84
|
+
expect(result.zone).to eq(expected.zone)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should return same Time value" do
|
89
|
+
value = Time.utc(2010, 1, 1, 12, 34, 56)
|
90
|
+
expect(type_cast_value(value)).to eq(value)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return as Time with same component values" do
|
94
|
+
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))
|
95
|
+
end
|
80
96
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
97
|
+
it "should return same Time in correct zone if timezone aware" do
|
98
|
+
value = Time.utc(2010, 1, 1, 12, 34, 56)
|
99
|
+
result = type_cast_value(value)
|
100
|
+
|
101
|
+
expect(result).to eq(Time.zone.local(2010, 1, 1, 20, 34, 56))
|
102
|
+
expect(result.zone).to eq('AWST')
|
103
|
+
end
|
86
104
|
end
|
87
105
|
|
88
|
-
|
89
|
-
|
106
|
+
context "not time zone aware" do
|
107
|
+
let(:time_zone_aware) { false }
|
108
|
+
|
109
|
+
it "should return Date as Time value" do
|
110
|
+
expect(type_cast_value(Date.new(2010, 1, 1))).to eq(Time.local(2010, 1, 1, 0, 0, 0))
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should return same Time value" do
|
114
|
+
value = Time.utc(2010, 1, 1, 12, 34, 56)
|
115
|
+
expect(type_cast_value(Time.utc(2010, 1, 1, 12, 34, 56))).to eq(value)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should return as Time with same component values" do
|
119
|
+
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))
|
120
|
+
end
|
90
121
|
end
|
91
122
|
end
|
92
123
|
|
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: 6.0.
|
4
|
+
version: 6.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: activemodel
|
@@ -68,7 +68,6 @@ files:
|
|
68
68
|
- Rakefile
|
69
69
|
- gemfiles/rails_6_0.gemfile
|
70
70
|
- gemfiles/rails_6_1.gemfile
|
71
|
-
- gemfiles/rails_edge.gemfile
|
72
71
|
- init.rb
|
73
72
|
- lib/generators/validates_timeliness/install_generator.rb
|
74
73
|
- lib/generators/validates_timeliness/templates/en.yml
|
data/gemfiles/rails_edge.gemfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", git: "https://github.com/rails/rails.git", branch: "main"
|
6
|
-
gem "rspec"
|
7
|
-
gem "rspec-rails", "~> 3.7"
|
8
|
-
gem "sqlite3"
|
9
|
-
gem "byebug"
|
10
|
-
gem "appraisal"
|
11
|
-
gem "nokogiri", "~> 1.8"
|
12
|
-
|
13
|
-
gemspec path: "../"
|