Line # Revision Author
1 23 dpavlin #!/usr/bin/env perl
2 use warnings;
3 use strict;
4
5 =head1 DESCRIPTION
6
7 A (very) basic test harness for the ToggleEdit action.
8
9 =cut
10
11 34 dpavlin use Jifty::Test tests => 20;
12 23 dpavlin use Data::Dump qw/dump/;
13
14 # Make sure we can load the action
15 use_ok('Arh::Action::ToggleEdit');
16
17
18 ok( my $web = Jifty::Test->web, 'web' );
19
20 ok( $web->current_user->user_object->load_by_cols( email => 'admin@example.com' ), 'admin' );
21
22 34 dpavlin ok( $web->current_user->editing, 'edit on' );
23 23 dpavlin
24 sub run_action {
25
26 ok(my $a = $web->new_action(
27 class => 'ToggleEdit',
28 ), 'new_action ToggleEdit');
29
30 ok( $a->run, 'run' );
31
32 34 dpavlin ok( my $message = $a->result->message, 'message' );
33 diag dump($message);
34
35 if ( $message =~ m/off/ ) {
36 ok( ! $web->current_user->editing, 'edit off' );
37 } else {
38 ok( $web->current_user->editing, 'edit on' );
39 }
40
41 23 dpavlin }
42
43 34 dpavlin run_action foreach ( 1 .. 4 );
44 23 dpavlin