Commit | Line | Data |
375c84bb |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use Test::Exception; |
6 | use lib qw(t/lib); |
7 | use DBICTest; |
8 | |
9 | my $schema = DBICTest->init_schema(); |
10 | |
11 | my $cd = $schema->resultset('CD')->next; |
37b9b05b |
12 | $cd->tracks->delete; |
375c84bb |
13 | |
37b9b05b |
14 | $schema->resultset('CD')->related_resultset('tracks')->delete; |
375c84bb |
15 | |
37b9b05b |
16 | is $cd->tracks->count, 0, 'No tracks'; |
375c84bb |
17 | |
37b9b05b |
18 | $cd->create_related('tracks', { title => "t_$_", position => $_ }) |
19 | for (4,2,3,1,5); |
20 | |
21 | is $cd->tracks->count, 5, 'Created 5 tracks'; |
22 | |
23 | # a txn should force the implicit pos reload, regardless of order |
24 | $schema->txn_do(sub { |
25 | $cd->tracks->delete_all |
26 | }); |
27 | |
28 | is $cd->tracks->count, 0, 'Successfully deleted everything'; |
375c84bb |
29 | |
30 | done_testing; |