aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/admin.t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-08-04 12:42:21 +0100
committerStruan Donald <struan@exo.org.uk>2011-08-04 12:42:21 +0100
commit8a253eeff63556c7bf3ed7cac5ecb82cbfacef27 (patch)
tree5cc29eb7f06ecaf6d50c598488b261a59de342d7 /t/app/controller/admin.t
parent3bb65a5debda34cdffd2a83f4747ea19412d0410 (diff)
configure open311 endpoint etc in admin interface
Diffstat (limited to 't/app/controller/admin.t')
-rw-r--r--t/app/controller/admin.t53
1 files changed, 53 insertions, 0 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 9f698c629..17e6f015e 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -202,6 +202,59 @@ subtest 'check contact updating' => sub {
$mech->content_like(qr{test2\@example.com[^<]*</td>[^<]*<td><strong>Yes}s);
};
+my $open311 =
+ FixMyStreet::App->model('DB::Open311Conf')->search( { area_id => 2650 } );
+$open311->delete if $open311;
+
+subtest 'check open311 configuring' => sub {
+ $mech->get_ok('/admin/council_contacts/2650/');
+ $mech->content_lacks('Council contacts configured via Open311');
+
+ $mech->form_number(3);
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ api_key => 'api key',
+ endpoint => 'http://example.com/open311',
+ jurisdiction => 'mySociety',
+ }
+ }
+ );
+ $mech->content_contains('Council contacts configured via Open311');
+ $mech->content_contains('Configuration updated - contacts will be generated automatically later');
+
+ $open311 =
+ FixMyStreet::App->model('DB::Open311Conf')->search( { area_id => 2650 } );
+
+ is $open311->count, 1, 'only one configuration';
+ my $conf = $open311->first;
+ is $conf->endpoint, 'http://example.com/open311', 'endpoint configured';
+ is $conf->api_key, 'api key', 'api key configured';
+ is $conf->jurisdiction, 'mySociety', 'jurisdiction configures';
+
+ $mech->form_number(3);
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ api_key => 'new api key',
+ endpoint => 'http://example.org/open311',
+ jurisdiction => 'open311',
+ }
+ }
+ );
+
+ $mech->content_contains('Configuration updated');
+
+ $open311 =
+ FixMyStreet::App->model('DB::Open311Conf')->search( { area_id => 2650 } );
+
+ is $open311->count, 1, 'only one configuration';
+ $conf = $open311->first;
+ is $conf->endpoint, 'http://example.org/open311', 'endpoint updated';
+ is $conf->api_key, 'new api key', 'api key updated';
+ is $conf->jurisdiction, 'open311', 'jurisdiction configures';
+};
+
subtest 'check text output' => sub {
$mech->get_ok('/admin/council_contacts/2650?text=1');
is $mech->content_type, 'text/plain';