diff options
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Rss.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/AlertType.pm | 5 | ||||
-rw-r--r-- | t/app/controller/alert_new.t | 17 |
3 files changed, 21 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm index db4955f06..78793d9c1 100755 --- a/perllib/FixMyStreet/App/Controller/Rss.pm +++ b/perllib/FixMyStreet/App/Controller/Rss.pm @@ -217,7 +217,7 @@ sub add_row : Private { my ( $self, $c, $row ) = @_; my $alert_type = $c->stash->{alert_type}; - $row->{name} ||= 'anonymous'; + $row->{name} = 'anonymous' if $row->{anonymous} || !$row->{name}; my $pubDate; if ($row->{confirmed}) { diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm index e92846aca..46009cb85 100644 --- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm +++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm @@ -27,7 +27,8 @@ sub email_alerts ($) { alert.cobrand_data as alert_cobrand_data, alert.parameter as alert_parameter, alert.parameter2 as alert_parameter2, '; if ($head_table) { $query .= " - $item_table.id as item_id, $item_table.name as item_name, $item_table.text as item_text, + $item_table.id as item_id, $item_table.text as item_text, + $item_table.name as item_name, $item_table.anonymous as item_anonymous, $head_table.* from alert inner join $item_table on alert.parameter::integer = $item_table.${head_table}_id @@ -81,7 +82,7 @@ sub email_alerts ($) { my $url = $cobrand->base_url_for_emails( $row->{alert_cobrand_data} ); if ($row->{item_text}) { $data{problem_url} = $url . "/report/" . $row->{id}; - $data{data} .= $row->{item_name} . ' : ' if $row->{item_name}; + $data{data} .= $row->{item_name} . ' : ' if $row->{item_name} && !$row->{item_anonymous}; $data{data} .= $row->{item_text} . "\n\n------\n\n"; } else { $data{data} .= $url . "/report/" . $row->{id} . " - $row->{title}\n\n"; diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t index cb3b4b656..580a5ad9a 100644 --- a/t/app/controller/alert_new.t +++ b/t/app/controller/alert_new.t @@ -431,6 +431,19 @@ subtest "Test normal alert signups and that alerts are sent" => sub { my $update_id = $update->id; ok $update, "created test update - $update_id"; + $update = FixMyStreet::App->model('DB::Comment')->create( { + problem_id => $report_id, + user_id => $user2->id, + name => 'Anonymous User', + mark_fixed => 'false', + text => 'This is some more update text', + state => 'confirmed', + confirmed => $dt->clone->add( hours => 8 ), + anonymous => 't', + } ); + $update_id = $update->id; + ok $update, "created test update - $update_id"; + FixMyStreet::App->model('DB::AlertType')->email_alerts(); $mech->email_count_is(3); my @emails = $mech->get_email; @@ -442,6 +455,10 @@ subtest "Test normal alert signups and that alerts are sent" => sub { } is $count, 3, 'Three emails with the right things in them'; + my $email = $emails[0]; + like $email->body, qr/Other User/, 'Update name given'; + unlike $email->body, qr/Anonymous User/, 'Update name not given'; + my ( $url, $url_token ) = $emails[0]->body =~ m{http://\S+(/A/(\S+))}; $mech->get_ok( $url ); $mech->content_contains('successfully deleted'); |