ndr_support 5.10.2 → 5.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/code_safety.yml +27 -23
- data/gemfiles/Gemfile.rails72 +6 -0
- data/gemfiles/Gemfile.rails80 +6 -0
- data/lib/ndr_support/date_and_time_extensions.rb +12 -11
- data/lib/ndr_support/ourdate/build_datetime.rb +1 -5
- data/lib/ndr_support/ourdate.rb +1 -5
- data/lib/ndr_support/string/clean_methodable.rb +2 -0
- data/lib/ndr_support/string/cleaning.rb +0 -1
- data/lib/ndr_support/string/conversions.rb +1 -5
- data/lib/ndr_support/version.rb +1 -1
- data/ndr_support.gemspec +2 -2
- data/test/date_and_time_extensions_test.rb +34 -8
- data/test/daterange_test.rb +1 -5
- data/test/string/cleaning_test.rb +14 -1
- data/test/string/conversions_test.rb +1 -5
- data/test/test_helper.rb +1 -5
- metadata +13 -12
- data/gemfiles/Gemfile.rails61 +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b6a369bc1e742569d0aa4d950f9a816c9e22f3625b3acaf67b9bd75a5355328
|
4
|
+
data.tar.gz: 7e6e2054579563d87ad5db6a79cbb9fb059613bfac985ee8aeaf2d12e2db4b3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 870d809da96700fddaf9610a3631b18906327ed75fd72205f75bd98527454c3c1b44c07429b7630e8cf83d989683ea503422cef020829cbf1583e602bd272085
|
7
|
+
data.tar.gz: 7ce414782c185518b9e87665cc0563192a6b8f54f1f9ca5aeaf8055b17ac7c08c81fb8da5238b2af3ea841c320d33b81221d243422c6df64135c5d64f91a64a3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
## [Unreleased]
|
2
|
-
*
|
2
|
+
* no unreleased changes
|
3
|
+
|
4
|
+
## 5.10.4 / 2024-11-13
|
5
|
+
### Added
|
6
|
+
* Support Rails 7.1, 7.2, 8.0, Ruby 3.2, 3.3. Drop support for Rails 6.1
|
7
|
+
|
8
|
+
## 5.10.3 / 2024-02-12
|
9
|
+
## Fixed
|
10
|
+
* Fixed issue with constant in wrong file/concern
|
11
|
+
* Added tests for roman5 cleaning method
|
12
|
+
* Separated log10 tests
|
3
13
|
|
4
14
|
## 5.10.2 / 2024-02-09
|
5
15
|
## Fixed
|
data/code_safety.yml
CHANGED
@@ -11,7 +11,7 @@ file safety:
|
|
11
11
|
".github/workflows/test.yml":
|
12
12
|
comments:
|
13
13
|
reviewed_by: brian.shand
|
14
|
-
safe_revision:
|
14
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
15
15
|
".gitignore":
|
16
16
|
comments:
|
17
17
|
reviewed_by: josh.pencheon
|
@@ -23,7 +23,7 @@ file safety:
|
|
23
23
|
CHANGELOG.md:
|
24
24
|
comments:
|
25
25
|
reviewed_by: brian.shand
|
26
|
-
safe_revision:
|
26
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
27
27
|
CODE_OF_CONDUCT.md:
|
28
28
|
comments:
|
29
29
|
reviewed_by: timgentry
|
@@ -48,10 +48,6 @@ file safety:
|
|
48
48
|
comments:
|
49
49
|
reviewed_by: timgentry
|
50
50
|
safe_revision: e33e9dae7f38bc449ce9276515a539836dbbbd53
|
51
|
-
gemfiles/Gemfile.rails61:
|
52
|
-
comments:
|
53
|
-
reviewed_by: brian.shand
|
54
|
-
safe_revision: 16254a4332aab074a27c8e13859dc4712e707122
|
55
51
|
gemfiles/Gemfile.rails70:
|
56
52
|
comments:
|
57
53
|
reviewed_by: brian.shand
|
@@ -60,6 +56,14 @@ file safety:
|
|
60
56
|
comments:
|
61
57
|
reviewed_by: brian.shand
|
62
58
|
safe_revision: 2253a90ec8db872590a8167fdebe95d6ed677cc2
|
59
|
+
gemfiles/Gemfile.rails72:
|
60
|
+
comments:
|
61
|
+
reviewed_by: brian.shand
|
62
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
63
|
+
gemfiles/Gemfile.rails80:
|
64
|
+
comments:
|
65
|
+
reviewed_by: brian.shand
|
66
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
63
67
|
lib/ndr_support.rb:
|
64
68
|
comments:
|
65
69
|
reviewed_by: brian.shand
|
@@ -75,7 +79,7 @@ file safety:
|
|
75
79
|
lib/ndr_support/date_and_time_extensions.rb:
|
76
80
|
comments:
|
77
81
|
reviewed_by: brian.shand
|
78
|
-
safe_revision:
|
82
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
79
83
|
lib/ndr_support/daterange.rb:
|
80
84
|
comments:
|
81
85
|
reviewed_by: brian.shand
|
@@ -107,11 +111,11 @@ file safety:
|
|
107
111
|
lib/ndr_support/ourdate.rb:
|
108
112
|
comments:
|
109
113
|
reviewed_by: brian.shand
|
110
|
-
safe_revision:
|
114
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
111
115
|
lib/ndr_support/ourdate/build_datetime.rb:
|
112
116
|
comments:
|
113
117
|
reviewed_by: brian.shand
|
114
|
-
safe_revision:
|
118
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
115
119
|
lib/ndr_support/ourtime.rb:
|
116
120
|
comments:
|
117
121
|
reviewed_by: brian.shand
|
@@ -138,16 +142,16 @@ file safety:
|
|
138
142
|
safe_revision: f4f7cb0803ea34a2f1ba83495d8bcbd942786bce
|
139
143
|
lib/ndr_support/string/clean_methodable.rb:
|
140
144
|
comments:
|
141
|
-
reviewed_by:
|
142
|
-
safe_revision:
|
145
|
+
reviewed_by: ollietulloch
|
146
|
+
safe_revision: ff21f98e6608eedb4b33f977778736b38f9fbacb
|
143
147
|
lib/ndr_support/string/cleaning.rb:
|
144
148
|
comments:
|
145
|
-
reviewed_by:
|
146
|
-
safe_revision:
|
149
|
+
reviewed_by: ollietulloch
|
150
|
+
safe_revision: d99c4bf5d2cbbfe78101beff399e7da8645417b2
|
147
151
|
lib/ndr_support/string/conversions.rb:
|
148
152
|
comments:
|
149
153
|
reviewed_by: brian.shand
|
150
|
-
safe_revision:
|
154
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
151
155
|
lib/ndr_support/tasks.rb:
|
152
156
|
comments:
|
153
157
|
reviewed_by: timgentry
|
@@ -174,8 +178,8 @@ file safety:
|
|
174
178
|
safe_revision: '09b3f97fb4c1afc88d0d070c39796b1f60c39d25'
|
175
179
|
lib/ndr_support/version.rb:
|
176
180
|
comments:
|
177
|
-
reviewed_by:
|
178
|
-
safe_revision:
|
181
|
+
reviewed_by: ollietulloch
|
182
|
+
safe_revision: 8cb498126d68a19f880b0cd1b83b127c8ec90a89
|
179
183
|
lib/ndr_support/working_days.rb:
|
180
184
|
comments:
|
181
185
|
reviewed_by: josh.pencheon
|
@@ -187,7 +191,7 @@ file safety:
|
|
187
191
|
ndr_support.gemspec:
|
188
192
|
comments:
|
189
193
|
reviewed_by: brian.shand
|
190
|
-
safe_revision:
|
194
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
191
195
|
test/array_test.rb:
|
192
196
|
comments:
|
193
197
|
reviewed_by: timgentry
|
@@ -199,11 +203,11 @@ file safety:
|
|
199
203
|
test/date_and_time_extensions_test.rb:
|
200
204
|
comments:
|
201
205
|
reviewed_by: brian.shand
|
202
|
-
safe_revision:
|
206
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
203
207
|
test/daterange_test.rb:
|
204
208
|
comments:
|
205
209
|
reviewed_by: brian.shand
|
206
|
-
safe_revision:
|
210
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
207
211
|
test/hash_test.rb:
|
208
212
|
comments:
|
209
213
|
reviewed_by: timgentry
|
@@ -258,16 +262,16 @@ file safety:
|
|
258
262
|
safe_revision: b562d0c15ff1b1d565522a47e6bae47ea09706f0
|
259
263
|
test/string/cleaning_test.rb:
|
260
264
|
comments:
|
261
|
-
reviewed_by:
|
262
|
-
safe_revision:
|
265
|
+
reviewed_by: ollietulloch
|
266
|
+
safe_revision: d99c4bf5d2cbbfe78101beff399e7da8645417b2
|
263
267
|
test/string/conversions_test.rb:
|
264
268
|
comments:
|
265
269
|
reviewed_by: brian.shand
|
266
|
-
safe_revision:
|
270
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
267
271
|
test/test_helper.rb:
|
268
272
|
comments:
|
269
273
|
reviewed_by: brian.shand
|
270
|
-
safe_revision:
|
274
|
+
safe_revision: 931e0ac50f7843abd80aa907245936fe907d96f8
|
271
275
|
test/threat_scanner_test.rb:
|
272
276
|
comments:
|
273
277
|
reviewed_by: ollietulloch
|
@@ -2,6 +2,7 @@ require 'yaml'
|
|
2
2
|
require 'date'
|
3
3
|
require 'ndr_support/working_days'
|
4
4
|
|
5
|
+
# Extend standard Date class with our custom to_s overrides
|
5
6
|
class Date
|
6
7
|
# to_iso output must be SQL safe for security reasons
|
7
8
|
def to_iso
|
@@ -12,11 +13,7 @@ class Date
|
|
12
13
|
|
13
14
|
def to_datetime
|
14
15
|
# Default timezone for Date is GMT, not local timezone
|
15
|
-
default_timezone =
|
16
|
-
ActiveRecord.default_timezone
|
17
|
-
else
|
18
|
-
ActiveRecord::Base.default_timezone # Rails <= 6.1
|
19
|
-
end
|
16
|
+
default_timezone = ActiveRecord.default_timezone
|
20
17
|
return in_time_zone.to_datetime if default_timezone == :local
|
21
18
|
|
22
19
|
orig_to_datetime
|
@@ -29,7 +26,7 @@ class Date
|
|
29
26
|
# We keep overriding this for compatibility
|
30
27
|
def to_s(format = :default)
|
31
28
|
if format == :default
|
32
|
-
|
29
|
+
DATE_FORMATS.key?(:default) ? to_fs(:default) : orig_to_s
|
33
30
|
else
|
34
31
|
orig_to_s(format)
|
35
32
|
end
|
@@ -38,6 +35,7 @@ end
|
|
38
35
|
|
39
36
|
#-------------------------------------------------------------------------------
|
40
37
|
|
38
|
+
# Extend standard Time class with our custom to_s overrides
|
41
39
|
class Time
|
42
40
|
# to_iso output must be SQL safe for security reasons
|
43
41
|
def to_iso
|
@@ -51,7 +49,7 @@ class Time
|
|
51
49
|
# We keep overriding this for compatibility
|
52
50
|
def to_s(format = :default)
|
53
51
|
if format == :default
|
54
|
-
|
52
|
+
DATE_FORMATS.key?(:default) ? to_fs(:default) : orig_to_s
|
55
53
|
else
|
56
54
|
orig_to_s(format)
|
57
55
|
end
|
@@ -60,6 +58,7 @@ end
|
|
60
58
|
|
61
59
|
#-------------------------------------------------------------------------------
|
62
60
|
|
61
|
+
# Extend standard DateTime class with our custom to_s overrides
|
63
62
|
class DateTime
|
64
63
|
alias orig_to_s to_s
|
65
64
|
|
@@ -68,7 +67,7 @@ class DateTime
|
|
68
67
|
# We keep overriding this for compatibility
|
69
68
|
def to_s(format = :default)
|
70
69
|
if format == :default
|
71
|
-
|
70
|
+
Time::DATE_FORMATS.key?(:default) ? to_fs(:default) : orig_to_s
|
72
71
|
else
|
73
72
|
orig_to_s(format)
|
74
73
|
end
|
@@ -78,6 +77,7 @@ end
|
|
78
77
|
#-------------------------------------------------------------------------------
|
79
78
|
|
80
79
|
module ActiveSupport
|
80
|
+
# Extend ActiveSupport::TimeWithZone with our custom to_s overrides
|
81
81
|
class TimeWithZone
|
82
82
|
alias orig_to_s to_s
|
83
83
|
|
@@ -86,7 +86,7 @@ module ActiveSupport
|
|
86
86
|
# We keep overriding this for compatibility
|
87
87
|
def to_s(format = :default)
|
88
88
|
if format == :default
|
89
|
-
|
89
|
+
Time::DATE_FORMATS.key?(:default) ? to_fs(:default) : orig_to_s
|
90
90
|
else
|
91
91
|
orig_to_s(format)
|
92
92
|
end
|
@@ -96,6 +96,7 @@ end
|
|
96
96
|
|
97
97
|
#-------------------------------------------------------------------------------
|
98
98
|
|
99
|
+
# NdrSupport module
|
99
100
|
module NdrSupport
|
100
101
|
class << self
|
101
102
|
# Within the NDR, we change default date formatting, as below.
|
@@ -120,8 +121,8 @@ module NdrSupport
|
|
120
121
|
def apply_date_patch!
|
121
122
|
# Ensure we emit "yaml-formatted" string, instead of the revised default format.
|
122
123
|
Psych::Visitors::YAMLTree.class_eval do
|
123
|
-
def visit_Date(o)
|
124
|
-
@emitter.scalar o.
|
124
|
+
def visit_Date(o) # rubocop:disable Naming/MethodName, Naming/MethodParameterName
|
125
|
+
@emitter.scalar o.to_fs(:yaml), nil, nil, true, false, Psych::Nodes::Scalar::ANY
|
125
126
|
end
|
126
127
|
end
|
127
128
|
end
|
@@ -10,11 +10,7 @@ class Ourdate
|
|
10
10
|
def self.build_datetime(year, month = 1, day = 1, hour = 0, min = 0, sec = 0, usec = 0)
|
11
11
|
return nil if year.nil?
|
12
12
|
|
13
|
-
default_timezone =
|
14
|
-
ActiveRecord.default_timezone
|
15
|
-
else
|
16
|
-
ActiveRecord::Base.default_timezone # Rails <= 6.1
|
17
|
-
end
|
13
|
+
default_timezone = ActiveRecord.default_timezone
|
18
14
|
if default_timezone == :local
|
19
15
|
# Time.local_time(year, month, day, hour, min, sec, usec).to_datetime
|
20
16
|
# Behave like oracle_adapter.rb
|
data/lib/ndr_support/ourdate.rb
CHANGED
@@ -15,11 +15,7 @@ class Ourdate
|
|
15
15
|
#--
|
16
16
|
# TODO: Use Ourdate.build_datetime everywhere below:
|
17
17
|
#++
|
18
|
-
default_timezone =
|
19
|
-
ActiveRecord.default_timezone
|
20
|
-
else
|
21
|
-
ActiveRecord::Base.default_timezone # Rails <= 6.1
|
22
|
-
end
|
18
|
+
default_timezone = ActiveRecord.default_timezone
|
23
19
|
if default_timezone == :local
|
24
20
|
build_datetime(current_time.year, current_time.month, current_time.day)
|
25
21
|
else
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module CleanMethodable
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
+
ROMAN_ONE_TO_FIVE_MAPPING = { 'I' => '1', 'II' => '2', 'III' => '3', 'IIII' => '4', 'IV' => '4', 'V' => '5' }.freeze
|
7
|
+
|
6
8
|
CLEAN_METHODS = {
|
7
9
|
nhsnumber: :clean_nhsnumber,
|
8
10
|
postcode: :clean_postcode, get_postcode: :clean_postcode,
|
@@ -129,11 +129,7 @@ class String
|
|
129
129
|
|
130
130
|
def to_datetime
|
131
131
|
# Default timezone for to_datetime conversion is GMT, not local timezone
|
132
|
-
default_timezone =
|
133
|
-
ActiveRecord.default_timezone
|
134
|
-
else
|
135
|
-
ActiveRecord::Base.default_timezone # Rails <= 6.1
|
136
|
-
end
|
132
|
+
default_timezone = ActiveRecord.default_timezone
|
137
133
|
return to_time.to_datetime if default_timezone == :local
|
138
134
|
|
139
135
|
orig_to_datetime
|
data/lib/ndr_support/version.rb
CHANGED
data/ndr_support.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'activerecord', '>=
|
22
|
-
spec.add_dependency 'activesupport', '>=
|
21
|
+
spec.add_dependency 'activerecord', '>= 7.0', '< 8.1'
|
22
|
+
spec.add_dependency 'activesupport', '>= 7.0', '< 8.1'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler'
|
25
25
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
@@ -6,7 +6,11 @@ require 'test_helper'
|
|
6
6
|
class DateAndTimeExtensionsTest < Minitest::Test
|
7
7
|
def test_date_to_s
|
8
8
|
d = Date.new(2000, 2, 1)
|
9
|
-
|
9
|
+
if d.respond_to?(:to_default_s) # Only defined on Rails <= 7.1
|
10
|
+
assert_equal '2000-02-01', d.to_default_s, 'Rails 7 default to_s'
|
11
|
+
else
|
12
|
+
assert_equal '2000-02-01', d.orig_to_s, 'Rails 7 default to_s (via our shim)'
|
13
|
+
end
|
10
14
|
assert_equal '01.02.2000', d.to_formatted_s(:default), 'Rails 6 default to_s'
|
11
15
|
assert_equal d.to_formatted_s(:default), d.to_s,
|
12
16
|
'We plan to change default to_s behaviour in a major version bump'
|
@@ -14,20 +18,33 @@ class DateAndTimeExtensionsTest < Minitest::Test
|
|
14
18
|
|
15
19
|
def test_datetime_to_s
|
16
20
|
bst_datetime = DateTime.new(2014, 4, 1, 0, 0, 0, '+1')
|
17
|
-
|
21
|
+
if bst_datetime.respond_to?(:to_default_s) # Only defined on Rails <= 7.1
|
22
|
+
assert_equal '2014-04-01T00:00:00+01:00', bst_datetime.to_default_s, 'Rails 7 default to_s'
|
23
|
+
else
|
24
|
+
assert_equal '2014-04-01T00:00:00+01:00', bst_datetime.orig_to_s, 'Rails 7 default to_s (via our shim)'
|
25
|
+
end
|
18
26
|
assert_equal '01.04.2014', bst_datetime.to_formatted_s(:default), 'Rails 6 default to_s'
|
19
27
|
assert_equal bst_datetime.to_formatted_s(:default), bst_datetime.to_s,
|
20
28
|
'We plan to change default to_s behaviour in a major version bump'
|
21
29
|
|
22
30
|
gmt_datetime = DateTime.new(2014, 3, 1, 0, 0, 0, '+0')
|
23
|
-
|
31
|
+
if gmt_datetime.respond_to?(:to_default_s) # Only defined on Rails <= 7.1
|
32
|
+
assert_equal '2014-03-01T00:00:00+00:00', gmt_datetime.to_default_s, 'Rails 7 default to_s'
|
33
|
+
else
|
34
|
+
assert_equal '2014-03-01T00:00:00+00:00', gmt_datetime.orig_to_s, 'Rails 7 default to_s (via our shim)'
|
35
|
+
end
|
24
36
|
assert_equal '01.03.2014', gmt_datetime.to_formatted_s(:default), 'Rails 6 default to_s'
|
25
37
|
assert_equal gmt_datetime.to_formatted_s(:default), gmt_datetime.to_s,
|
26
38
|
'We plan to change default to_s behaviour in a major version bump'
|
27
39
|
|
28
40
|
datetime_with_hhmmss = DateTime.new(2014, 4, 1, 12, 35, 11, '+0')
|
29
|
-
|
30
|
-
|
41
|
+
if datetime_with_hhmmss.respond_to?(:to_default_s) # Only defined on Rails <= 7.1
|
42
|
+
assert_equal '2014-04-01T12:35:11+00:00', datetime_with_hhmmss.to_default_s,
|
43
|
+
'Rails 7 default to_s'
|
44
|
+
else
|
45
|
+
assert_equal '2014-04-01T12:35:11+00:00', datetime_with_hhmmss.orig_to_s,
|
46
|
+
'Rails 7 default to_s (via our shim)'
|
47
|
+
end
|
31
48
|
assert_equal '01.04.2014 12:35', datetime_with_hhmmss.to_formatted_s(:default),
|
32
49
|
'Rails 6 default to_s'
|
33
50
|
assert_equal datetime_with_hhmmss.to_formatted_s(:default), datetime_with_hhmmss.to_s,
|
@@ -36,7 +53,11 @@ class DateAndTimeExtensionsTest < Minitest::Test
|
|
36
53
|
|
37
54
|
def test_time_to_s
|
38
55
|
time = Time.new(2014, 4, 1, 12, 35, 11.5, '+01:00')
|
39
|
-
|
56
|
+
if time.respond_to?(:to_default_s) # Only defined on Rails <= 7.1
|
57
|
+
assert_equal '2014-04-01 12:35:11 +0100', time.to_default_s, 'Rails 7 default to_s'
|
58
|
+
else
|
59
|
+
assert_equal '2014-04-01 12:35:11 +0100', time.orig_to_s, 'Rails 7 default to_s (via our shim)'
|
60
|
+
end
|
40
61
|
assert_equal '01.04.2014 12:35', time.to_formatted_s(:default), 'Rails 6 default to_s'
|
41
62
|
assert_equal time.to_formatted_s(:default), time.to_s,
|
42
63
|
'We plan to change default to_s behaviour in a major version bump'
|
@@ -47,8 +68,13 @@ class DateAndTimeExtensionsTest < Minitest::Test
|
|
47
68
|
assert_equal 'BST', time_with_zone.zone
|
48
69
|
# Without ndr_support extensions, we'd expect "2014-04-01 12:35:11 +0100"
|
49
70
|
# but we have to trick the database into assuming all times are UTC to retain local time
|
50
|
-
|
51
|
-
|
71
|
+
if time_with_zone.respond_to?(:to_default_s) # Only defined on Rails <= 7.1
|
72
|
+
assert_equal '2014-04-01 12:35:11 UTC', time_with_zone.to_default_s,
|
73
|
+
'Rails 7 default to_s with our date and time formatting'
|
74
|
+
else
|
75
|
+
assert_equal '2014-04-01 12:35:11 +0100', time_with_zone.orig_to_s,
|
76
|
+
'Rails 7 default to_s with our date and time formatting (via our shim)'
|
77
|
+
end
|
52
78
|
assert_equal '01.04.2014 12:35', time_with_zone.to_formatted_s(:default), 'Rails 6 default to_s'
|
53
79
|
assert_equal time_with_zone.to_formatted_s(:default), time_with_zone.to_s,
|
54
80
|
'We plan to change default to_s behaviour in a major version bump'
|
data/test/daterange_test.rb
CHANGED
@@ -166,11 +166,7 @@ class DaterangeTest < Minitest::Test
|
|
166
166
|
def test_date_with_daylight_saving
|
167
167
|
dr = Daterange.new(Date.new(2017, 9, 2)) # During daylight saving
|
168
168
|
assert_equal '02.09.2017', dr.to_s
|
169
|
-
default_timezone =
|
170
|
-
ActiveRecord.default_timezone
|
171
|
-
else
|
172
|
-
ActiveRecord::Base.default_timezone # Rails <= 6.1
|
173
|
-
end
|
169
|
+
default_timezone = ActiveRecord.default_timezone
|
174
170
|
return unless default_timezone == :local
|
175
171
|
|
176
172
|
assert_equal Date.new(2017, 9, 2).in_time_zone.utc_offset, dr.date1.utc_offset, 'Expect consistent offset'
|
@@ -30,7 +30,9 @@ class String
|
|
30
30
|
assert_equal 'IP222', 'IP222'.postcodeize(:db)
|
31
31
|
assert_equal 'IP222E', 'IP222E'.postcodeize(:db)
|
32
32
|
assert_equal 'HANTS', 'HANTS'.postcodeize(:db)
|
33
|
-
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'clean_log10' do
|
34
36
|
assert_equal '0.0', '0'.clean(:log10)
|
35
37
|
assert_equal '-10.1', '-10.1'.clean(:log10)
|
36
38
|
assert_match(/\A0.041392685158225[0-9]*\z/, '1.1'.clean(:log10),
|
@@ -38,6 +40,17 @@ class String
|
|
38
40
|
assert_equal 'BILBO', 'BILBO'.clean(:log10)
|
39
41
|
end
|
40
42
|
|
43
|
+
test 'clean_roman5' do
|
44
|
+
assert_equal '12345', 'I2345'.clean(:roman5)
|
45
|
+
assert_equal '12345', '1II345'.clean(:roman5)
|
46
|
+
assert_equal '12345', '12III45'.clean(:roman5)
|
47
|
+
assert_equal '12345', '123IIII5'.clean(:roman5)
|
48
|
+
assert_equal '12345', '123IIII5'.clean(:roman5)
|
49
|
+
assert_equal '12345', '123IV5'.clean(:roman5)
|
50
|
+
assert_equal '12345', '1234V'.clean(:roman5)
|
51
|
+
assert_equal '12345', '1II34V'.clean(:roman5)
|
52
|
+
end
|
53
|
+
|
41
54
|
test 'xml_unsafe?' do
|
42
55
|
without_control = 'hello world!'
|
43
56
|
refute without_control.xml_unsafe?
|
@@ -84,11 +84,7 @@ class String::ConversionsTest < Minitest::Test
|
|
84
84
|
|
85
85
|
test 'should convert strings to DateTime correctly' do
|
86
86
|
assert_equal 0, '2018-01-02'.to_datetime.utc_offset
|
87
|
-
default_timezone =
|
88
|
-
ActiveRecord.default_timezone
|
89
|
-
else
|
90
|
-
ActiveRecord::Base.default_timezone # Rails <= 6.1
|
91
|
-
end
|
87
|
+
default_timezone = ActiveRecord.default_timezone
|
92
88
|
return unless default_timezone == :local
|
93
89
|
|
94
90
|
assert_equal Time.new(2017, 9, 2).utc_offset, '2017-09-02'.to_datetime.utc_offset, 'Expect consistent offset'
|
data/test/test_helper.rb
CHANGED
@@ -16,11 +16,7 @@ NdrSupport.apply_era_date_formats!
|
|
16
16
|
# require all dates to be stored in UTC in the database.
|
17
17
|
# Thus a birth date of 1975-06-01 would be stored as 1975-05-31 23.00.00.
|
18
18
|
# Instead, we want to store all times in local time.
|
19
|
-
|
20
|
-
ActiveRecord.default_timezone = :local
|
21
|
-
else
|
22
|
-
ActiveRecord::Base.default_timezone = :local # Rails <= 6.1
|
23
|
-
end
|
19
|
+
ActiveRecord.default_timezone = :local
|
24
20
|
ActiveRecord::Base.time_zone_aware_attributes = false
|
25
21
|
Time.zone = 'London'
|
26
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ndr_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.10.
|
4
|
+
version: 5.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NCRS Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,40 +16,40 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '7.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '7.0'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '8.1'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '7.0'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '8.1'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,9 +220,10 @@ files:
|
|
220
220
|
- README.md
|
221
221
|
- Rakefile
|
222
222
|
- code_safety.yml
|
223
|
-
- gemfiles/Gemfile.rails61
|
224
223
|
- gemfiles/Gemfile.rails70
|
225
224
|
- gemfiles/Gemfile.rails71
|
225
|
+
- gemfiles/Gemfile.rails72
|
226
|
+
- gemfiles/Gemfile.rails80
|
226
227
|
- lib/ndr_support.rb
|
227
228
|
- lib/ndr_support/array.rb
|
228
229
|
- lib/ndr_support/concerns/working_days.rb
|
@@ -299,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
300
|
- !ruby/object:Gem::Version
|
300
301
|
version: '0'
|
301
302
|
requirements: []
|
302
|
-
rubygems_version: 3.
|
303
|
+
rubygems_version: 3.3.27
|
303
304
|
signing_key:
|
304
305
|
specification_version: 4
|
305
306
|
summary: NDR Support library
|