10 |
|
|
11 |
use Jifty::Test tests => 11; |
use Jifty::Test tests => 11; |
12 |
|
|
13 |
|
my $nr = 4; |
14 |
|
|
15 |
# Make sure we can load the model |
# Make sure we can load the model |
16 |
use_ok('Transports::Model::ReturnCode'); |
use_ok('Transports::Model::ReturnCode'); |
17 |
|
|
21 |
|
|
22 |
# Try testing a create |
# Try testing a create |
23 |
my $o = Transports::Model::ReturnCode->new(current_user => $system_user); |
my $o = Transports::Model::ReturnCode->new(current_user => $system_user); |
24 |
my ($id) = $o->create(); |
my ($id) = $o->create( name => 'foo' ); |
25 |
ok($id, "ReturnCode create returned success"); |
ok($id, "ReturnCode create returned success"); |
26 |
ok($o->id, "New ReturnCode has valid id set"); |
ok($o->id, "New ReturnCode has valid id set"); |
27 |
is($o->id, $id, "Create returned the right id"); |
is($o->id, $id, "Create returned the right id"); |
28 |
|
|
29 |
# And another |
# And another |
30 |
$o->create(); |
$o->create( name => 'bar' ); |
31 |
ok($o->id, "ReturnCode create returned another value"); |
ok($o->id, "ReturnCode create returned another value"); |
32 |
isnt($o->id, $id, "And it is different from the previous one"); |
isnt($o->id, $id, "And it is different from the previous one"); |
33 |
|
|
34 |
# Searches in general |
# Searches in general |
35 |
my $collection = Transports::Model::ReturnCodeCollection->new(current_user => $system_user); |
my $collection = Transports::Model::ReturnCodeCollection->new(current_user => $system_user); |
36 |
$collection->unlimit; |
$collection->unlimit; |
37 |
is($collection->count, 2, "Finds two records"); |
is($collection->count, $nr + 2, "Finds two records"); |
38 |
|
|
39 |
# Searches in specific |
# Searches in specific |
40 |
$collection->limit(column => 'id', value => $o->id); |
$collection->limit(column => 'id', value => $o->id); |
47 |
|
|
48 |
# And the other one is still there |
# And the other one is still there |
49 |
$collection->unlimit; |
$collection->unlimit; |
50 |
is($collection->count, 1, "Still one left"); |
is($collection->count, $nr + 1, "Still one left"); |
51 |
|
|