10 |
|
|
11 |
use Jifty::Test tests => 11; |
use Jifty::Test tests => 11; |
12 |
|
|
13 |
|
my $nr = 3; |
14 |
|
|
15 |
# Make sure we can load the model |
# Make sure we can load the model |
16 |
use_ok('Transports::Model::Destination'); |
use_ok('Transports::Model::Destination'); |
17 |
|
|
21 |
|
|
22 |
# Try testing a create |
# Try testing a create |
23 |
my $o = Transports::Model::Destination->new(current_user => $system_user); |
my $o = Transports::Model::Destination->new(current_user => $system_user); |
24 |
my ($id) = $o->create( name => 'dest1' ); |
my ($id) = $o->create( |
25 |
|
name => 'dest1', |
26 |
|
landscape => 1, |
27 |
|
); |
28 |
ok($id, "Destination create returned success"); |
ok($id, "Destination create returned success"); |
29 |
ok($o->id, "New Destination has valid id set"); |
ok($o->id, "New Destination has valid id set"); |
30 |
is($o->id, $id, "Create returned the right id"); |
is($o->id, $id, "Create returned the right id"); |
31 |
|
|
32 |
# And another |
# And another |
33 |
$o->create( name => 'dest2' ); |
$o->create( |
34 |
|
name => 'dest2', |
35 |
|
landscape => 2, |
36 |
|
); |
37 |
ok($o->id, "Destination create returned another value"); |
ok($o->id, "Destination create returned another value"); |
38 |
isnt($o->id, $id, "And it is different from the previous one"); |
isnt($o->id, $id, "And it is different from the previous one"); |
39 |
|
|
40 |
# Searches in general |
# Searches in general |
41 |
my $collection = Transports::Model::DestinationCollection->new(current_user => $system_user); |
my $collection = Transports::Model::DestinationCollection->new(current_user => $system_user); |
42 |
$collection->unlimit; |
$collection->unlimit; |
43 |
is($collection->count, 2, "Finds two records"); |
is($collection->count, $nr + 2, "Finds two records"); |
44 |
|
|
45 |
# Searches in specific |
# Searches in specific |
46 |
$collection->limit(column => 'id', value => $o->id); |
$collection->limit(column => 'id', value => $o->id); |
53 |
|
|
54 |
# And the other one is still there |
# And the other one is still there |
55 |
$collection->unlimit; |
$collection->unlimit; |
56 |
is($collection->count, 1, "Still one left"); |
is($collection->count, $nr + 1, "Still one left"); |
57 |
|
|