From 571884e093411635d32f5edf2f0d683ce8c3b300 Mon Sep 17 00:00:00 2001 From: Lukas Eklund Date: Mon, 7 Dec 2015 22:10:53 +0000 Subject: [PATCH] remove uniqueness validator from this upstream PR for rails 4 https://github.com/rubysherpas/paranoia/pull/277/files and this issue: https://github.com/rubysherpas/paranoia/issues/276 --- lib/paranoia.rb | 13 ------------- test/paranoia_test.rb | 8 +------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/lib/paranoia.rb b/lib/paranoia.rb index e84ae18d..e75e5fa2 100644 --- a/lib/paranoia.rb +++ b/lib/paranoia.rb @@ -174,16 +174,3 @@ def paranoia_column require 'paranoia/rspec' if defined? RSpec - -module ActiveRecord - module Validations - class UniquenessValidator < ActiveModel::EachValidator - protected - def build_relation_with_paranoia(klass, table, attribute, value) - relation = build_relation_without_paranoia(klass, table, attribute, value) - relation.and(klass.arel_table[klass.paranoia_column].eq(nil)) - end - alias_method_chain :build_relation, :paranoia - end - end -end diff --git a/test/paranoia_test.rb b/test/paranoia_test.rb index 9ed05107..450dcdbd 100644 --- a/test/paranoia_test.rb +++ b/test/paranoia_test.rb @@ -435,16 +435,10 @@ def test_observers_not_notified_if_not_supported # essentially, we're just ensuring that this doesn't crash end - def test_validates_uniqueness_only_checks_non_deleted_records + def test_validates_uniqueness_checks_all_records a = Employer.create!(name: "A") a.destroy b = Employer.new(name: "A") - assert b.valid? - end - - def test_validates_uniqueness_still_works_on_non_deleted_records - a = Employer.create!(name: "A") - b = Employer.new(name: "A") refute b.valid? end