paranoia_uniqueness_validator 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Gemfile +1 -1
- data/README.md +5 -2
- data/docker-compose.yml +1 -1
- data/lib/paranoia_uniqueness_validator/validations/uniqueness_without_deleted.rb +3 -4
- data/lib/paranoia_uniqueness_validator/version.rb +1 -1
- data/paranoia_uniqueness_validator.gemspec +6 -5
- data/spec/dummy/config/initializers/new_framework_defaults.rb +0 -3
- data/spec/validations/uniqueness_without_deleted_spec.rb +3 -2
- metadata +22 -22
- data/Dockerfile +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad82f8dc3a747d34926d95905b6194f554db18f6
|
4
|
+
data.tar.gz: b5a9e10595083c04576275f1a6ddb99ed1091ea8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d0780ebd71e952aaabbd1de3101d6fe86b22b8154c190e038f05e4a1841d27efdb92ecdd7487887d7443641fa62cc2c6734d8e1da7348e678137842b015c15a
|
7
|
+
data.tar.gz: 12e46e861c058e500e3273711287d4c59501a9e5f294be2b325c94287a7fd7a13b50d97a5cb1523a14976aa0f88d592a6f2c5ad70dee9006651b832c6e96c493
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -16,9 +16,12 @@ Add this line to your application's Gemfile:
|
|
16
16
|
# Rails 4
|
17
17
|
gem 'paranoia_uniqueness_validator', '1.1.0'
|
18
18
|
|
19
|
-
# Rails 5
|
19
|
+
# Rails 5.0
|
20
20
|
gem 'paranoia_uniqueness_validator', '2.0.0'
|
21
|
-
|
21
|
+
|
22
|
+
# Rails 5.1
|
23
|
+
gem 'paranoia_uniqueness_validator', '3.0.0'
|
24
|
+
|
22
25
|
And then execute:
|
23
26
|
|
24
27
|
$ bundle
|
data/docker-compose.yml
CHANGED
@@ -3,18 +3,17 @@ module ParanoiaUniquenessValidator
|
|
3
3
|
class UniquenessWithoutDeletedValidator < ActiveRecord::Validations::UniquenessValidator
|
4
4
|
def validate_each(record, attribute, value)
|
5
5
|
finder_class = find_finder_class_for(record)
|
6
|
-
table = finder_class.arel_table
|
7
6
|
value = map_enum_attribute(finder_class, attribute, value)
|
8
7
|
|
9
|
-
relation = build_relation(finder_class,
|
8
|
+
relation = build_relation(finder_class, attribute, value)
|
10
9
|
if record.persisted?
|
11
10
|
if finder_class.primary_key
|
12
|
-
relation = relation.where.not(finder_class.primary_key => record.
|
11
|
+
relation = relation.where.not(finder_class.primary_key => record.id_in_database || record.id)
|
13
12
|
else
|
14
13
|
raise UnknownPrimaryKey.new(finder_class, "Can not validate uniqueness for persisted record without primary key.")
|
15
14
|
end
|
16
15
|
end
|
17
|
-
relation = scope_relation(record,
|
16
|
+
relation = scope_relation(record, relation)
|
18
17
|
relation = relation.merge(options[:conditions]) if options[:conditions]
|
19
18
|
|
20
19
|
if defined?('Paranoia') && Paranoia.respond_to?(:default_sentinel_value)
|
@@ -10,16 +10,17 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["anthony@sticksnleaves.com"]
|
11
11
|
gem.description = %q{Adds the validates_uniqueness_without_deleted validator to ignore deleted fields when validating for uniqueness.}
|
12
12
|
gem.summary = %q{Validate unique fields without letting those pesky deleted records get in the way. Great for use with Paranoia.}
|
13
|
-
gem.homepage = ""
|
13
|
+
gem.homepage = "https://github.com/anthonator/paranoia_uniqueness_validator"
|
14
|
+
gem.license = "MIT"
|
14
15
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
19
|
gem.require_paths = ["lib"]
|
19
20
|
|
20
|
-
gem.add_dependency "activerecord", ">= 5.
|
21
|
+
gem.add_dependency "activerecord", ">= 5.1.0", "< 5.2"
|
21
22
|
|
22
|
-
gem.add_development_dependency "paranoia"
|
23
|
-
gem.add_development_dependency "database_cleaner"
|
24
|
-
gem.add_development_dependency "rspec-rails"
|
23
|
+
gem.add_development_dependency "paranoia", "~> 2.3"
|
24
|
+
gem.add_development_dependency "database_cleaner", "~> 1.6"
|
25
|
+
gem.add_development_dependency "rspec-rails", "~> 3.6"
|
25
26
|
end
|
@@ -17,8 +17,5 @@ ActiveSupport.to_time_preserves_timezone = true
|
|
17
17
|
# Require `belongs_to` associations by default. Previous versions had false.
|
18
18
|
Rails.application.config.active_record.belongs_to_required_by_default = true
|
19
19
|
|
20
|
-
# Do not halt callback chains when a callback returns false. Previous versions had true.
|
21
|
-
ActiveSupport.halt_callback_chains_on_return_false = false
|
22
|
-
|
23
20
|
# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
|
24
21
|
Rails.application.config.ssl_options = { hsts: { subdomains: true } }
|
@@ -32,14 +32,15 @@ describe ParanoiaUniquenessValidator::Validations::UniquenessWithoutDeletedValid
|
|
32
32
|
|
33
33
|
it "should validate uniqueness" do
|
34
34
|
DummyNonNilModel.create(:unique_field => "unique")
|
35
|
-
|
35
|
+
|
36
|
+
expect(DummyNonNilModel.new(:unique_field => "unique")).to_not be_valid
|
36
37
|
end
|
37
38
|
|
38
39
|
it "should should be valid if not unique with a deleted record" do
|
39
40
|
dummy_model = DummyNonNilModel.create(:unique_field => "unique")
|
40
41
|
dummy_model.destroy
|
41
42
|
dummy_model = DummyNonNilModel.new(:unique_field => "unique")
|
42
|
-
dummy_model.
|
43
|
+
expect(dummy_model).to be_valid
|
43
44
|
end
|
44
45
|
|
45
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paranoia_uniqueness_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,62 +16,62 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.
|
19
|
+
version: 5.1.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '5.
|
22
|
+
version: '5.2'
|
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: 5.
|
29
|
+
version: 5.1.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '5.
|
32
|
+
version: '5.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: paranoia
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '2.3'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '2.3'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: database_cleaner
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '1.6'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - "
|
58
|
+
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '1.6'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rspec-rails
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '3.6'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - "
|
72
|
+
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '3.6'
|
75
75
|
description: Adds the validates_uniqueness_without_deleted validator to ignore deleted
|
76
76
|
fields when validating for uniqueness.
|
77
77
|
email:
|
@@ -82,7 +82,6 @@ extra_rdoc_files: []
|
|
82
82
|
files:
|
83
83
|
- ".gitignore"
|
84
84
|
- ".travis.yml"
|
85
|
-
- Dockerfile
|
86
85
|
- Gemfile
|
87
86
|
- LICENSE.txt
|
88
87
|
- README.md
|
@@ -164,8 +163,9 @@ files:
|
|
164
163
|
- spec/dummy/vendor/assets/stylesheets/.keep
|
165
164
|
- spec/spec_helper.rb
|
166
165
|
- spec/validations/uniqueness_without_deleted_spec.rb
|
167
|
-
homepage:
|
168
|
-
licenses:
|
166
|
+
homepage: https://github.com/anthonator/paranoia_uniqueness_validator
|
167
|
+
licenses:
|
168
|
+
- MIT
|
169
169
|
metadata: {}
|
170
170
|
post_install_message:
|
171
171
|
rdoc_options: []
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
requirements: []
|
185
185
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.6.
|
186
|
+
rubygems_version: 2.6.11
|
187
187
|
signing_key:
|
188
188
|
specification_version: 4
|
189
189
|
summary: Validate unique fields without letting those pesky deleted records get in
|
data/Dockerfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
FROM ruby:2.3
|
2
|
-
|
3
|
-
MAINTAINER Anthony Smith <anthony@sticksnleaves.com>
|
4
|
-
|
5
|
-
ENV APP_HOME /usr/src/app
|
6
|
-
|
7
|
-
RUN apt-get update -y \
|
8
|
-
&& apt-get upgrade -y
|
9
|
-
|
10
|
-
RUN gem install rubygems-update --no-document
|
11
|
-
RUN gem install bundler --no-document
|
12
|
-
|
13
|
-
WORKDIR $APP_HOME
|