diff options
Diffstat (limited to 't/app/controller/report_updates.t')
-rw-r--r-- | t/app/controller/report_updates.t | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 466fa71c1..13908fbff 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -10,12 +10,19 @@ use DateTime; my $mech = FixMyStreet::TestMech->new; # create a test user and report +$mech->delete_user('commenter@example.com'); $mech->delete_user('test@example.com'); + my $user = FixMyStreet::App->model('DB::User') ->find_or_create( { email => 'test@example.com', name => 'Test User' } ); ok $user, "created test user"; +my $user2 = + FixMyStreet::App->model('DB::User') + ->find_or_create( { email => 'commenter@example.com', name => 'Commenter' } ); +ok $user2, "created comment user"; + my $dt = DateTime->new( year => 2011, month => 04, @@ -54,10 +61,10 @@ ok $report, "created test report - $report_id"; my $comment = FixMyStreet::App->model('DB::Comment')->find_or_create( { problem_id => $report_id, + user_id => $user2->id, name => 'Other User', mark_fixed => 'false', text => 'This is some update text', - email => 'commenter@example.com', state => 'confirmed', confirmed => $dt->ymd . ' ' . $dt->hms, } @@ -68,36 +75,53 @@ ok $comment, "created test update - $comment_id"; for my $test ( { + description => 'named user, anon is false', name => 'Other User', + anonymous => 'f', mark_fixed => 'false', mark_open => 'false', meta => 'Posted by Other User at 15:47, Saturday 16 April 2011', }, { + description => 'blank user, anon is false', name => '', + anonymous => 'f', mark_fixed => 'false', mark_open => 'false', meta => 'Posted anonymously at 15:47, Saturday 16 April 2011', }, { - name => '', + description => 'named user, anon is true', + name => 'Other User', + anonymous => 't', + mark_fixed => 'false', + mark_open => 'false', + meta => 'Posted anonymously at 15:47, Saturday 16 April 2011', + }, + { + description => 'named user, anon is true, fixed', + name => 'Other User', + anonymous => 't', mark_fixed => 'true', mark_open => 'false', meta => 'Posted anonymously at 15:47, Saturday 16 April 2011, marked as fixed', }, { - name => '', + description => 'named user, anon is true, reopened', + name => 'Other User', + anonymous => 't', mark_fixed => 'false', mark_open => 'true', meta => 'Posted anonymously at 15:47, Saturday 16 April 2011, reopened', } ) { - subtest "test update displayed" => sub { + subtest "test update displayed for $test->{description}" => sub { $comment->name( $test->{name} ); $comment->mark_fixed( $test->{mark_fixed} ); $comment->mark_open( $test->{mark_open} ); + $comment->anonymous( $test->{anonymous} ); $comment->update; $mech->get_ok("/report/$report_id"); @@ -111,5 +135,6 @@ for my $test ( } ok $comment->delete, 'deleted comment'; +$mech->delete_user('commenter@example.com'); $mech->delete_user('test@example.com'); done_testing(); |