paranoia_uniqueness_validator 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.travis.yml +6 -9
- data/Dockerfile +13 -0
- data/Gemfile +3 -9
- data/README.md +4 -0
- data/docker-compose.yml +11 -0
- data/lib/paranoia_uniqueness_validator/validations/uniqueness_without_deleted.rb +16 -13
- data/lib/paranoia_uniqueness_validator/version.rb +1 -1
- data/paranoia_uniqueness_validator.gemspec +1 -1
- data/spec/dummy/.gitignore +9 -3
- data/spec/dummy/.rspec +1 -0
- data/spec/dummy/{README.rdoc → README.md} +1 -5
- data/spec/dummy/Rakefile +2 -2
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/{mailers → assets/images}/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +4 -4
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/{models → assets/javascripts/channels}/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +6 -4
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +0 -2
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/dummy_model.rb +1 -1
- data/spec/dummy/app/models/dummy_non_nil_model.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +9 -9
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config.ru +2 -1
- data/spec/dummy/config/application.rb +8 -10
- data/spec/dummy/config/boot.rb +3 -5
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.yml +7 -11
- data/spec/dummy/config/environment.rb +4 -4
- data/spec/dummy/config/environments/development.rb +30 -5
- data/spec/dummy/config/environments/production.rb +37 -31
- data/spec/dummy/config/environments/test.rb +10 -4
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -2
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +2 -48
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/db/migrate/20130511080827_create_dummy_models.rb +1 -1
- data/spec/dummy/db/migrate/20160421194241_create_dummy_non_nil_models.rb +1 -1
- data/spec/dummy/db/schema.rb +5 -6
- data/spec/dummy/db/seeds.rb +3 -3
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +20 -11
- data/spec/dummy/public/422.html +20 -11
- data/spec/dummy/public/500.html +19 -10
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/robots.txt +1 -1
- data/spec/spec_helper.rb +1 -2
- data/spec/validations/uniqueness_without_deleted_spec.rb +9 -9
- metadata +61 -13
- data/spec/dummy/config/initializers/secret_token.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6c43ab07ae51e7b81827a2eb89534c4fd26ef36
|
4
|
+
data.tar.gz: a5a83e727c9ea0a0a6b45a06164fc52c2b44465d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e57390dcc1bdee3a5d356fdf0d94bebc9c08b5501fe74de02c0bbee526139dad60a46ddf7d5cc32eb626d645bd6b32a199b3ec30e7abb4415762ff3ffd4ae62
|
7
|
+
data.tar.gz: 0bbf526c132a4c7efb252ed0704d946a0de03809595e4868cdbcdb7134c6940e41bc396a7c9c80d1beb1fb1e7e902115d5d60ba5223954024bfbab18d309d8e3
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,19 +1,16 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
-
|
4
|
-
- 2.
|
5
|
-
- 2.1.0
|
6
|
-
- 2.2.0
|
3
|
+
- 2.2.5
|
4
|
+
- 2.3.0
|
7
5
|
- ruby-head
|
8
|
-
- jruby-19mode
|
9
6
|
- jruby-head
|
10
|
-
- rbx
|
11
7
|
env:
|
12
|
-
- "RAILS_VERSION=
|
13
|
-
- "RAILS_VERSION=
|
14
|
-
- "RAILS_VERSION=
|
8
|
+
- "RAILS_VERSION=master"
|
9
|
+
- "RAILS_VERSION=5.0.0"
|
10
|
+
- "RAILS_VERSION=5.0.0.1"
|
15
11
|
matrix:
|
16
12
|
allow_failures:
|
17
13
|
- rvm: ruby-head
|
18
14
|
- rvm: jruby-head
|
15
|
+
- env: RAILS_VERSION=master
|
19
16
|
sudo: false
|
data/Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
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
|
data/Gemfile
CHANGED
@@ -6,10 +6,11 @@ gemspec
|
|
6
6
|
rails_version = ENV['RAILS_VERSION'] || 'default'
|
7
7
|
|
8
8
|
rails = case rails_version
|
9
|
+
|
9
10
|
when 'master'
|
10
11
|
{ github: 'rails/rails' }
|
11
12
|
when 'default'
|
12
|
-
'>=
|
13
|
+
'>= 5.0.0'
|
13
14
|
else
|
14
15
|
"~> #{rails_version}"
|
15
16
|
end
|
@@ -30,16 +31,9 @@ platforms :ruby_19, :jruby_19 do
|
|
30
31
|
gem "mime-types", "< 3.0"
|
31
32
|
end
|
32
33
|
|
33
|
-
platforms :rbx do
|
34
|
-
#gem 'psych'
|
35
|
-
#gem 'racc'
|
36
|
-
#gem 'rubinius-coverage'
|
37
|
-
#gem 'rubysl'
|
38
|
-
#gem 'rubysl-test-unit'
|
39
|
-
end
|
40
|
-
|
41
34
|
group :development do
|
42
35
|
gem 'bundler'
|
43
36
|
gem 'coveralls', :require => false
|
37
|
+
gem 'listen'
|
44
38
|
gem 'rake'
|
45
39
|
end
|
data/README.md
CHANGED
data/docker-compose.yml
ADDED
@@ -4,24 +4,27 @@ module ParanoiaUniquenessValidator
|
|
4
4
|
def validate_each(record, attribute, value)
|
5
5
|
finder_class = find_finder_class_for(record)
|
6
6
|
table = finder_class.arel_table
|
7
|
-
|
8
|
-
if ActiveRecord.version.to_s >= '4.2.0'
|
9
|
-
value = map_enum_attribute(finder_class, attribute, value)
|
10
|
-
else
|
11
|
-
value = deserialize_attribute(record, attribute, value)
|
12
|
-
end
|
7
|
+
value = map_enum_attribute(finder_class, attribute, value)
|
13
8
|
|
14
9
|
relation = build_relation(finder_class, table, attribute, value)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
if record.persisted?
|
11
|
+
if finder_class.primary_key
|
12
|
+
relation = relation.where.not(finder_class.primary_key => record.id_was || record.id)
|
13
|
+
else
|
14
|
+
raise UnknownPrimaryKey.new(finder_class, "Can not validate uniqueness for persisted record without primary key.")
|
15
|
+
end
|
16
|
+
end
|
21
17
|
relation = scope_relation(record, table, relation)
|
22
|
-
relation = finder_class.unscoped.where(relation)
|
23
18
|
relation = relation.merge(options[:conditions]) if options[:conditions]
|
24
19
|
|
20
|
+
if defined?('Paranoia') && Paranoia.respond_to?(:default_sentinel_value)
|
21
|
+
sentinel_value = Paranoia.default_sentinel_value
|
22
|
+
else
|
23
|
+
sentinel_value = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
relation = relation.where(deleted_at: sentinel_value)
|
27
|
+
|
25
28
|
if relation.exists?
|
26
29
|
error_options = options.except(:case_sensitive, :scope, :conditions)
|
27
30
|
error_options[:value] = value
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency "activerecord", ">=
|
20
|
+
gem.add_dependency "activerecord", ">= 5.0.0", "< 5.1"
|
21
21
|
|
22
22
|
gem.add_development_dependency "paranoia"
|
23
23
|
gem.add_development_dependency "database_cleaner"
|
data/spec/dummy/.gitignore
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# See
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
2
|
#
|
3
3
|
# If you find yourself ignoring temporary files generated by your text editor
|
4
4
|
# or operating system, you probably want to add a global ignore instead:
|
@@ -8,8 +8,14 @@
|
|
8
8
|
/.bundle
|
9
9
|
|
10
10
|
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
11
12
|
/db/*.sqlite3-journal
|
12
13
|
|
13
14
|
# Ignore all logfiles and tempfiles.
|
14
|
-
/log
|
15
|
-
/tmp
|
15
|
+
/log/*
|
16
|
+
/tmp/*
|
17
|
+
!/log/.keep
|
18
|
+
!/tmp/.keep
|
19
|
+
|
20
|
+
# Ignore Byebug command history file.
|
21
|
+
.byebug_history
|
data/spec/dummy/.rspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# README
|
2
2
|
|
3
3
|
This README would normally document whatever steps are necessary to get the
|
4
4
|
application up and running.
|
@@ -22,7 +22,3 @@ Things you may want to cover:
|
|
22
22
|
* Deployment instructions
|
23
23
|
|
24
24
|
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
2
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
3
|
|
4
|
-
|
4
|
+
require_relative 'config/application'
|
5
5
|
|
6
|
-
|
6
|
+
Rails.application.load_tasks
|
File without changes
|
@@ -2,13 +2,13 @@
|
|
2
2
|
// listed below.
|
3
3
|
//
|
4
4
|
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or vendor/assets/javascripts
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
6
|
//
|
7
7
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
9
|
//
|
10
|
-
//
|
11
|
-
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
12
|
//
|
13
13
|
//= require jquery
|
14
14
|
//= require jquery_ujs
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the rails generate channel command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
File without changes
|
@@ -3,11 +3,13 @@
|
|
3
3
|
* listed below.
|
4
4
|
*
|
5
5
|
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
7
|
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the
|
9
|
-
* compiled file
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
10
12
|
*
|
11
|
-
*= require_self
|
12
13
|
*= require_tree .
|
14
|
+
*= require_self
|
13
15
|
*/
|
@@ -1,14 +1,14 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
10
6
|
|
11
|
-
<%=
|
7
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
8
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
9
|
+
</head>
|
12
10
|
|
13
|
-
|
11
|
+
<body>
|
12
|
+
<%= yield %>
|
13
|
+
</body>
|
14
14
|
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/spec/dummy/bin/rails
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a starting point to setup your application.
|
15
|
+
# Add necessary setup steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
# puts "\n== Copying sample files =="
|
22
|
+
# unless File.exist?('config/database.yml')
|
23
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
24
|
+
# end
|
25
|
+
|
26
|
+
puts "\n== Preparing database =="
|
27
|
+
system! 'bin/rails db:setup'
|
28
|
+
|
29
|
+
puts "\n== Removing old logs and tempfiles =="
|
30
|
+
system! 'bin/rails log:clear tmp:clear'
|
31
|
+
|
32
|
+
puts "\n== Restarting application server =="
|
33
|
+
system! 'bin/rails restart'
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a way to update your development environment automatically.
|
15
|
+
# Add necessary update steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
puts "\n== Updating database =="
|
22
|
+
system! 'bin/rails db:migrate'
|
23
|
+
|
24
|
+
puts "\n== Removing old logs and tempfiles =="
|
25
|
+
system! 'bin/rails log:clear tmp:clear'
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system! 'bin/rails restart'
|
29
|
+
end
|