Skip to content

Commit

Permalink
remove extras
Browse files Browse the repository at this point in the history
  • Loading branch information
andyklimczak committed Sep 11, 2019
1 parent 760f3d9 commit 8fd4790
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions test/paranoia_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ def setup!
'active_column_models' => 'deleted_at DATETIME, active BOOLEAN',
'active_column_model_with_uniqueness_validations' => 'name VARCHAR(32), deleted_at DATETIME, active BOOLEAN',
'paranoid_model_with_belongs_to_active_column_model_with_has_many_relationships' => 'name VARCHAR(32), deleted_at DATETIME, active BOOLEAN, active_column_model_with_has_many_relationship_id INTEGER',
'active_column_model_with_has_many_relationships' => 'name VARCHAR(32), deleted_at DATETIME, active BOOLEAN',
'without_default_scope_models' => 'deleted_at DATETIME',
'paranoid_has_one_dependent_destroys' => 'deleted_at DATETIME',
'paranoid_belongs_to_dependent_destroys' => 'deleted_at DATETIME, paranoid_has_one_dependent_destroy_id INTEGER'
'active_column_model_with_has_many_relationships' => 'name VARCHAR(32), deleted_at DATETIME, active BOOLEAN',
'without_default_scope_models' => 'deleted_at DATETIME'
}.each do |table_name, columns_as_sql_string|
ActiveRecord::Base.connection.execute "CREATE TABLE #{table_name} (id INTEGER NOT NULL PRIMARY KEY, #{columns_as_sql_string})"
end
Expand Down Expand Up @@ -191,11 +189,11 @@ def test_scoping_behavior_for_paranoid_models
p2 = ParanoidModel.create(:parent_model => parent2)
p1.destroy
p2.destroy

assert_equal 0, parent1.paranoid_models.count
assert_equal 1, parent1.paranoid_models.only_deleted.count

assert_equal 2, ParanoidModel.only_deleted.joins(:parent_model).count
assert_equal 2, ParanoidModel.only_deleted.joins(:parent_model).count
assert_equal 1, parent1.paranoid_models.deleted.count
assert_equal 0, parent1.paranoid_models.without_deleted.count
p3 = ParanoidModel.create(:parent_model => parent1)
Expand All @@ -208,7 +206,7 @@ def test_only_deleted_with_joins
c1 = ActiveColumnModelWithHasManyRelationship.create(name: 'Jacky')
c2 = ActiveColumnModelWithHasManyRelationship.create(name: 'Thomas')
p1 = ParanoidModelWithBelongsToActiveColumnModelWithHasManyRelationship.create(name: 'Hello', active_column_model_with_has_many_relationship: c1)

c1.destroy
assert_equal 1, ActiveColumnModelWithHasManyRelationship.count
assert_equal 1, ActiveColumnModelWithHasManyRelationship.only_deleted.count
Expand Down Expand Up @@ -1055,18 +1053,6 @@ def test_counter_cache_column_on_restore
related_model.restore
assert_equal 1, parent_model_with_counter_cache_column.reload.related_models_count
end

def test_circular_dependent_destroy_has_one_belongs_to
has_one_dependent_destroy = ParanoidHasOneDependentDestroy.create
belongs_to_dependent_destroy = ParanoidBelongsToDependentDestroy.create
belongs_to_dependent_destroy.paranoid_has_one_dependent_destroy = has_one_dependent_destroy
belongs_to_dependent_destroy.save!

belongs_to_dependent_destroy.destroy

refute has_one_dependent_destroy.reload.deleted_at.nil?
refute belongs_to_dependent_destroy.reload.deleted_at.nil?
end
end

private
Expand Down Expand Up @@ -1370,16 +1356,6 @@ class PolymorphicModel < ActiveRecord::Base
belongs_to :parent, polymorphic: true
end

class ParanoidHasOneDependentDestroy < ActiveRecord::Base
acts_as_paranoid
has_one :paranoid_belongs_to_dependent_destroy, dependent: :destroy
end

class ParanoidBelongsToDependentDestroy < ActiveRecord::Base
acts_as_paranoid
belongs_to :paranoid_has_one_dependent_destroy, dependent: :destroy
end

module Namespaced
def self.table_name_prefix
"namespaced_"
Expand Down

0 comments on commit 8fd4790

Please sign in to comment.