6 my $artists = $schema->resultset("Artist");
9 $artists->create({ artistid=>1, name=>"Joe" });
10 $artists->create({ artistid=>2, name=>"Bob" });
11 $artists->create({ artistid=>3, name=>"Ted" });
12 $artists->create({ artistid=>4, name=>"Ned" });
13 $artists->create({ artistid=>5, name=>"Don" });
15 $artists = $artists->search(undef,{order_by=>'position'});
19 check_positions($schema);
23 foreach my $position (1..5) {
25 $artist = $artists->find({ position=>$position });
26 $artist->move_previous();
27 check_positions($schema);
29 $artist = $artists->find({ position=>$position });
31 check_positions($schema);
33 $artist = $artists->find({ position=>$position });
34 $artist->move_first();
35 check_positions($schema);
37 $artist = $artists->find({ position=>$position });
39 check_positions($schema);
41 foreach my $to_position (1..5) {
43 $artist = $artists->find({ position=>$position });
44 $artist->move_to($to_position);
45 check_positions($schema);
55 my $artists = $schema->resultset("Artist")->search(undef,{order_by=>'position'});
56 my $expected_position = 0;
57 while (my $artist = $artists->next()) {
58 $expected_position ++;
59 ok( ($artist->position()==$expected_position), 'default positions set as expected' );