diff .svn/pristine/64/6405eab4a4b9b92dcff2e2c358f9c728d763c20e.svn-base @ 927:9ee5fd0b9bd3

Merge from cannam_integration
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Fri, 11 May 2012 16:13:59 +0100
parents cbb26bc654de
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.svn/pristine/64/6405eab4a4b9b92dcff2e2c358f9c728d763c20e.svn-base	Fri May 11 16:13:59 2012 +0100
@@ -0,0 +1,41 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+module CollectiveIdea
+  module Acts #:nodoc:
+    module NestedSet #:nodoc:
+      class AwesomeNestedSetTest < Test::Unit::TestCase
+        include Helper
+        fixtures :categories
+        
+        def test_nested_set_options
+          expected = [
+            [" Top Level", 1],
+            ["- Child 1", 2],
+            ['- Child 2', 3],
+            ['-- Child 2.1', 4],
+            ['- Child 3', 5],
+            [" Top Level 2", 6]
+          ]
+          actual = nested_set_options(Category) do |c|
+            "#{'-' * c.level} #{c.name}"
+          end
+          assert_equal expected, actual
+        end
+        
+        def test_nested_set_options_with_mover
+          expected = [
+            [" Top Level", 1],
+            ["- Child 1", 2],
+            ['- Child 3', 5],
+            [" Top Level 2", 6]
+          ]
+          actual = nested_set_options(Category, categories(:child_2)) do |c|
+            "#{'-' * c.level} #{c.name}"
+          end
+          assert_equal expected, actual
+        end
+        
+      end
+    end
+  end
+end
\ No newline at end of file