Bug#670568: debbugs: mark up 'Added indication that bug 2 blocks 10'

Arnout Engelen <[email protected]>
Newsgroups gmane.linux.debian.devel.debbugs
Message-ID <20120426194429.GN2822__26450.4805476919$1335469697$gmane$org@bzzt.net>
Package: debbugs
Version: 2.4.2~exp2
Severity: normal
Tags: patch

Hi,

Texts of the format:

  Removed blocking bug(s) of 10: 2

already got converted to:

  Removed blocking bug(s) of <a href="bugreport.cgi?bug=10">10</a>: <a href="bugreport.cgi?bug=2">2</a>

.. but texts of the format:

  Added indication that bug 2 blocks 10

did not yet get converted to:

  Added indication that bug <a href="bugreport.cgi?bug=2">2</a> blocks <a href="bugreport.cgi?bug=10">10</a>

Kind regards,

Arnout
0001-Also-mark-up-records-of-the-form-Removed-indication-.patch (text/x-diff, 3.1 KB)
>From a030408e5b876e5fde20980f79d12d8961b17e44 Mon Sep 17 00:00:00 2001
From: Arnout Engelen <[email protected]>
Date: Thu, 26 Apr 2012 21:39:29 +0200
Subject: [PATCH] Also mark up records of the form 'Removed indication that
 bug 2 blocks 10'.

---
 Debbugs/CGI/Bugreport.pm |    3 +++
 t/11_blocks.t            |   36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/Debbugs/CGI/Bugreport.pm b/Debbugs/CGI/Bugreport.pm
index 8589ac9..7cff47f 100644
--- a/Debbugs/CGI/Bugreport.pm
+++ b/Debbugs/CGI/Bugreport.pm
@@ -339,6 +339,9 @@ sub handle_record{
 		       (\d+(?:,\s+\d+)*(?:\,?\s+and\s+\d+)?)}
 		      {$1.(defined $3?$2.bug_links(bug=>$3):'').$4.
 			   english_join([map {bug_links(bug=>$_)} (split /\,?\s+(?:and\s+)?/, $5)])}xeo;
+	  $output =~ s{([Aa]dded|[Rr]emoved)( indication that bug )(\d+)( blocks )([\d\s\,]+)}
+		      {$1.$2.(bug_links(bug=>$3)).$4.
+			   english_join([map {bug_links(bug=>$_)} (split /\,?\s+(?:and\s+)?/, $5)])}eo;
 	  # Add links to reassigned packages
 	  $output =~ s{(Bug reassigned from package \`)([^']+?)((?:'|\&\#39;) to \`)([^']+?)((?:'|\&\#39;))}
 	  {$1.q(<a href=").html_escape(pkg_url(pkg=>$2)).qq(">$2</a>).$3.q(<a href=").html_escape(pkg_url(pkg=>$4)).qq(">$4</a>).$5}eo;
diff --git a/t/11_blocks.t b/t/11_blocks.t
index 553fe25..11c765a 100644
--- a/t/11_blocks.t
+++ b/t/11_blocks.t
@@ -1,6 +1,6 @@
 # -*- mode: cperl;-*-
 
-use Test::More tests => 14;
+use Test::More tests => 20;
 
 use warnings;
 use strict;
@@ -21,6 +21,7 @@ use File::Basename qw(dirname basename);
 use lib qw(t/lib);
 use DebbugsTest qw(:all);
 use Data::Dumper;
+use Test::WWW::Mechanize;
 
 # HTTP::Server:::Simple defines a SIG{CHLD} handler that breaks system; undef it here.
 $SIG{CHLD} = sub {};
@@ -159,3 +160,36 @@ ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: P
 
 $status = read_bug(bug=>3);
 ok($status->{blockedby} eq '5','bug 3 is blocked by exactly 5');
+
+# Check how this blocked bug is presented on the web interface
+
+# start up an HTTP::Server::Simple
+my $bugreport_cgi_handler = sub {
+     # I do not understand why this is necessary.
+     $ENV{DEBBUGS_CONFIG_FILE} = "$config{config_dir}/debbugs_config";
+     my $content = qx(perl -I. -T cgi/bugreport.cgi);
+     $content =~ s/^\s*Content-Type:[^\n]+\n*//si;
+     print $content;
+};
+
+my $port = 11342;
+
+ok(DebbugsTest::HTTPServer::fork_and_create_webserver($bugreport_cgi_handler,$port),
+   'forked HTTP::Server::Simple successfully');
+
+my $mech = Test::WWW::Mechanize->new();
+
+$mech->get_ok('http://localhost:'.$port.'/?bug=10',
+	      'Page received ok');
+
+ok($mech->content() =~ qr//i,
+   'Title of bug is \'Submitting a bug\'');
+
+ok($mech->content() =~ qr/Added blocking bug\(s\) of <a[^>]+10[^>]+>10<\/a>: <a[^>]+2[^>]+>2<\/a>/i,
+   '\'Added blocking bug(s) of x: y\' received markup');
+
+$mech->get_ok('http://localhost:'.$port.'/?bug=2',
+	      'Page received ok');
+
+ok($mech->content() =~ qr/Added indication that bug <a[^>]+2[^>]+>2<\/a> blocks <a[^>]+10[^>]+>10<\/a>/i,
+   '\'indication that bug x blocks y\' received markup');
-- 
1.7.9.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.