From 2f2c53c2e755ce02e552e9e0c9218ab28dd3da5e Mon Sep 17 00:00:00 2001 From: Juan Hoyos Date: Mon, 3 Sep 2012 16:43:29 -0500 Subject: [PATCH] Failing tests when moving to a node with uninitialized sort_order Harder failing tests when moving to a node with uninitialized sort_order --- spec/fixtures/labels.yml | 4 ++++ spec/label_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/spec/fixtures/labels.yml b/spec/fixtures/labels.yml index 4abd888b..ed570c22 100644 --- a/spec/fixtures/labels.yml +++ b/spec/fixtures/labels.yml @@ -48,4 +48,8 @@ e2: parent: d2 sort_order: 1 +f3: + name: f3 +f4: + name: f4 diff --git a/spec/label_spec.rb b/spec/label_spec.rb index 3799b182..0b236413 100644 --- a/spec/label_spec.rb +++ b/spec/label_spec.rb @@ -130,6 +130,26 @@ def nuke_db labels(:c2).self_and_siblings.to_a.should == [labels(:b1), labels(:c2), labels(:b2)] end + it "should move a node before another node which has an uninitialized sort_order" do + labels(:f3).ancestry_path.should == %w{f3} + labels(:e2).children << labels(:f3) + labels(:f3).reload.ancestry_path.should == %w{a1 b2 c2 d2 e2 f3} + labels(:f3).self_and_siblings.to_a.should == [labels(:f3)] + labels(:f3).prepend_sibling labels(:f4) + labels(:f3).siblings_before.to_a.should == [labels(:f4)] + labels(:f3).self_and_siblings.to_a.should == [labels(:f4), labels(:f3)] + end + + it "should move a node after another node which has an uninitialized sort_order" do + labels(:f3).ancestry_path.should == %w{f3} + labels(:e2).children << labels(:f3) + labels(:f3).reload.ancestry_path.should == %w{a1 b2 c2 d2 e2 f3} + labels(:f3).self_and_siblings.to_a.should == [labels(:f3)] + labels(:f3).append_sibling labels(:f4) + labels(:f3).siblings_after.to_a.should == [labels(:f4)] + labels(:f3).self_and_siblings.to_a.should == [labels(:f3), labels(:f4)] + end + it "should move a node after another node" do labels(:c2).ancestry_path.should == %w{a1 b2 c2} labels(:b2).append_sibling(labels(:c2), false)