activerecord-databasevalidations 0.4.0 → 0.5.0

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: 16b7e2657966158be5c02fd634d034b0ff7a63adbd82341f0abcab9e41d87fed
4
- data.tar.gz: cf06bf1331a19a0bc11736212277ad595ecc2469900eae210d754fbc76cc2a83
3
+ metadata.gz: 86138fed43c841609f1a4b0f1952d956e84040d14bc966731ce8ffd56a533309
4
+ data.tar.gz: e133a86b1cb4c996c609c00e5b683fadab0d28bcfd696502cfc330c6a40d23d6
5
5
  SHA512:
6
- metadata.gz: '078c2e682da2fa04f716c950ff7ab2608335ee0142b3b507d4e3c7249688187d914c1d1d12c5101ad4f46125c9628c3aafb0aa39606abea34d3354a59c4b974c'
7
- data.tar.gz: aaf055985a320538354863a635bb879e40e733cc75d0abccc586134e8d78b019a7b27aef9f74cc1bbc247aee113dfa1fbb490d089e5929befde7d06dcb3f4125
6
+ metadata.gz: df4cb11a72a91ff8073a94c0bc1d5641cc9d674efd237b643c223ce49a3a8a660e185d3044fa78b416cdf0bd87494ea2b0d9338b9950675e182a9e7ce49b7054
7
+ data.tar.gz: f87e0c673004f5b1a16763c297da0744993388ca0d48ac6857f9a2b4b68f34409c2bb2c3e893706f7f5a96ec1e3688a7a6df2077a1947ba8beb4884c8044ace7
@@ -1,25 +1,16 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
+ services:
5
+ - mysql
4
6
 
5
7
  rvm:
6
- - 2.2.2
7
- - 2.3.0
8
- - 2.4.1
9
- - 2.5.0
8
+ - '2.5'
9
+ - '2.6'
10
10
 
11
11
  gemfile:
12
- - gemfiles/Gemfile.activerecord50
13
- - gemfiles/Gemfile.activerecord51
14
12
  - gemfiles/Gemfile.activerecord52
15
- - gemfiles/Gemfile.activerecord-edge
16
-
17
- matrix:
18
- exclude:
19
- - rvm: 2.2.2
20
- gemfile: gemfiles/Gemfile.activerecord-edge
21
- - rvm: 2.3.0
22
- gemfile: gemfiles/Gemfile.activerecord-edge
13
+ - gemfiles/Gemfile.activerecord60
23
14
 
24
15
  before_script:
25
16
  - mysql -e 'create database database_validations;'
@@ -18,9 +18,9 @@ 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.required_ruby_version = '>= 2.2.2'
21
+ spec.required_ruby_version = '>= 2.5'
22
22
 
23
- spec.add_runtime_dependency "activerecord", ">= 5.0"
23
+ spec.add_runtime_dependency "activerecord", ">= 5.2"
24
24
  spec.add_runtime_dependency "rejectu"
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.5"
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec path: '..'
3
3
 
4
- gem 'activerecord', github: 'rails/rails', branch: '5-2-stable'
4
+ gem 'activerecord', '~> 5.2.0'
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec path: '..'
3
3
 
4
- gem 'activerecord', '~> 5.0.0'
4
+ gem 'activerecord', '~> 6.0.0'
@@ -64,8 +64,12 @@ module ActiveRecord
64
64
 
65
65
  def self.value_for_column(value, column_encoding = nil)
66
66
  value = value.to_s unless value.is_a?(String)
67
- value.encode!('utf-8') if requires_transcoding?(value, column_encoding)
68
- return value
67
+
68
+ if requires_transcoding?(value, column_encoding)
69
+ return value.encode(Encoding::UTF_8)
70
+ end
71
+
72
+ value
69
73
  end
70
74
  end
71
75
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module DatabaseValidations
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -33,8 +33,8 @@ class DataLossTest < Minitest::Test
33
33
  end
34
34
 
35
35
  def test_decimal_silently_changes_out_of_bound_values
36
- maximum = BigDecimal.new(10 ** (Unicorn.columns_hash['decimal'].precision - Unicorn.columns_hash['decimal'].scale))
37
- delta = BigDecimal.new(10 ** -(Unicorn.columns_hash['decimal'].scale), Unicorn.columns_hash['decimal'].precision)
36
+ maximum = BigDecimal(10 ** (Unicorn.columns_hash['decimal'].precision - Unicorn.columns_hash['decimal'].scale))
37
+ delta = BigDecimal(10 ** -(Unicorn.columns_hash['decimal'].scale), Unicorn.columns_hash['decimal'].precision)
38
38
 
39
39
  refute_data_loss Unicorn.new(decimal: maximum - delta)
40
40
  assert_data_loss Unicorn.new(decimal: maximum)
@@ -42,8 +42,8 @@ class DataLossTest < Minitest::Test
42
42
  assert_data_loss Unicorn.new(decimal: 0 - maximum)
43
43
 
44
44
 
45
- maximum = BigDecimal.new(10 ** (Unicorn.columns_hash['unsigned_decimal'].precision - Unicorn.columns_hash['unsigned_decimal'].scale))
46
- delta = BigDecimal.new(10 ** -(Unicorn.columns_hash['unsigned_decimal'].scale), Unicorn.columns_hash['unsigned_decimal'].precision)
45
+ maximum = BigDecimal(10 ** (Unicorn.columns_hash['unsigned_decimal'].precision - Unicorn.columns_hash['unsigned_decimal'].scale))
46
+ delta = BigDecimal(10 ** -(Unicorn.columns_hash['unsigned_decimal'].scale), Unicorn.columns_hash['unsigned_decimal'].precision)
47
47
 
48
48
  refute_data_loss Unicorn.new(unsigned_decimal: maximum - delta)
49
49
  assert_data_loss Unicorn.new(unsigned_decimal: maximum)
@@ -99,7 +99,7 @@ class DataLossTest < Minitest::Test
99
99
  end
100
100
 
101
101
  def test_utf8mb3_field_sliently_truncates_strings_after_first_4byte_character
102
- emoji = '💩'
102
+ emoji = "\u{1F4A9}"
103
103
  assert_equal 1, emoji.length
104
104
  assert_equal 4, emoji.bytesize
105
105
  assert_data_loss Unicorn.new(string: emoji)
@@ -98,7 +98,7 @@ class DatabaseConstraintsValidatorTest < Minitest::Test
98
98
  assert_equal 1, subvalidators.length
99
99
  assert_kind_of ActiveModel::Validations::BytesizeValidator, subvalidators.first
100
100
  assert_equal 65535, subvalidators.first.options[:maximum]
101
- assert_equal nil, subvalidators.first.encoding
101
+ assert_nil subvalidators.first.encoding
102
102
  end
103
103
 
104
104
  def test_not_null_text_field_defines_requested_bytesize_validator_and_unicode_validator
@@ -120,7 +120,7 @@ class DatabaseConstraintsValidatorTest < Minitest::Test
120
120
 
121
121
  def test_should_not_create_a_validator_for_a_utf8mb4_field
122
122
  assert Bar._validators[:mb4_string].first.attribute_validators(Bar, :mb4_string).empty?
123
- emoji = Bar.new(mb4_string: '💩')
123
+ emoji = Bar.new(mb4_string: '')
124
124
  assert emoji.valid?
125
125
  refute_data_loss emoji
126
126
  end
@@ -214,7 +214,7 @@ class DatabaseConstraintsValidatorTest < Minitest::Test
214
214
  end
215
215
 
216
216
  def test_error_messages
217
- foo = Foo.new(string: 'ü' * 41, checked: nil, not_null_text: '💩')
217
+ foo = Foo.new(string: 'ü' * 41, checked: nil, not_null_text: "\u{1F4A9}")
218
218
  refute foo.save
219
219
 
220
220
  assert_equal ["is too long (maximum is 40 characters)"], foo.errors[:string]
@@ -14,7 +14,7 @@ class VarcharDefaultSizeTest < Minitest::Test
14
14
  ActiveRecord::Migration.add_index(:varchars, :string, unique: true)
15
15
  end
16
16
 
17
- assert_match /\Autf8mb4_/, Varchar.columns_hash['string'].collation
18
- assert_equal 191, Varchar.columns_hash['string'].limit
17
+ assert_match(/\Autf8mb4_/, Varchar.columns_hash['string'].collation)
18
+ assert_equal(191, Varchar.columns_hash['string'].limit)
19
19
  end
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-databasevalidations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-20 00:00:00.000000000 Z
11
+ date: 2019-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '5.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: '5.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rejectu
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -110,10 +110,8 @@ files:
110
110
  - README.md
111
111
  - Rakefile
112
112
  - activerecord-databasevalidations.gemspec
113
- - gemfiles/Gemfile.activerecord-edge
114
- - gemfiles/Gemfile.activerecord50
115
- - gemfiles/Gemfile.activerecord51
116
113
  - gemfiles/Gemfile.activerecord52
114
+ - gemfiles/Gemfile.activerecord60
117
115
  - lib/active_model/validations/basic_multilingual_plane.rb
118
116
  - lib/active_model/validations/bytesize.rb
119
117
  - lib/active_model/validations/not_null.rb
@@ -149,15 +147,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
147
  requirements:
150
148
  - - ">="
151
149
  - !ruby/object:Gem::Version
152
- version: 2.2.2
150
+ version: '2.5'
153
151
  required_rubygems_version: !ruby/object:Gem::Requirement
154
152
  requirements:
155
153
  - - ">="
156
154
  - !ruby/object:Gem::Version
157
155
  version: '0'
158
156
  requirements: []
159
- rubyforge_project:
160
- rubygems_version: 2.7.6
157
+ rubygems_version: 3.0.4
161
158
  signing_key:
162
159
  specification_version: 4
163
160
  summary: Add validations to your ActiveRecord models based on MySQL database constraints.
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec path: '..'
3
-
4
- gem 'activerecord', github: 'rails/rails', branch: 'master'
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec path: '..'
3
-
4
- gem 'activerecord', '~> 5.1.0'