aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-06-03 16:09:14 +0100
committerStruan Donald <struan@exo.org.uk>2011-06-03 16:09:14 +0100
commit4767d166eca6e8c34d5c7d99c829e36722530852 (patch)
treef78b7dda1e506c0d351a88cbbdee028af4c3efbd /t/app/controller
parentbe33cdc1ad3be7136132fdd4f1aa578b60e4571b (diff)
some rudimentary tests and some removal of warnings.
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/admin.t73
1 files changed, 73 insertions, 0 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
new file mode 100644
index 000000000..ea3e8a656
--- /dev/null
+++ b/t/app/controller/admin.t
@@ -0,0 +1,73 @@
+use strict;
+use warnings;
+use Test::More;
+
+use FixMyStreet::TestMech;
+
+my $mech = FixMyStreet::TestMech->new;
+
+$mech->get_ok('/admin');
+$mech->title_like(qr/Summary/);
+
+$mech->get_ok('/admin/council_contacts/2650');
+$mech->content_contains('Aberdeen City Council');
+$mech->content_contains('AB15 8RN');
+
+subtest 'check contact creation' => sub {
+ my $contact = FixMyStreet::App->model('DB::Contact')->find(
+ { area_id => 2650, category => 'test category' }
+ );
+
+ $contact->delete if $contact;
+
+ my $history = FixMyStreet::App->model('DB::ContactsHistory')->search(
+ { area_id => 2650, category => 'test category' }
+ );
+
+ $history->delete_all;
+
+ $mech->get_ok('/admin/council_contacts/2650');
+
+ $mech->submit_form_ok( { with_fields => {
+ category => 'test category',
+ email => 'test@example.com',
+ note => 'test note',
+ } } );
+
+ $mech->content_contains( 'test category' );
+ $mech->content_contains( '<td>test@example.com' );
+ $mech->content_contains( '<td>test note' );
+};
+
+subtest 'check contact editing' => sub {
+ $mech->get_ok('/admin/council_edit/2650/test%20category');
+
+ $mech->submit_form_ok( { with_fields => {
+ email => 'test2@example.com',
+ note => 'test2 note',
+ } } );
+
+ $mech->content_contains( 'test category' );
+ $mech->content_contains( '<td>test2@example.com' );
+ $mech->content_contains( '<td>test2 note' );
+
+ $mech->get_ok('/admin/council_edit/2650/test%20category');
+ $mech->content_contains( '<td><strong>test2@example.com' );
+};
+
+subtest 'check contact updating' => sub {
+ $mech->get_ok('/admin/council_edit/2650/test%20category');
+ $mech->content_like(qr{test2\@example.com</strong>[^<]*</td>[^<]*<td>No}s);
+
+ $mech->get_ok('/admin/council_contacts/2650');
+
+ $mech->form_number( 1 );
+ $mech->tick( 'confirmed', 'test category' );
+ $mech->submit_form_ok({form_number => 1});
+
+ $mech->content_like(qr'test2@example.com</td>[^<]*<td>Yes's);
+ $mech->get_ok('/admin/council_edit/2650/test%20category');
+ $mech->content_like(qr{test2\@example.com[^<]*</td>[^<]*<td><strong>Yes}s);
+};
+
+done_testing();