schema_validations 2.4.0 → 2.4.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: 1b78d8982bebac58a973056eafde5936834ccca0d4c14d082ce4de1f077a9520
4
- data.tar.gz: 929c35cc4a3d93b3442396ed13491b806c2d72915f2125bb16884e65ce4bca9c
3
+ metadata.gz: 2ab55b81e765e8fb52d2775cdc56d28457a8210770bd78037fc8a05a5c1e3fa0
4
+ data.tar.gz: a3871e40d193076ad1e8e3144407fa0a87eba01764c96e74d3f35ac8dc61a776
5
5
  SHA512:
6
- metadata.gz: 10650e92299fcb0d86a864587f50f8337bdac03972d195d46eff628ea6de22323c0ef1d0272e840fd8383f8c032413b47eda302dd56bae8cf0163786b4646a69
7
- data.tar.gz: 89b78874b3d66ee0fcde0818677aa6cd00cee09d375e9121e016209c64c40be11e4005cf37ea2694c74810326cc34fc0688236b4e8794fab8fed24cf85d248e2
6
+ metadata.gz: 452d43d12d06516b2667f601e3b49536a2d4e866a61a9391e2f925cfbbd1ce94b503442fd2cdce092327a93b1ae42c35e789639946680873bd7741a1d105421f
7
+ data.tar.gz: cb34384da433ae3ddb1a1318b4ad514f72d1b00c2bf6d28a422051b9e872f3f7797c44b10b3333b5845922ef60fd9fe3a242c9b01e40f86c49a007f0dd076566
@@ -22,9 +22,12 @@ jobs:
22
22
  - '2.5'
23
23
  - '2.7'
24
24
  - '3.0'
25
+ - '3.1'
25
26
  activerecord:
26
27
  - '5.2'
27
28
  - '6.0'
29
+ - '6.1'
30
+ - '7.0'
28
31
  db:
29
32
  - mysql2
30
33
  - sqlite3
@@ -34,6 +37,10 @@ jobs:
34
37
  exclude:
35
38
  - ruby: '3.0'
36
39
  activerecord: '5.2'
40
+ - ruby: '3.1'
41
+ activerecord: '5.2'
42
+ - ruby: '2.5'
43
+ activerecord: '7.0'
37
44
  - db: skip
38
45
  dbversion: skip
39
46
  include:
@@ -45,6 +52,10 @@ jobs:
45
52
  activerecord: '6.0'
46
53
  db: postgresql
47
54
  dbversion: '9.6'
55
+ - ruby: '2.5'
56
+ activerecord: '6.1'
57
+ db: postgresql
58
+ dbversion: '9.6'
48
59
  - ruby: '2.7'
49
60
  activerecord: '5.2'
50
61
  db: postgresql
@@ -53,10 +64,38 @@ jobs:
53
64
  activerecord: '6.0'
54
65
  db: postgresql
55
66
  dbversion: '9.6'
67
+ - ruby: '2.7'
68
+ activerecord: '6.1'
69
+ db: postgresql
70
+ dbversion: '9.6'
71
+ - ruby: '2.7'
72
+ activerecord: '7.0'
73
+ db: postgresql
74
+ dbversion: '9.6'
75
+ - ruby: '3.0'
76
+ activerecord: '6.0'
77
+ db: postgresql
78
+ dbversion: '9.6'
79
+ - ruby: '3.0'
80
+ activerecord: '6.1'
81
+ db: postgresql
82
+ dbversion: '9.6'
56
83
  - ruby: '3.0'
84
+ activerecord: '7.0'
85
+ db: postgresql
86
+ dbversion: '9.6'
87
+ - ruby: '3.1'
57
88
  activerecord: '6.0'
58
89
  db: postgresql
59
90
  dbversion: '9.6'
91
+ - ruby: '3.1'
92
+ activerecord: '6.1'
93
+ db: postgresql
94
+ dbversion: '9.6'
95
+ - ruby: '3.1'
96
+ activerecord: '7.0'
97
+ db: postgresql
98
+ dbversion: '9.6'
60
99
  env:
61
100
  BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}/Gemfile.${{ matrix.db }}"
62
101
  MYSQL_DB_HOST: 127.0.0.1
data/README.md CHANGED
@@ -176,9 +176,17 @@ As of version 1.2.0, SchemaValidations supports and is tested on:
176
176
  <!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
177
177
  * ruby **2.5** with activerecord **5.2**, using **mysql2**, **postgresql:9.6** or **sqlite3**
178
178
  * ruby **2.5** with activerecord **6.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
179
+ * ruby **2.5** with activerecord **6.1**, using **mysql2**, **postgresql:9.6** or **sqlite3**
179
180
  * ruby **2.7** with activerecord **5.2**, using **mysql2**, **postgresql:9.6** or **sqlite3**
180
181
  * ruby **2.7** with activerecord **6.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
182
+ * ruby **2.7** with activerecord **6.1**, using **mysql2**, **postgresql:9.6** or **sqlite3**
183
+ * ruby **2.7** with activerecord **7.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
181
184
  * ruby **3.0** with activerecord **6.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
185
+ * ruby **3.0** with activerecord **6.1**, using **mysql2**, **postgresql:9.6** or **sqlite3**
186
+ * ruby **3.0** with activerecord **7.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
187
+ * ruby **3.1** with activerecord **6.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
188
+ * ruby **3.1** with activerecord **6.1**, using **mysql2**, **postgresql:9.6** or **sqlite3**
189
+ * ruby **3.1** with activerecord **7.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
182
190
 
183
191
  <!-- SCHEMA_DEV: MATRIX - end -->
184
192
 
@@ -190,6 +198,11 @@ Earlier versions of SchemaValidations supported:
190
198
 
191
199
  ## Release Notes
192
200
 
201
+ ### 2.4.1
202
+
203
+ * Add AR 6.1 and 7.0
204
+ * add ruby 3.1
205
+
193
206
  ### 2.4.0
194
207
 
195
208
  * Add AR 6.0
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 6.1", "< 6.2"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "sqlite3"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
+ end
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 7.0", "< 7.1"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "sqlite3"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
+ end
@@ -5,9 +5,15 @@ module SchemaValidations
5
5
  # Validates that the field is not nil?
6
6
  # (Unlike the standard PresenceValidator which uses #blank?)
7
7
  class NotNilValidator < ActiveModel::EachValidator
8
- def validate_each(record, attr_name, value)
9
- record.errors.add(attr_name, :blank, options) if value.nil?
8
+ if Gem::Version.new(::ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
9
+ def validate_each(record, attr_name, value)
10
+ record.errors.add(attr_name, :blank, options) if value.nil?
11
+ end
12
+ else
13
+ def validate_each(record, attr_name, value)
14
+ record.errors.add(attr_name, :blank, **options) if value.nil?
15
+ end
10
16
  end
11
17
  end
12
18
  end
13
- end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SchemaValidations
4
- VERSION = "2.4.0"
4
+ VERSION = "2.4.1"
5
5
  end
data/schema_dev.yml CHANGED
@@ -2,9 +2,12 @@ ruby:
2
2
  - 2.5
3
3
  - 2.7
4
4
  - 3.0
5
+ - 3.1
5
6
  activerecord:
6
7
  - 5.2
7
8
  - 6.0
9
+ - 6.1
10
+ - 7.0
8
11
  db:
9
12
  - mysql2
10
13
  - postgresql
@@ -21,11 +21,11 @@ Gem::Specification.new do |gem|
21
21
 
22
22
  gem.required_ruby_version = '>= 2.5'
23
23
 
24
- gem.add_dependency 'schema_plus_columns', '~> 1.0.0'
25
- gem.add_dependency 'activerecord', '>= 5.2', '< 6.1'
24
+ gem.add_dependency 'schema_plus_columns', '~> 1.0.1'
25
+ gem.add_dependency 'activerecord', '>= 5.2', '< 7.1'
26
26
  gem.add_dependency 'valuable'
27
27
 
28
28
  gem.add_development_dependency 'rake', '~> 13.0'
29
29
  gem.add_development_dependency 'rspec', '~> 3.0'
30
- gem.add_development_dependency 'schema_dev', '~> 4.1'
30
+ gem.add_development_dependency 'schema_dev', '~> 4.2.0'
31
31
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'simplecov'
4
- SimpleCov.start
4
+ SimpleCov.start unless SimpleCov.running
5
5
 
6
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -15,8 +15,6 @@ SchemaDev::Rspec.setup
15
15
 
16
16
  RSpec.configure do |config|
17
17
  config.around(:each) do |example|
18
- remove_all_models
19
-
20
18
  ActiveRecord::Migration.suppress_messages do
21
19
  example.run
22
20
  ensure
@@ -32,14 +30,6 @@ I18n.enforce_available_locales = true
32
30
 
33
31
  Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f }
34
32
 
35
- def remove_all_models
36
- ActiveRecord::Base.descendants.each do |c|
37
- next if c == ActiveRecord::InternalMetadata
38
- next if c == ActiveRecord::SchemaMigration
39
- ActiveSupport::Dependencies.remove_constant c.name
40
- end
41
- end
42
-
43
33
  def define_schema(config={}, &block)
44
34
  ActiveRecord::Migration.suppress_messages do
45
35
  ActiveRecord::Schema.define do
@@ -3,6 +3,15 @@
3
3
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
4
 
5
5
  describe "Validations" do
6
+ def stub_model(name, base = ActiveRecord::Base, &block)
7
+ klass = Class.new(base)
8
+
9
+ if block_given?
10
+ klass.instance_eval(&block)
11
+ end
12
+
13
+ stub_const(name, klass)
14
+ end
6
15
 
7
16
  before(:each) do
8
17
  define_schema do
@@ -41,15 +50,15 @@ describe "Validations" do
41
50
  context "auto-created" do
42
51
  before(:each) do
43
52
  with_auto_validations do
44
- class Article < ActiveRecord::Base ; end
53
+ stub_model('Article')
45
54
 
46
- class Review < ActiveRecord::Base
55
+ stub_model('Review') do
47
56
  belongs_to :article
48
57
  belongs_to :news_article, class_name: 'Article', foreign_key: :article_id
49
58
  schema_validations except: :content
50
59
  end
51
60
 
52
- class ArticleReview < ActiveRecord::Base
61
+ stub_model('ArticleReview') do
53
62
  belongs_to :article
54
63
  belongs_to :review
55
64
  end
@@ -187,7 +196,7 @@ describe "Validations" do
187
196
  end
188
197
  end
189
198
  with_auto_validations do
190
- class AntiNull < ActiveRecord::Base
199
+ stub_model('AntiNull') do
191
200
  def self.all_blank
192
201
  @all_blank ||= AntiNull.new(
193
202
  no_default: '',
@@ -244,8 +253,8 @@ describe "Validations" do
244
253
  context "auto-created but changed" do
245
254
  before(:each) do
246
255
  with_auto_validations do
247
- class Article < ActiveRecord::Base ; end
248
- class Review < ActiveRecord::Base
256
+ stub_model('Article')
257
+ stub_model('Review') do
249
258
  belongs_to :article
250
259
  belongs_to :news_article, class_name: 'Article', foreign_key: :article_id
251
260
  end
@@ -314,7 +323,8 @@ describe "Validations" do
314
323
  end
315
324
 
316
325
  before(:each) do
317
- class Review < ActiveRecord::Base
326
+ stub_model('Article')
327
+ stub_model('Review') do
318
328
  belongs_to :article
319
329
  belongs_to :news_article, class_name: 'Article', foreign_key: :article_id
320
330
  end
@@ -339,10 +349,10 @@ describe "Validations" do
339
349
 
340
350
  context "manually invoked" do
341
351
  before(:each) do
342
- class Article < ActiveRecord::Base ; end
352
+ stub_model('Article')
343
353
  Article.schema_validations only: [:title, :state]
344
354
 
345
- class Review < ActiveRecord::Base
355
+ stub_model('Review') do
346
356
  belongs_to :dummy_association
347
357
  schema_validations except: :content
348
358
  end
@@ -378,7 +388,7 @@ describe "Validations" do
378
388
 
379
389
  context "manually invoked" do
380
390
  before(:each) do
381
- class Review < ActiveRecord::Base
391
+ stub_model('Review') do
382
392
  belongs_to :article
383
393
  end
384
394
  @columns = Review.content_columns.dup
@@ -399,16 +409,16 @@ describe "Validations" do
399
409
  around(:each) { |example| with_auto_validations(&example) }
400
410
 
401
411
  it "should set validations on base class" do
402
- class Review < ActiveRecord::Base ; end
403
- class PremiumReview < Review ; end
412
+ stub_model('Review')
413
+ stub_model('PremiumReview', Review)
404
414
  PremiumReview.new
405
415
  expect(Review.new.error_on(:author).size).to eq(1)
406
416
  end
407
417
 
408
418
  it "shouldn't create doubled validations" do
409
- class Review < ActiveRecord::Base ; end
419
+ stub_model('Review')
410
420
  Review.new
411
- class PremiumReview < Review ; end
421
+ stub_model('PremiumReview', Review)
412
422
  expect(PremiumReview.new.error_on(:author).size).to eq(1)
413
423
  end
414
424
 
@@ -416,7 +426,7 @@ describe "Validations" do
416
426
 
417
427
  context "when used with enum" do
418
428
  it "does not validate numericality" do
419
- class Article < ActiveRecord::Base
429
+ stub_model('Article') do
420
430
  enum state: [:happy, :sad]
421
431
  end
422
432
  expect(Article.new(valid_article_attributes.merge(state: :happy))).to be_valid
@@ -439,7 +449,7 @@ describe "Validations" do
439
449
  end
440
450
 
441
451
  with_auto_validations do
442
- class Book < ActiveRecord::Base; end
452
+ stub_model('Book') do; end
443
453
  end
444
454
  end
445
455
 
@@ -464,8 +474,8 @@ describe "Validations" do
464
474
  end
465
475
 
466
476
  with_auto_validations do
467
- class Folder < ActiveRecord::Base
468
- belongs_to :parent, class_name: Folder.name
477
+ stub_model('Folder') do
478
+ belongs_to :parent, class_name: 'Folder'
469
479
  end
470
480
  end
471
481
  end
@@ -489,7 +499,7 @@ describe "Validations" do
489
499
  end
490
500
  end
491
501
  with_auto_validations do
492
- class Optimistic < ActiveRecord::Base; end
502
+ stub_model('Optimistic') do; end
493
503
  end
494
504
  end
495
505
  it 'should not crash' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ronen Barzel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-05-06 00:00:00.000000000 Z
12
+ date: 2022-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: schema_plus_columns
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 1.0.0
20
+ version: 1.0.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 1.0.0
27
+ version: 1.0.1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activerecord
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: '5.2'
35
35
  - - "<"
36
36
  - !ruby/object:Gem::Version
37
- version: '6.1'
37
+ version: '7.1'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '5.2'
45
45
  - - "<"
46
46
  - !ruby/object:Gem::Version
47
- version: '6.1'
47
+ version: '7.1'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: valuable
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -93,14 +93,14 @@ dependencies:
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '4.1'
96
+ version: 4.2.0
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '4.1'
103
+ version: 4.2.0
104
104
  description: SchemaValidations extends ActiveRecord to automatically create validations
105
105
  by inspecting the database schema. This makes your models more DRY as you no longer
106
106
  need to duplicate NOT NULL, unique, numeric and varchar constraints on the model
@@ -115,7 +115,6 @@ files:
115
115
  - ".github/workflows/prs.yml"
116
116
  - ".gitignore"
117
117
  - ".simplecov"
118
- - ".travis.yml"
119
118
  - Gemfile
120
119
  - MIT-LICENSE
121
120
  - README.md
@@ -129,6 +128,14 @@ files:
129
128
  - gemfiles/activerecord-6.0/Gemfile.mysql2
130
129
  - gemfiles/activerecord-6.0/Gemfile.postgresql
131
130
  - gemfiles/activerecord-6.0/Gemfile.sqlite3
131
+ - gemfiles/activerecord-6.1/Gemfile.base
132
+ - gemfiles/activerecord-6.1/Gemfile.mysql2
133
+ - gemfiles/activerecord-6.1/Gemfile.postgresql
134
+ - gemfiles/activerecord-6.1/Gemfile.sqlite3
135
+ - gemfiles/activerecord-7.0/Gemfile.base
136
+ - gemfiles/activerecord-7.0/Gemfile.mysql2
137
+ - gemfiles/activerecord-7.0/Gemfile.postgresql
138
+ - gemfiles/activerecord-7.0/Gemfile.sqlite3
132
139
  - init.rb
133
140
  - lib/schema_validations.rb
134
141
  - lib/schema_validations/active_record/type.rb
@@ -160,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
167
  - !ruby/object:Gem::Version
161
168
  version: '0'
162
169
  requirements: []
163
- rubygems_version: 3.0.8
170
+ rubygems_version: 3.1.6
164
171
  signing_key:
165
172
  specification_version: 4
166
173
  summary: Automatically creates validations basing on the database schema.
data/.travis.yml DELETED
@@ -1,24 +0,0 @@
1
- # This file was auto-generated by the schema_dev tool, based on the data in
2
- # ./schema_dev.yml
3
- # Please do not edit this file; any changes will be overwritten next time
4
- # schema_dev gets run.
5
- ---
6
- sudo: false
7
- rvm:
8
- - 2.3.1
9
- gemfile:
10
- - gemfiles/activerecord-5.0/Gemfile.mysql2
11
- - gemfiles/activerecord-5.0/Gemfile.postgresql
12
- - gemfiles/activerecord-5.0/Gemfile.sqlite3
13
- - gemfiles/activerecord-5.1/Gemfile.mysql2
14
- - gemfiles/activerecord-5.1/Gemfile.postgresql
15
- - gemfiles/activerecord-5.1/Gemfile.sqlite3
16
- - gemfiles/activerecord-5.2/Gemfile.mysql2
17
- - gemfiles/activerecord-5.2/Gemfile.postgresql
18
- - gemfiles/activerecord-5.2/Gemfile.sqlite3
19
- env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
20
- addons:
21
- postgresql: '9.4'
22
- before_script: bundle exec rake create_databases
23
- after_script: bundle exec rake drop_databases
24
- script: bundle exec rake travis