Skip to content

Commit

Permalink
Removed white spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan Yakhyaev committed Sep 2, 2013
1 parent ede3e3b commit 07e6201
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions test/has_ancestry_test.rb
@@ -1,7 +1,6 @@
require "environment" require "environment"


class HasAncestryTreeTest < ActiveSupport::TestCase class HasAncestryTreeTest < ActiveSupport::TestCase

def test_default_ancestry_column def test_default_ancestry_column
AncestryTestDatabase.with_model do |model| AncestryTestDatabase.with_model do |model|
assert_equal :ancestry, model.ancestry_column assert_equal :ancestry, model.ancestry_column
Expand Down Expand Up @@ -306,7 +305,7 @@ def test_orphan_restrict_strategy
end end
end end
end end

def test_orphan_adopt_strategy def test_orphan_adopt_strategy
AncestryTestDatabase.with_model do |model| AncestryTestDatabase.with_model do |model|
model.orphan_strategy = :adopt # set the orphan strategy as paerntify model.orphan_strategy = :adopt # set the orphan strategy as paerntify
Expand Down Expand Up @@ -713,20 +712,20 @@ def test_arrange_order_option
end end
end end
end end

def test_sort_by_ancestry def test_sort_by_ancestry
AncestryTestDatabase.with_model do |model| AncestryTestDatabase.with_model do |model|
n1 = model.create! n1 = model.create!
n2 = model.create!(:parent => n1) n2 = model.create!(:parent => n1)
n3 = model.create!(:parent => n2) n3 = model.create!(:parent => n2)
n4 = model.create!(:parent => n2) n4 = model.create!(:parent => n2)
n5 = model.create!(:parent => n1) n5 = model.create!(:parent => n1)

arranged = model.sort_by_ancestry(model.all.sort_by(&:id).reverse) arranged = model.sort_by_ancestry(model.all.sort_by(&:id).reverse)
assert_equal [n1, n2, n4, n3, n5].map(&:id), arranged.map(&:id) assert_equal [n1, n2, n4, n3, n5].map(&:id), arranged.map(&:id)
end end
end end

def test_node_excluded_by_default_scope_should_still_move_with_parent def test_node_excluded_by_default_scope_should_still_move_with_parent
AncestryTestDatabase.with_model( AncestryTestDatabase.with_model(
:width => 3, :depth => 3, :extra_columns => {:deleted_at => :datetime}, :width => 3, :depth => 3, :extra_columns => {:deleted_at => :datetime},
Expand All @@ -737,7 +736,7 @@ def test_node_excluded_by_default_scope_should_still_move_with_parent
new_grandparent = roots[1] new_grandparent = roots[1]
parent = grandparent.children.first parent = grandparent.children.first
child = parent.children.first child = parent.children.first

child.update_attributes :deleted_at => Time.now child.update_attributes :deleted_at => Time.now
parent.update_attributes :parent => new_grandparent parent.update_attributes :parent => new_grandparent
child.update_attributes :deleted_at => nil child.update_attributes :deleted_at => nil
Expand All @@ -754,11 +753,11 @@ def test_node_excluded_by_default_scope_should_be_destroyed_with_parent
) do |model, roots| ) do |model, roots|
parent = model.roots.first parent = model.roots.first
child = parent.children.first child = parent.children.first

child.update_attributes :deleted_at => Time.now child.update_attributes :deleted_at => Time.now
parent.destroy parent.destroy
child.update_attributes :deleted_at => nil child.update_attributes :deleted_at => nil

assert model.count.zero? assert model.count.zero?
end end
end end
Expand All @@ -771,11 +770,11 @@ def test_node_excluded_by_default_scope_should_be_rootified
) do |model, roots| ) do |model, roots|
parent = model.roots.first parent = model.roots.first
child = parent.children.first child = parent.children.first

child.update_attributes :deleted_at => Time.now child.update_attributes :deleted_at => Time.now
parent.destroy parent.destroy
child.update_attributes :deleted_at => nil child.update_attributes :deleted_at => nil

assert child.reload.is_root? assert child.reload.is_root?
end end
end end
Expand Down Expand Up @@ -805,7 +804,7 @@ def test_sort_by_ancestry_with_block
n4 = model.create!(:rank => 0, :parent => n2) n4 = model.create!(:rank => 0, :parent => n2)
n5 = model.create!(:rank => 1, :parent => n1) n5 = model.create!(:rank => 1, :parent => n1)
n6 = model.create!(:rank => 1, :parent => n2) n6 = model.create!(:rank => 1, :parent => n2)

arranged = model.sort_by_ancestry(model.all.sort_by(&:rank).reverse) {|a, b| a.rank <=> b.rank} arranged = model.sort_by_ancestry(model.all.sort_by(&:rank).reverse) {|a, b| a.rank <=> b.rank}
assert_equal [n1, n3, n5, n2, n4, n6].map(&:id), arranged.map(&:id) assert_equal [n1, n3, n5, n2, n4, n6].map(&:id), arranged.map(&:id)
end end
Expand Down

0 comments on commit 07e6201

Please sign in to comment.