diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-18 12:43:52 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-18 12:43:52 +0100 |
commit | c3b33bfac3b15c869fc24aacc403e148b2079edc (patch) | |
tree | 320b3deb060e53d4c2b4bc71b1879b1d94c0eea8 | |
parent | f16b964144577f48513ecc291ae49b4f89897a30 (diff) |
rejig now that we can mark comments as anonymous
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 2 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 33 | ||||
-rw-r--r-- | templates/web/default/report/updates.html | 6 |
3 files changed, 34 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index f02b2cbe3..decda1b6c 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -159,6 +159,8 @@ sub load_problem_or_display_error : Private { { select => [ 'id', 'name', 'text', + 'user_id', + 'anonymous', 'mark_fixed', 'mark_open', 'photo', 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(); diff --git a/templates/web/default/report/updates.html b/templates/web/default/report/updates.html index 2bacbde1d..1a7254712 100644 --- a/templates/web/default/report/updates.html +++ b/templates/web/default/report/updates.html @@ -4,10 +4,10 @@ <h2 class="problem-update-list-header">[% loc('Updates') %]</h2> [% END %] <div><div class="problem-update"><p><a name="update_[% update.id %]"></a><em> - [% IF update.name %] - [% tprintf( loc( 'Posted by %s at %s' ), update.name, prettify_epoch( update.confirmed ) ) | html -%] - [%- ELSE %] + [% IF update.anonymous || update.name == '' %] [% tprintf( loc( 'Posted anonymously at %s' ), prettify_epoch( update.confirmed ) ) -%] + [%- ELSE %] + [% tprintf( loc( 'Posted by %s at %s' ), update.name, prettify_epoch( update.confirmed ) ) | html -%] [%- END -%] [%- # extra cobrand meta data -%] [%- ", " _ loc( 'marked as fixed' ) IF update.mark_fixed %] |