Skip to content

Commit

Permalink
Merge d06e45f into f89cc6f
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Smith committed Apr 12, 2018
2 parents f89cc6f + d06e45f commit 5867d4b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 43 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
language: ruby
rvm:
- 2.2.5
- 2.3.0
- 2.4.0
- jruby-9.1.5.0
- 2.2.9
- 2.3.7
- 2.4.4
- 2.5.1
- ruby-head
- jruby-head
env:
- "RAILS_VERSION=master"
- "RAILS_VERSION=5.1.0"
- "RAILS_VERSION=5.2.0"
matrix:
allow_failures:
- rvm: jruby-9.1.5.0
- rvm: ruby-head
- rvm: jruby-head
- env: RAILS_VERSION=master
sudo: false
32 changes: 12 additions & 20 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,23 @@ gemspec

rails_version = ENV['RAILS_VERSION'] || 'default'

rails = case rails_version

when 'master'
{ github: 'rails/rails' }
when 'default'
'>= 5.1.0'
else
"~> #{rails_version}"
end
rails =
case rails_version
when 'master'
{ github: 'rails/rails' }
when 'default'
'>= 5.2.0'
else
"~> #{rails_version}"
end

gem 'rails', rails

platforms :jruby do
gem "activerecord-jdbcsqlite3-adapter", github: "jruby/activerecord-jdbc-adapter", branch: "rails-5"
gem "jruby-openssl"
end

platforms :ruby do
gem "sqlite3"
gem "test-unit"
end

group :development do
gem 'bundler'
gem 'coveralls', :require => false
gem 'coveralls', require: false
gem 'listen'
gem 'rake'
gem "sqlite3"
gem "test-unit"
end
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# ParanoiaUniquenessValidator

Adds validator validates_uniqueness_without_deleted.
Adds `validates_uniqueness_without_deleted`.

This validator will ignore any record that has a non-null value for the deleted_at field. This gem was made specifically for use with the [Paranoia](https://github.com/radar/paranoia) gem but it can be used with any gem that uses the deleted_at field for marking records as deleted.
This validator will ignore any record that has a non-null value for the
`deleted_at` field. This gem was made specifically for use with the
[Paranoia](https://github.com/radar/paranoia) gem but it can be used with any
gem that uses the `deleted_at` field for marking records as deleted.

[![Gem Version](https://badge.fury.io/rb/paranoia_uniqueness_validator.png)](http://badge.fury.io/rb/paranoia_uniqueness_validator) [![Build Status](https://secure.travis-ci.org/anthonator/paranoia_uniqueness_validator.png)](http://travis-ci.org/anthonator/paranoia_uniqueness_validator) [![Dependency Status](https://gemnasium.com/anthonator/paranoia_uniqueness_validator.png)](https://gemnasium.com/anthonator/paranoia_uniqueness_validator) [![Coverage Status](https://coveralls.io/repos/anthonator/paranoia_uniqueness_validator/badge.png)](https://coveralls.io/r/anthonator/paranoia_uniqueness_validator) [![Code Climate](https://codeclimate.com/github/anthonator/paranoia_uniqueness_validator.png)](https://codeclimate.com/github/anthonator/paranoia_uniqueness_validator)

Expand All @@ -19,8 +22,8 @@ Add this line to your application's Gemfile:
# Rails 5.0
gem 'paranoia_uniqueness_validator', '2.0.0'

# Rails 5.1
gem 'paranoia_uniqueness_validator', '3.0.0'
# Rails 5.1+
gem 'paranoia_uniqueness_validator', '3.1.0'

And then execute:

Expand All @@ -32,13 +35,14 @@ Or install it yourself as:

## Configuration

This validator supports all configuration options used by the base ActiveRecord uniqueness validator. For more information check out the [Rails API documentation](http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_uniqueness_of).
This validator supports all configuration options used by the base ActiveRecord
uniqueness validator. For more information check out the [Rails API documentation](http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_uniqueness_of).

## Usage

```ruby
class SomeModel < ActiveRecord::Base
validates :some_field, :uniqueness_without_deleted => true
validates :some_field, uniqueness_without_deleted: true
end
```

Expand All @@ -52,8 +56,6 @@ end

## Credits

[![Sticksnleaves](http://sticksnleaves-wordpress.herokuapp.com/wp-content/themes/sticksnleaves/images/snl-logo-116x116.png)](http://www.sticksnleaves.com)

paranoia_uniqueness_validator is maintained and funded by [Sticksnleaves](http://www.sticksnleaves.com)
`paranoia_uniqueness_validator` is maintained and funded by [Sticksnleaves](http://www.sticksnleaves.com)

Thanks to all of our [contributors](https://github.com/anthonator/paranoia_uniqueness_validator/graphs/contributors)
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '2'
services:
lib:
command: rspec
image: sticksnleaves/ruby-project:2.4
image: sticksnleaves/ruby-project:2.5
volumes:
- .:/usr/src/app
- lib.volume:/usr/local/bundle
Expand Down
2 changes: 1 addition & 1 deletion lib/paranoia_uniqueness_validator/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ParanoiaUniquenessValidator
VERSION = "3.0.0"
VERSION = "3.1.0"
end
2 changes: 1 addition & 1 deletion paranoia_uniqueness_validator.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]

gem.add_dependency "activerecord", ">= 5.1.0", "< 5.2"
gem.add_dependency "activerecord", ">= 5.1.0", "< 6.0"

gem.add_development_dependency "paranoia", "~> 2.3"
gem.add_development_dependency "database_cleaner", "~> 1.6"
Expand Down
4 changes: 0 additions & 4 deletions spec/validations/uniqueness_without_deleted_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

expect(DummyModel.new(:unique_field => "unique")).to be_valid
end

end

context 'with datetime (non nil) default_sentinel_value' do

before(:all) do
if Paranoia.respond_to?(:default_sentinel_value)
Paranoia.default_sentinel_value = DateTime.new(0)
Expand All @@ -42,7 +40,5 @@
dummy_model = DummyNonNilModel.new(:unique_field => "unique")
expect(dummy_model).to be_valid
end

end

end

0 comments on commit 5867d4b

Please sign in to comment.