aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorSteven Day <steve@mysociety.org>2014-07-29 16:46:04 +0100
committerHakim Cassimally <hakim@mysociety.org>2014-07-31 11:17:07 +0000
commit0c254d386b2580bdcd2ffea43391acc1e682a6d4 (patch)
treeb72206ec087a1db50bc2cd7102b446882b486a4c /t
parent9a8fa132b6718b7f994476b4175f81fceebe337e (diff)
Replace from_council with from_body in SeeSomething cobrand
'from_council' was renamed to 'from_body' and turned into a relationship in b2aa34b Feb 2013, and the seesomething code was missed. Though the FMS::DB::Result::User object would (correctly) throw an error if an invalid method is called, *Catalyst* idea of a user object wraps this in a Catalyst::Authentication::Store::DBIx::Class which uses AUTOLOAD to delegate methods and swallows the error. e.g. this code always returns false, hence the code path is never run. (I think this is a bug and have opened: https://rt.cpan.org/Ticket/Display.html?id=97640 ) Added test case and (hopefully) corrected template, will need a check against site running copy with recent data to check that nothing looks squiffy. We also had to change the %council_details stash, which was based on the old code, not sure if suggested fix matches original intent, but looks plausible. (As discussed with @dracos @stevenday this is slightly repeated, and should arguably use ->{bodies} but that's a possible future FIXME)
Diffstat (limited to 't')
-rw-r--r--t/cobrand/seesomething.t39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/cobrand/seesomething.t b/t/cobrand/seesomething.t
new file mode 100644
index 000000000..3e818f2d1
--- /dev/null
+++ b/t/cobrand/seesomething.t
@@ -0,0 +1,39 @@
+use strict;
+use warnings;
+use DateTime;
+use Test::More;
+use JSON;
+
+use FixMyStreet;
+use FixMyStreet::TestMech;
+
+my $EMAIL = 'seesomething@example.com';
+
+my $mech = FixMyStreet::TestMech->new;
+my $user = $mech->create_user_ok( $EMAIL );
+
+my $body = $mech->create_body_ok( 2520, 'Coventry City Council' );
+$mech->create_body_ok( 2522, 'Dudley Borough Council' );
+$mech->create_body_ok( 2514, 'Birmingham City Council' );
+$mech->create_body_ok( 2546, 'Walsall Borough Council' );
+$mech->create_body_ok( 2519, 'Wolverhampton City Council' );
+$mech->create_body_ok( 2538, 'Solihull Borough Council' );
+$mech->create_body_ok( 2535, 'Sandwell Borough Council' );
+
+$user->update({ from_body => $body });
+
+subtest 'admin/stats' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'seesomething' ],
+ }, sub {
+ my $user = $mech->log_in_ok( $EMAIL );
+
+ $mech->get( '/admin/stats' );
+ ok $mech->success or do {
+ diag $mech->content;
+ diag $mech->status;
+ };
+ }
+};
+
+done_testing;