ActsAsList: add_to_list() auch aufrufen können, wenn 'position' noch gesetzt ist
[kivitendo-erp.git] / t / db_helper / acts_as_list.t
index 0d47bb2..2e7b708 100644 (file)
@@ -1,4 +1,4 @@
-use Test::More tests => 50;
+use Test::More tests => 51;
 use Test::Exception;
 
 use strict;
@@ -206,6 +206,10 @@ reset_state();
 $item = get_item(8); $item->remove_from_list; $item->parent_id(3); $item->add_to_list(position => 'first');
 test_positions "add_to_list position 'first' in empty", [ 1, undef, 1 ], [ 2, undef, 2 ], [ 3, 1, 1 ], [ 4, 1, 2 ], [ 5, 1, 3 ], [ 6, 4, 1 ], [ 7, 4, 2 ], [ 8, 3, 1 ];
 
+reset_state();
+$item = get_item(5); $item->add_to_list(position => 'after', reference => 3);
+test_positions "add_to_list without prior remove_from_list", [ 1, undef, 1 ], [ 2, undef, 2 ], [ 3, 1, 1 ], [ 5, 1, 2 ], [ 4, 1, 3 ], [ 6, 4, 1 ], [ 7, 4, 2 ], [ 8, 2, 1 ];
+
 reset_state();
 $item = get_item(4);
 is($item->get_next_in_list->id,                           5, 'Next of 4 is 5');