validates_timeliness 6.0.1 → 7.0.0.beta1

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: a72c9c656e7bb6b4987658858001d6654a591b12a2aa6322f2b38a932ef4c7b5
4
- data.tar.gz: b8449806435f41af895a80c61a7e641f42d4581aaee40183781a222ea027876a
3
+ metadata.gz: 284d18473a0007c273fc4608579b619afac6a3809dfdcd12864d6aeea30c6f17
4
+ data.tar.gz: 12d2db9663bb6c80a643d7c7365fc4d44218a64a9b69feacb6d060dc737ddd93
5
5
  SHA512:
6
- metadata.gz: 68e98f1017b315190106b17608ce8d5df1977f101154c91a89fea550b2546b10ec569b6ba79ff51ae4efd760bc61e91756e7561624b8e8da7ae281d407c012a4
7
- data.tar.gz: bda2a3e5f833ed1e3467e5e3ee2c2030d964187e9c23611c2afa1265c76096590332ae1739d8196c429eca57a2f8720a1c2e67cb87e75ba8a777f1c7f8939e56
6
+ metadata.gz: 77eb167f597fe224c293b6a9e9143c0b5eb8b443ed54539dc89e34c28e5cb7c9517e826c25660641281d6b477451cb2ff4b1187f0332e33fd0d94d7618223204
7
+ data.tar.gz: de5c7cb989b1148acf4a7af524171c7eead44663b43088da99f79bb5af7c7b1c120f28ace62cb62bcfe533979fbe9975763e59aa463acccf7ed1a951496e1f39
@@ -7,18 +7,12 @@ jobs:
7
7
  fail-fast: false
8
8
  matrix:
9
9
  include:
10
- - gemfile: rails_6_0
11
- ruby: 2.6
12
- - gemfile: rails_6_0
10
+ - gemfile: rails_7_0
13
11
  ruby: 2.7
14
- - gemfile: rails_6_0
15
- ruby: 3.0
16
- - gemfile: rails_6_1
17
- ruby: 2.6
18
- - gemfile: rails_6_1
19
- ruby: 2.7
20
- - gemfile: rails_6_1
12
+ - gemfile: rails_7_0
21
13
  ruby: 3.0
14
+ - gemfile: rails_7_0
15
+ ruby: 3.1
22
16
 
23
17
  name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}
24
18
  env:
data/README.md CHANGED
@@ -6,13 +6,13 @@
6
6
 
7
7
  ## Description
8
8
 
9
- Complete validation of dates, times and datetimes for Rails 6.x and
10
- ActiveModel.
9
+ Complete validation of dates, times and datetimes for Rails 7.x and ActiveModel.
11
10
 
12
- Old Rails versions:
11
+ Older Rails versions:
13
12
 
14
13
  - Rails 4.x: [https://github.com/adzap/validates_timeliness/tree/4-0-stable]
15
14
  - Rails 5.x: [https://github.com/adzap/validates_timeliness/tree/5-0-stable]
15
+ - Rails 6.x: [https://github.com/adzap/validates_timeliness/tree/6-0-stable]
16
16
 
17
17
 
18
18
  ## Features
@@ -30,7 +30,7 @@ Old Rails versions:
30
30
 
31
31
  In Gemfile
32
32
  ```ruby
33
- gem 'validates_timeliness', '~> 6.0.0'
33
+ gem 'validates_timeliness', '~> 7.0.0.beta1'
34
34
  ```
35
35
 
36
36
  Run bundler:
@@ -2,9 +2,9 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "~> 6.0.0"
5
+ gem "rails", "~> 7.0.0"
6
6
  gem "rspec"
7
- gem "rspec-rails", "~> 3.7"
7
+ gem "rspec-rails", "~> 6.0"
8
8
  gem "sqlite3"
9
9
  gem "byebug"
10
10
  gem "appraisal"
@@ -2,11 +2,10 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "~> 6.1.0"
5
+ gem "rails", git: "https://github.com/rails/rails.git", branch: "main"
6
6
  gem "rspec"
7
7
  gem "rspec-rails", "~> 3.7"
8
8
  gem "sqlite3"
9
- gem "timecop"
10
9
  gem "byebug"
11
10
  gem "appraisal"
12
11
  gem "nokogiri", "~> 1.8"
@@ -19,13 +19,12 @@ module ValidatesTimeliness
19
19
  when :date
20
20
  value.to_date
21
21
  when :datetime
22
- value.is_a?(Time) ? value : (time_zone_aware? ? value.in_time_zone : value.to_time)
22
+ value.is_a?(Time) ? value : value.to_time
23
23
  else
24
24
  value
25
25
  end
26
-
27
26
  if ignore_usec && value.is_a?(Time)
28
- value.change(usec: 0)
27
+ Timeliness::Parser.make_time(Array(value).reverse[4..9], (:current if time_zone_aware?))
29
28
  else
30
29
  value
31
30
  end
@@ -20,7 +20,7 @@ module ActiveModel
20
20
 
21
21
  def timeliness_validation_for(attr_names, type=nil)
22
22
  options = _merge_attributes(attr_names)
23
- options.update(type: type) if type
23
+ options.update(:type => type) if type
24
24
  validates_with TimelinessValidator, options
25
25
  end
26
26
  end
@@ -2,7 +2,7 @@ module ValidatesTimeliness
2
2
  class Railtie < Rails::Railtie
3
3
  initializer "validates_timeliness.initialize_active_record", :after => 'active_record.initialize_timezone' do
4
4
  ActiveSupport.on_load(:active_record) do
5
- ValidatesTimeliness.default_timezone = ActiveRecord::Base.default_timezone
5
+ ValidatesTimeliness.default_timezone = ActiveRecord.default_timezone
6
6
  ValidatesTimeliness.extend_orms << :active_record
7
7
  ValidatesTimeliness.load_orms
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module ValidatesTimeliness
2
- VERSION = '6.0.1'
2
+ VERSION = '7.0.0.beta1'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -57,7 +57,7 @@ class PersonWithShim < Person
57
57
  include TestModelShim
58
58
  end
59
59
 
60
- ActiveRecord::Base.default_timezone = :utc
60
+ ActiveRecord.default_timezone = :utc
61
61
  ActiveRecord::Base.time_zone_aware_attributes = true
62
62
  ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', :database => ':memory:'})
63
63
  ActiveRecord::Base.time_zone_aware_types = [:datetime, :time]
@@ -63,61 +63,30 @@ 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 }
66
67
 
67
- it 'should return nil for invalid value types' do
68
- expect(type_cast_value(12)).to eq(nil)
68
+ it "should return Date as Time value" do
69
+ expect(type_cast_value(Date.new(2010, 1, 1))).to eq(Time.local(2010, 1, 1, 0, 0, 0))
69
70
  end
70
71
 
71
- context "time zone aware" do
72
- let(:time_zone_aware) { true }
73
-
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
96
-
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
72
+ it "should return same Time value" do
73
+ value = Time.utc(2010, 1, 1, 12, 34, 56)
74
+ expect(type_cast_value(Time.utc(2010, 1, 1, 12, 34, 56))).to eq(value)
104
75
  end
105
76
 
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
77
+ it "should return as Time with same component values" do
78
+ 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))
79
+ end
112
80
 
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
81
+ it "should return same Time in correct zone if timezone aware" do
82
+ value = Time.utc(2010, 1, 1, 12, 34, 56)
83
+ result = type_cast_value(value)
84
+ expect(result).to eq(Time.zone.local(2010, 1, 1, 23, 34, 56))
85
+ expect(result.zone).to eq('AEDT')
86
+ end
117
87
 
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
88
+ it 'should return nil for invalid value types' do
89
+ expect(type_cast_value(12)).to eq(nil)
121
90
  end
122
91
  end
123
92
 
@@ -27,6 +27,6 @@ Gem::Specification.new do |s|
27
27
  "wiki_uri" => "#{github_url}/wiki",
28
28
  }
29
29
 
30
- s.add_runtime_dependency("activemodel", [">= 6.0.0", "< 7"])
30
+ s.add_runtime_dependency("activemodel", [">= 7.0.0", "< 8"])
31
31
  s.add_runtime_dependency("timeliness", [">= 0.3.10", "< 1"])
32
32
  end
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.1
4
+ version: 7.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Meehan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-12 00:00:00.000000000 Z
11
+ date: 2022-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0
19
+ version: 7.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '8'
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: 6.0.0
29
+ version: 7.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: timeliness
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -66,8 +66,8 @@ files:
66
66
  - LICENSE
67
67
  - README.md
68
68
  - Rakefile
69
- - gemfiles/rails_6_0.gemfile
70
- - gemfiles/rails_6_1.gemfile
69
+ - gemfiles/rails_7_0.gemfile
70
+ - gemfiles/rails_edge.gemfile
71
71
  - init.rb
72
72
  - lib/generators/validates_timeliness/install_generator.rb
73
73
  - lib/generators/validates_timeliness/templates/en.yml
@@ -94,6 +94,7 @@ files:
94
94
  - spec/validates_timeliness/extensions/date_time_select_spec.rb
95
95
  - spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
96
96
  - spec/validates_timeliness/helper_methods_spec.rb
97
+ - spec/validates_timeliness/orm/active_model_spec.rb
97
98
  - spec/validates_timeliness/orm/active_record_spec.rb
98
99
  - spec/validates_timeliness/railtie_spec.rb
99
100
  - spec/validates_timeliness/validator/after_spec.rb
@@ -123,9 +124,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
124
  version: '0'
124
125
  required_rubygems_version: !ruby/object:Gem::Requirement
125
126
  requirements:
126
- - - ">="
127
+ - - ">"
127
128
  - !ruby/object:Gem::Version
128
- version: '0'
129
+ version: 1.3.1
129
130
  requirements: []
130
131
  rubygems_version: 3.1.6
131
132
  signing_key:
@@ -142,6 +143,7 @@ test_files:
142
143
  - spec/validates_timeliness/extensions/date_time_select_spec.rb
143
144
  - spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
144
145
  - spec/validates_timeliness/helper_methods_spec.rb
146
+ - spec/validates_timeliness/orm/active_model_spec.rb
145
147
  - spec/validates_timeliness/orm/active_record_spec.rb
146
148
  - spec/validates_timeliness/railtie_spec.rb
147
149
  - spec/validates_timeliness/validator/after_spec.rb