aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2013-12-17 14:46:31 +0000
committerHakim Cassimally <hakim@mysociety.org>2013-12-17 14:46:31 +0000
commitc8447ee320407a0542106cf92d20d72b95452b19 (patch)
treefa620dcbbf935e2a740bf2f44ce36067da4f0298
parentcbfe33690c64f6a301e77971abb9b762318bb9be (diff)
Test for admin_base_url in RS::Problem
Test that the slash is added in correct place (the base URL should not have its own trailing slash).
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm7
-rw-r--r--t/app/controller/admin.t11
2 files changed, 17 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 603f425f7..3bf41035e 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -216,6 +216,11 @@ sub categories_summary {
return \%categories;
}
+sub get_admin_url {
+ my ($rs, $cobrand, $row) = @_;
+ return $cobrand->admin_base_url . '/report_edit/' . $row->id;
+}
+
sub send_reports {
my ( $rs, $site_override ) = @_;
@@ -278,7 +283,7 @@ sub send_reports {
$h{query} = $row->postcode;
$h{url} = $email_base_url . $row->url;
- $h{admin_url} = $cobrand->admin_base_url . '/report_edit/' . $row->id;
+ $h{admin_url} = $rs->get_admin_url($cobrand, $row);
$h{phone_line} = $h{phone} ? _('Phone:') . " $h{phone}\n\n" : '';
if ($row->photo) {
$h{has_photo} = _("This web page also contains a photo of the problem, provided by the user.") . "\n\n";
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 4970821a8..e369968b4 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -1228,6 +1228,17 @@ subtest "Test setting a report from unconfirmed to something else doesn't cause
$mech->get_ok("/report/$report_id");
};
+subtest "Check admin_base_url" => sub {
+ my $rs = FixMyStreet::App->model('DB::Problem');
+ my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($report->cobrand)->new();
+
+ is (FixMyStreet::App->model('DB::Problem')->get_admin_url(
+ $cobrand,
+ $report),
+ (sprintf 'https://secure.mysociety.org/admin/bci/report_edit/%d', $report_id),
+ 'get_admin_url OK');
+};
+
$mech->delete_user( $user );
$mech->delete_user( $user2 );
$mech->delete_user( $user3 );