acts_as_paranoid 0.6.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +126 -10
- data/CONTRIBUTING.md +59 -0
- data/README.md +151 -57
- data/lib/acts_as_paranoid.rb +29 -29
- data/lib/acts_as_paranoid/associations.rb +21 -17
- data/lib/acts_as_paranoid/core.rb +151 -95
- data/lib/acts_as_paranoid/relation.rb +9 -0
- data/lib/acts_as_paranoid/validations.rb +8 -74
- data/lib/acts_as_paranoid/version.rb +3 -1
- data/test/test_associations.rb +118 -46
- data/test/test_core.rb +264 -66
- data/test/test_default_scopes.rb +20 -7
- data/test/test_dependent_recovery.rb +54 -0
- data/test/test_deprecated_behavior.rb +30 -0
- data/test/test_helper.rb +130 -95
- data/test/test_inheritance.rb +3 -1
- data/test/test_relations.rb +98 -16
- data/test/test_table_namespace.rb +40 -0
- data/test/test_validations.rb +27 -7
- metadata +78 -32
- data/lib/acts_as_paranoid/preloader_association.rb +0 -16
- data/test/test_preloader_association.rb +0 -27
@@ -1,16 +0,0 @@
|
|
1
|
-
module ActsAsParanoid
|
2
|
-
module PreloaderAssociation
|
3
|
-
def self.included(base)
|
4
|
-
base.class_eval do
|
5
|
-
def build_scope_with_deleted
|
6
|
-
scope = build_scope_without_deleted
|
7
|
-
scope = scope.with_deleted if reflection.options[:with_deleted] && klass.respond_to?(:with_deleted)
|
8
|
-
scope
|
9
|
-
end
|
10
|
-
|
11
|
-
alias_method :build_scope_without_deleted, :build_scope
|
12
|
-
alias_method :build_scope, :build_scope_with_deleted
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class PreloaderAssociationTest < ParanoidBaseTest
|
4
|
-
def test_includes_with_deleted
|
5
|
-
paranoid_time = ParanoidTime.first
|
6
|
-
paranoid_has_many_dependant = paranoid_time.paranoid_has_many_dependants.create(:name => 'dependant!')
|
7
|
-
|
8
|
-
paranoid_time.destroy
|
9
|
-
|
10
|
-
ParanoidHasManyDependant.with_deleted.includes(:paranoid_time_with_deleted).each do |hasmany|
|
11
|
-
assert_not_nil hasmany.paranoid_time_with_deleted
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_includes_with_deleted_with_polymorphic_parent
|
16
|
-
not_paranoid_parent = NotParanoidHasManyAsParent.create(name: 'not paranoid parent')
|
17
|
-
paranoid_parent = ParanoidHasManyAsParent.create(name: 'paranoid parent')
|
18
|
-
ParanoidBelongsToPolymorphic.create(:name => 'belongs_to', :parent => not_paranoid_parent)
|
19
|
-
ParanoidBelongsToPolymorphic.create(:name => 'belongs_to', :parent => paranoid_parent)
|
20
|
-
|
21
|
-
paranoid_parent.destroy
|
22
|
-
|
23
|
-
ParanoidBelongsToPolymorphic.with_deleted.includes(:parent).each do |hasmany|
|
24
|
-
assert_not_nil hasmany.parent
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|