aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2013-10-23 22:38:20 +0100
committerMatthew Somerville <matthew@mysociety.org>2013-10-24 21:34:46 +0100
commitcd51c26830d4f6ba144874e2f26010f7b6b76636 (patch)
tree17a0316b6c461e2ba45ac1d462772bf37fddc38e
parent0b28f2ac1af652c37eda35f944b5eb78f4adf5d1 (diff)
Fix test suite to run regardless of config setup.
-rw-r--r--.travis.yml4
-rw-r--r--t/app/controller/about.t9
-rw-r--r--t/app/controller/admin.t27
-rw-r--r--t/app/controller/alert.t85
-rw-r--r--t/app/controller/alert_new.t59
-rw-r--r--t/app/controller/around.t24
-rw-r--r--t/app/controller/index.t6
-rw-r--r--t/app/controller/questionnaire.t18
-rw-r--r--t/app/controller/report_display.t26
-rw-r--r--t/app/controller/report_import.t236
-rw-r--r--t/app/controller/report_interest_count.t7
-rw-r--r--t/app/controller/report_new.t524
-rw-r--r--t/app/controller/report_new_open311.t34
-rw-r--r--t/app/controller/reports.t56
-rw-r--r--t/app/controller/rss.t30
-rw-r--r--t/app/model/alert_type.t18
-rw-r--r--t/app/model/problem.t18
-rw-r--r--t/app/uri_for.t20
-rw-r--r--t/cobrand/bromley.t3
-rw-r--r--t/cobrand/councils.t10
-rw-r--r--t/cobrand/fixmybarangay.t15
-rw-r--r--t/cobrand/get_body_sender.t13
-rw-r--r--t/cobrand/zurich.t273
23 files changed, 904 insertions, 611 deletions
diff --git a/.travis.yml b/.travis.yml
index 944931667..9ce5dbc86 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -34,10 +34,6 @@ before_script:
- psql fms postgres < db/generate_secret.sql
- >
sed -r -e "s,(FMS_DB_USER:) 'fms',\\1 'postgres',"
- -e "s,cobrand_one,barnet\\n - bromley\\n - emptyhomes\\n - fiksgatami\\n - fixmybarangay\\n - lichfielddc\\n - reading\\n - seesomething\\n - southampton\\n - zurich,"
- -e "s,cobrand_two: 'hostname_substring2',fixmystreet: '.',"
- -e "s,(BASE_URL:) 'http://www.example.org',\\1 'http://localhost',"
- -e "s,(MAPIT_URL:) '',\\1 'http://mapit.mysociety.org/',"
conf/general.yml-example > conf/general.yml
- ./bin/cron-wrapper ./bin/make_po FixMyStreet-EmptyHomes
- ./bin/cron-wrapper ./bin/make_emptyhomes_welsh_po
diff --git a/t/app/controller/about.t b/t/app/controller/about.t
index ed28eb584..b3562ea04 100644
--- a/t/app/controller/about.t
+++ b/t/app/controller/about.t
@@ -11,10 +11,9 @@ $mech->get_ok('/about');
$mech->content_like(qr{About us ::\s+FixMyStreet});
$mech->content_contains('html class="no-js" lang="en-gb"');
-SKIP: {
- skip( "Need 'emptyhomes' in ALLOWED_COBRANDS config", 8 )
- unless FixMyStreet::Cobrand->exists('emptyhomes');
-
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'emptyhomes' ],
+}, sub {
# check that geting the page as EHA produces a different page
ok $mech->host("reportemptyhomes.co.uk"), 'change host to reportemptyhomes';
$mech->get_ok('/about');
@@ -26,6 +25,6 @@ SKIP: {
$mech->get_ok('/about');
$mech->content_like(qr{Amdanom ni ::\s+Rhoi gwybod am eiddo gwag});
$mech->content_contains('html lang="cy"');
-}
+};
done_testing();
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 521497f3e..80ea839da 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -93,7 +93,11 @@ subtest 'check summary counts' => sub {
my $alerts = FixMyStreet::App->model('DB::Alert')->search( { confirmed => { '>' => 0 } } );
my $a_count = $alerts->count;
- $mech->get_ok('/admin');
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ }, sub {
+ $mech->get_ok('/admin');
+ };
$mech->title_like(qr/Summary/);
@@ -105,10 +109,9 @@ subtest 'check summary counts' => sub {
$mech->content_contains( "$q_count questionnaires sent" );
- SKIP: {
- skip( "Need 'barnet' in ALLOWED_COBRANDS config", 7 )
- unless FixMyStreet::Cobrand->exists('barnet');
-
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'barnet' ],
+ }, sub {
ok $mech->host('barnet.fixmystreet.com');
$mech->get_ok('/admin');
@@ -137,19 +140,23 @@ subtest 'check summary counts' => sub {
$alert->cobrand('');
$alert->update;
- }
+ };
FixMyStreet::App->model('DB::Problem')->search( { bodies_str => 1 } )->update( { bodies_str => 2489 } );
ok $mech->host('fixmystreet.com');
};
-my $host = FixMyStreet->config('BASE_URL');
-
my $body = $mech->create_body_ok(2650, 'Aberdeen City Council');
-$mech->get_ok('/admin/body/2650');
+FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ MAPIT_TYPES => [ 'UTA' ],
+ BASE_URL => 'http://www.example.org',
+}, sub {
+ $mech->get_ok('/admin/body/2650');
+};
$mech->content_contains('Aberdeen City Council');
$mech->content_like(qr{AB\d\d});
-$mech->content_contains("$host/around");
+$mech->content_contains("http://www.example.org/around");
subtest 'check contact creation' => sub {
my $contact = FixMyStreet::App->model('DB::Contact')->search(
diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t
index 847aa1a17..6fab4d3e3 100644
--- a/t/app/controller/alert.t
+++ b/t/app/controller/alert.t
@@ -12,56 +12,61 @@ $mech->content_contains('Local RSS feeds and email alerts');
$mech->content_contains('html class="no-js" lang="en-gb"');
# check that we can get list page
-$mech->get_ok('/alert/list');
-$mech->title_like(qr/^Local RSS feeds and email alerts/);
-$mech->content_contains('Local RSS feeds and email alerts');
-$mech->content_contains('html class="no-js" lang="en-gb"');
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ $mech->get_ok('/alert/list');
+ $mech->title_like(qr/^Local RSS feeds and email alerts/);
+ $mech->content_contains('Local RSS feeds and email alerts');
+ $mech->content_contains('html class="no-js" lang="en-gb"');
-$mech->get_ok('/alert/list?pc=EH99 1SP');
-$mech->title_like(qr/^Local RSS feeds and email alerts/);
-$mech->content_contains('Here are the types of local problem alerts for &lsquo;EH99&nbsp;1SP&rsquo;');
-$mech->content_contains('html class="no-js" lang="en-gb"');
-$mech->content_contains('Problems within 8.5km');
-$mech->content_contains('rss/pc/EH991SP/2');
-$mech->content_contains('rss/pc/EH991SP/5');
-$mech->content_contains('rss/pc/EH991SP/10');
-$mech->content_contains('rss/pc/EH991SP/20');
-$mech->content_contains('Problems within City of Edinburgh');
-$mech->content_contains('Problems within City Centre ward');
-$mech->content_contains('/rss/reports/City+of+Edinburgh');
-$mech->content_contains('/rss/reports/City+of+Edinburgh/City+Centre');
-$mech->content_contains('council:2651:City_of_Edinburgh');
-$mech->content_contains('ward:2651:20728:City_of_Edinburgh:City_Centre');
+ $mech->get_ok('/alert/list?pc=EH99 1SP');
+ $mech->title_like(qr/^Local RSS feeds and email alerts/);
+ $mech->content_contains('Here are the types of local problem alerts for &lsquo;EH99&nbsp;1SP&rsquo;');
+ $mech->content_contains('html class="no-js" lang="en-gb"');
+ $mech->content_contains('Problems within 8.5km');
+ $mech->content_contains('rss/pc/EH991SP/2');
+ $mech->content_contains('rss/pc/EH991SP/5');
+ $mech->content_contains('rss/pc/EH991SP/10');
+ $mech->content_contains('rss/pc/EH991SP/20');
+ $mech->content_contains('Problems within City of Edinburgh');
+ $mech->content_contains('Problems within City Centre ward');
+ $mech->content_contains('/rss/reports/City+of+Edinburgh');
+ $mech->content_contains('/rss/reports/City+of+Edinburgh/City+Centre');
+ $mech->content_contains('council:2651:City_of_Edinburgh');
+ $mech->content_contains('ward:2651:20728:City_of_Edinburgh:City_Centre');
-$mech->get_ok('/alert/list?pc=High Street');
-$mech->content_contains('We found more than one match for that location');
+ $mech->get_ok('/alert/list?pc=High Street');
+ $mech->content_contains('We found more than one match for that location');
-$mech->get_ok('/alert/list?pc=');
-$mech->content_contains('To find out what local alerts we have for you');
+ $mech->get_ok('/alert/list?pc=');
+ $mech->content_contains('To find out what local alerts we have for you');
-$mech->get_ok('/alert/list?pc=GL502PR');
-$mech->content_contains('Problems within the boundary of');
+ $mech->get_ok('/alert/list?pc=GL502PR');
+ $mech->content_contains('Problems within the boundary of');
-$mech->get_ok('/alert/subscribe?rss=1&type=local&pc=ky16+8yg&rss=Give+me+an+RSS+feed&rznvy=' );
-$mech->content_contains('Please select the feed you want');
+ $mech->get_ok('/alert/subscribe?rss=1&type=local&pc=ky16+8yg&rss=Give+me+an+RSS+feed&rznvy=' );
+ $mech->content_contains('Please select the feed you want');
-$mech->get_ok('/alert/subscribe?rss=1&feed=invalid:1000:A_Locationtype=local&pc=ky16+8yg&rss=Give+me+an+RSS+feed&rznvy=');
-$mech->content_contains('Illegal feed selection');
+ $mech->get_ok('/alert/subscribe?rss=1&feed=invalid:1000:A_Locationtype=local&pc=ky16+8yg&rss=Give+me+an+RSS+feed&rznvy=');
+ $mech->content_contains('Illegal feed selection');
-$mech->create_body_ok(2504, 'Birmingham City Council');
-$mech->create_body_ok(2226, 'Gloucestershire County Council');
-$mech->create_body_ok(2326, 'Cheltenham Borough Council');
+ $mech->create_body_ok(2504, 'Birmingham City Council');
+ $mech->create_body_ok(2226, 'Gloucestershire County Council');
+ $mech->create_body_ok(2326, 'Cheltenham Borough Council');
-$mech->get_ok('/alert/subscribe?rss=1&feed=area:1000:Birmingham');
-is $mech->uri->path, '/rss/reports/Birmingham';
+ $mech->get_ok('/alert/subscribe?rss=1&feed=area:1000:Birmingham');
+ is $mech->uri->path, '/rss/reports/Birmingham';
-$mech->get_ok('/alert/subscribe?rss=1&feed=area:1000:1001:Cheltenham:Lansdown');
-is $mech->uri->path, '/rss/area/Cheltenham/Lansdown';
+ $mech->get_ok('/alert/subscribe?rss=1&feed=area:1000:1001:Cheltenham:Lansdown');
+ is $mech->uri->path, '/rss/area/Cheltenham/Lansdown';
-$mech->get_ok('/alert/subscribe?rss=1&feed=council:1000:Gloucestershire');
-is $mech->uri->path, '/rss/reports/Gloucestershire';
+ $mech->get_ok('/alert/subscribe?rss=1&feed=council:1000:Gloucestershire');
+ is $mech->uri->path, '/rss/reports/Gloucestershire';
-$mech->get_ok('/alert/subscribe?rss=1&feed=ward:1000:1001:Cheltenham:Lansdown');
-is $mech->uri->path, '/rss/reports/Cheltenham/Lansdown';
+ $mech->get_ok('/alert/subscribe?rss=1&feed=ward:1000:1001:Cheltenham:Lansdown');
+ is $mech->uri->path, '/rss/reports/Cheltenham/Lansdown';
+};
done_testing();
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index 23240c3b9..1804da32e 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -207,7 +207,12 @@ foreach my $test (
$mech->log_in_ok( $test->{email} );
$mech->clear_emails_ok;
- $mech->get_ok('/alert/list?pc=EH991SP');
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok('/alert/list?pc=EH991SP');
+ };
$mech->set_visible( [ radio => 'council:2651:City_of_Edinburgh' ] );
$mech->click('alert');
@@ -306,13 +311,18 @@ subtest "Test two-tier council alerts" => sub {
result => '/rss/reports/Gloucestershire/Lansdown+and+Park'
},
) {
- $mech->get_ok( '/alert/list?pc=GL502PR' );
- $mech->submit_form_ok( {
- button => 'rss',
- with_fields => {
- feed => $alert->{feed},
- }
- } );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok( '/alert/list?pc=GL502PR' );
+ $mech->submit_form_ok( {
+ button => 'rss',
+ with_fields => {
+ feed => $alert->{feed},
+ }
+ } );
+ };
is $mech->uri->path, $alert->{result}, 'Redirected to right RSS feed';
}
};
@@ -344,11 +354,16 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
},
) {
$mech->get_ok( '/alert' );
- $mech->submit_form_ok( { with_fields => { pc => 'EH11BB' } } );
- $mech->submit_form_ok( {
- button => 'alert',
- with_fields => $alert->{fields},
- } );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => 'EH11BB' } } );
+ $mech->submit_form_ok( {
+ button => 'alert',
+ with_fields => $alert->{fields},
+ } );
+ };
if ( $alert->{email_confirm} ) {
my $email = $mech->get_email;
$mech->clear_emails_ok;
@@ -425,7 +440,11 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
$update_id = $update->id;
ok $update, "created test update - $update_id";
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ };
# TODO Note the below will fail if the db has an existing alert that matches
$mech->email_count_is(3);
my @emails = $mech->get_email;
@@ -545,11 +564,19 @@ for my $test (
} );
$mech->clear_emails_ok;
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ };
$mech->email_count_is(0);
$report->update( { non_public => 0 } );
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ };
$mech->email_count_is(1);
my $email = $mech->get_email;
like $email->body, qr/Alert\s+test\s+for\s+non\s+public\s+reports/, 'alert contains public report';
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index fa2d94aed..cbb110a1a 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -14,7 +14,11 @@ subtest "check that if no query we get sent back to the homepage" => sub {
# historic links
subtest "redirect x,y requests to lat/lon (301 - permanent)" => sub {
- $mech->get_ok('/around?x=3281&y=1113');
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok('/around?x=3281&y=1113');
+ };
# did we redirect to lat,lon?
is $mech->uri->path, '/around', "still on /around";
@@ -75,8 +79,13 @@ foreach my $test (
{
subtest "check lat/lng for '$test->{pc}'" => sub {
$mech->get_ok('/');
- $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
- "good location" );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
+ "good location" );
+ };
is_deeply $mech->page_errors, [], "no errors for pc '$test->{pc}'";
is_deeply $mech->extract_location, $test,
"got expected location for pc '$test->{pc}'";
@@ -93,8 +102,13 @@ subtest 'check non public reports are not displayed on around page' => sub {
$mech->create_problems_for_body( 5, 2651, 'Around page', $params );
$mech->get_ok('/');
- $mech->submit_form_ok( { with_fields => { pc => 'EH99 1SP' } },
- "good location" );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => 'EH99 1SP' } },
+ "good location" );
+ };
$mech->content_contains( 'Around page Test 3 for 2651',
'problem to be marked non public visible' );
diff --git a/t/app/controller/index.t b/t/app/controller/index.t
index 47c08291f..7fc15ab4b 100644
--- a/t/app/controller/index.t
+++ b/t/app/controller/index.t
@@ -47,7 +47,11 @@ subtest "does pc, (x,y), (e,n) or (lat,lon) go to /around" => sub {
$uri->query_form( $test->{in} );
# get the uri and check for 302
- $mech->get_ok($uri);
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok($uri);
+ };
# check that we are at /around
is $mech->uri->path, '/around', "Got to /around";
diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t
index 5c81a43d1..8e553a1a5 100644
--- a/t/app/controller/questionnaire.t
+++ b/t/app/controller/questionnaire.t
@@ -383,10 +383,9 @@ for my $test (
};
}
-SKIP: {
- skip( "Need 'emptyhomes' in ALLOWED_COBRANDS config", 18 )
- unless FixMyStreet::Cobrand->exists('emptyhomes');
-
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'emptyhomes' ],
+}, sub {
# EHA extra checking
ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
@@ -436,12 +435,11 @@ SKIP: {
ok $questionnaire, 'found questionnaire';
$questionnaire2->delete;
-}
-
-SKIP: {
- skip( "Need 'fiksgatami' in ALLOWED_COBRANDS config", 5 )
- unless FixMyStreet::Cobrand->exists('fiksgatami');
+};
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fiksgatami' ],
+}, sub {
# I18N Unicode extra testing using FiksGataMi
$report->send_questionnaire( 1 );
$report->cobrand( 'fiksgatami' );
@@ -455,7 +453,7 @@ SKIP: {
like $email->body, qr/Testing =96 Detail/, 'email contains encoded character from user';
like $email->body, qr/sak p=E5 FiksGataMi/, 'email contains encoded character from template';
is $email->header('Content-Type'), 'text/plain; charset="windows-1252"', 'email is in right encoding';
-}
+};
$mech->delete_user('test@example.com');
done_testing();
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index c17ee70ea..07e8caa9b 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -97,15 +97,16 @@ subtest "change report to unconfirmed and check for 404 status" => sub {
subtest "Zurich unconfirmeds are 200" => sub {
- if ( !FixMyStreet::Cobrand->exists('zurich') ) {
- plan skip_all => 'Skipping Zurich test without Zurich cobrand';
- }
- $mech->host( 'zurich.example.com' );
- ok $report->update( { state => 'unconfirmed' } ), 'unconfirm report';
- $mech->get_ok("/report/$report_id");
- $mech->content_contains( '&Uuml;berpr&uuml;fung ausstehend' );
- ok $report->update( { state => 'confirmed' } ), 'confirm report again';
- $mech->host( 'www.fixmystreet.com' );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ }, sub {
+ $mech->host( 'zurich.example.com' );
+ ok $report->update( { state => 'unconfirmed' } ), 'unconfirm report';
+ $mech->get_ok("/report/$report_id");
+ $mech->content_contains( '&Uuml;berpr&uuml;fung ausstehend' );
+ ok $report->update( { state => 'confirmed' } ), 'confirm report again';
+ $mech->host( 'www.fixmystreet.com' );
+ };
};
subtest "change report to hidden and check for 410 status" => sub {
@@ -400,9 +401,9 @@ for my $test (
}
subtest "Zurich banners are displayed correctly" => sub {
- if ( !FixMyStreet::Cobrand->exists('zurich') ) {
- plan skip_all => 'Skipping Zurich test without Zurich cobrand';
- }
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ }, sub {
$mech->host( 'zurich.example.com' );
for my $test (
@@ -466,6 +467,7 @@ subtest "Zurich banners are displayed correctly" => sub {
}
$mech->host( 'www.fixmystreet.com' );
+ };
};
$mech->create_body_ok(2504, 'Westminster City Council');
diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t
index e25764c4b..a6ccc9604 100644
--- a/t/app/controller/report_import.t
+++ b/t/app/controller/report_import.t
@@ -63,10 +63,14 @@ subtest "Test creating bad partial entries" => sub {
{
$mech->get_ok('/import');
- $mech->submit_form_ok( #
- { with_fields => $test->{fields} },
- "fill in form"
- );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ }, sub {
+ $mech->submit_form_ok( #
+ { with_fields => $test->{fields} },
+ "fill in form"
+ );
+ };
is_deeply( $mech->import_errors, $test->{errors}, "expected errors" );
}
@@ -103,7 +107,11 @@ subtest "Submit a correct entry" => sub {
ok $token_url, "Found a token url $token_url";
# go to the token url
- $mech->get_ok($token_url);
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok($token_url);
+ };
# check that we are on '/around'
is $mech->uri->path, '/around', "sent to /around";
@@ -112,10 +120,15 @@ subtest "Submit a correct entry" => sub {
is_deeply $mech->visible_form_values, { pc => '' },
"check only pc field is shown";
- $mech->submit_form_ok( #
- { with_fields => { pc => 'SW1A 1AA' } },
- "fill in postcode"
- );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok(
+ { with_fields => { pc => 'SW1A 1AA' } },
+ "fill in postcode"
+ );
+ };
is $mech->uri->path, '/report/new', "sent to report page";
@@ -136,14 +149,19 @@ subtest "Submit a correct entry" => sub {
$mech->content_contains( '<img align="right" src="/photo/' );
$mech->content_contains('latitude" value="51.50101"', 'Check latitude');
$mech->content_contains('longitude" value="-0.141587"', 'Check longitude');
- $mech->submit_form_ok(
- {
- button => 'tile_32742.21793',
- x => 10,
- y => 10,
- },
- "New map location"
- );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok(
+ {
+ button => 'tile_32742.21793',
+ x => 10,
+ y => 10,
+ },
+ "New map location"
+ );
+ };
$mech->content_contains( '<img align="right" src="/photo/' );
$mech->content_contains('latitude" value="51.50519"', 'Check latitude');
$mech->content_contains('longitude" value="-0.142608"', 'Check longitude');
@@ -162,19 +180,24 @@ subtest "Submit a correct entry" => sub {
"check imported fields are shown";
# change the details
- $mech->submit_form_ok( #
- {
- with_fields => {
- name => 'New Test User',
- title => 'New Test report',
- detail => 'This is a test report',
- phone => '01234 567 890',
- may_show_name => '1',
- category => 'Street lighting',
- }
- },
- "Update details and save"
- );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ name => 'New Test User',
+ title => 'New Test report',
+ detail => 'This is a test report',
+ phone => '01234 567 890',
+ may_show_name => '1',
+ category => 'Street lighting',
+ }
+ },
+ "Update details and save"
+ );
+ };
# check that report has been created
my $user =
@@ -221,7 +244,12 @@ subtest "Submit a correct entry (with location)" => sub {
ok $token_url, "Found a token url $token_url";
# go to the token url
- $mech->get_ok($token_url);
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok($token_url);
+ };
# check that we are on '/report/new'
is $mech->uri->path, '/report/new', "sent to /report/new";
@@ -240,19 +268,24 @@ subtest "Submit a correct entry (with location)" => sub {
"check imported fields are shown";
# change the details
- $mech->submit_form_ok( #
- {
- with_fields => {
- name => 'New Test User ll',
- title => 'New Test report ll',
- detail => 'This is a test report ll',
- phone => '01234 567 890',
- may_show_name => '1',
- category => 'Street lighting',
- }
- },
- "Update details and save"
- );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( #
+ {
+ with_fields => {
+ name => 'New Test User ll',
+ title => 'New Test report ll',
+ detail => 'This is a test report ll',
+ phone => '01234 567 890',
+ may_show_name => '1',
+ category => 'Street lighting',
+ }
+ },
+ "Update details and save"
+ );
+ };
# check that report has been created
my $user =
@@ -268,72 +301,71 @@ subtest "Submit a correct entry (with location)" => sub {
};
subtest "Submit a correct entry (with location) to cobrand" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fiksgatami' ],
+ MAPIT_URL => 'http://mapit.nuug.no/',
+ }, sub {
+ ok $mech->host("fiksgatami.no"), 'change host to fiksgatami';
- SKIP: {
- skip( "Need 'fiksgatami' in ALLOWED_COBRANDS config", 20 )
- unless FixMyStreet::Cobrand->exists('fiksgatami');
- mySociety::MaPit::configure('http://mapit.nuug.no/');
- ok $mech->host("fiksgatami.no"), 'change host to fiksgatami';
+ $mech->get_ok('/import');
- $mech->get_ok('/import');
+ $mech->submit_form_ok( #
+ {
+ with_fields => {
+ service => 'test-script',
+ lat => '59',
+ lon => '10',
+ name => 'Test User ll',
+ email => 'test-ll@example.com',
+ subject => 'Test report ll',
+ detail => 'This is a test report ll',
+ photo => $sample_file,
+ }
+ },
+ "fill in form"
+ );
- $mech->submit_form_ok( #
- {
- with_fields => {
- service => 'test-script',
- lat => '59',
- lon => '10',
- name => 'Test User ll',
- email => 'test-ll@example.com',
- subject => 'Test report ll',
- detail => 'This is a test report ll',
- photo => $sample_file,
- }
- },
- "fill in form"
- );
+ is_deeply( $mech->import_errors, [], "got no errors" );
+ is $mech->content, 'SUCCESS', "Got success response";
- is_deeply( $mech->import_errors, [], "got no errors" );
- is $mech->content, 'SUCCESS', "Got success response";
+ # check that we have received the email
+ $mech->email_count_is(1);
+ my $email = $mech->get_email;
+ $mech->clear_emails_ok;
- # check that we have received the email
- $mech->email_count_is(1);
- my $email = $mech->get_email;
- $mech->clear_emails_ok;
+ my ($token_url) = $email->body =~ m{(http://\S+)};
+ ok $token_url, "Found a token url $token_url";
- my ($token_url) = $email->body =~ m{(http://\S+)};
- ok $token_url, "Found a token url $token_url";
+ # go to the token url
+ $mech->get_ok($token_url);
- # go to the token url
- $mech->get_ok($token_url);
+ # check that we are on '/report/new'
+ is $mech->uri->path, '/report/new', "sent to /report/new";
- # check that we are on '/report/new'
- is $mech->uri->path, '/report/new', "sent to /report/new";
-
- # check that fields are prefilled for us
- is_deeply $mech->visible_form_values,
- {
- name => 'Test User ll',
- title => 'Test report ll',
- detail => 'This is a test report ll',
- photo => '',
- phone => '',
- may_show_name => '1',
- },
- "check imported fields are shown";
-
- my $user =
- FixMyStreet::App->model('DB::User')
- ->find( { email => 'test-ll@example.com' } );
- ok $user, "Found a user";
-
- my $report = $user->problems->first;
- is $report->state, 'partial', 'is still partial';
- is $report->title, 'Test report ll', 'title is correct';
- is $report->lang, 'nb', 'language is correct';
-
- $mech->delete_user($user);
- }
+ # check that fields are prefilled for us
+ is_deeply $mech->visible_form_values,
+ {
+ name => 'Test User ll',
+ title => 'Test report ll',
+ detail => 'This is a test report ll',
+ photo => '',
+ phone => '',
+ may_show_name => '1',
+ },
+ "check imported fields are shown";
+
+ my $user =
+ FixMyStreet::App->model('DB::User')
+ ->find( { email => 'test-ll@example.com' } );
+ ok $user, "Found a user";
+
+ my $report = $user->problems->first;
+ is $report->state, 'partial', 'is still partial';
+ is $report->title, 'Test report ll', 'title is correct';
+ is $report->lang, 'nb', 'language is correct';
+
+ $mech->delete_user($user);
+ };
};
done_testing();
diff --git a/t/app/controller/report_interest_count.t b/t/app/controller/report_interest_count.t
index bfd1a8d1f..3de931c74 100644
--- a/t/app/controller/report_interest_count.t
+++ b/t/app/controller/report_interest_count.t
@@ -51,10 +51,9 @@ my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
my $report_id = $report->id;
ok $report, "created test report - $report_id";
-SKIP: {
- skip( "Need 'fixmybarangay' in ALLOWED_COBRANDS config", 29 )
- unless FixMyStreet::Cobrand->exists('fixmybarangay');
-
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmybarangay' ],
+}, sub {
$mech->create_body_ok(2504, 'Westminster City Council');
for my $test (
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index d1f246e95..4a6ba9bac 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -454,17 +454,22 @@ foreach my $test (
$mech->get_ok('/around');
# submit initial pc form
- $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
- "submit location" );
- is_deeply $mech->page_errors, [], "no errors for pc '$test->{pc}'";
-
- # click through to the report page
- $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
- "follow 'skip this step' link" );
-
- # submit the main form
- $mech->submit_form_ok( { with_fields => $test->{fields} },
- "submit form" );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
+ "submit location" );
+ is_deeply $mech->page_errors, [], "no errors for pc '$test->{pc}'";
+
+ # click through to the report page
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link" );
+
+ # submit the main form
+ $mech->submit_form_ok( { with_fields => $test->{fields} },
+ "submit form" );
+ };
# check that we got the errors expected
is_deeply $mech->page_errors, $test->{errors}, "check errors";
@@ -522,30 +527,35 @@ foreach my $test (
# submit initial pc form
$mech->get_ok('/around');
- $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } },
- "submit location" );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } },
+ "submit location" );
- # click through to the report page
- $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
- "follow 'skip this step' link" );
+ # click through to the report page
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link" );
- $mech->submit_form_ok(
- {
- button => 'submit_register',
- with_fields => {
- title => 'Test Report',
- detail => 'Test report details.',
- photo => '',
- name => 'Joe Bloggs',
- may_show_name => '1',
- email => 'test-1@example.com',
- phone => '07903 123 456',
- category => 'Street lighting',
- password_register => $test->{password} ? 'secret' : '',
- }
- },
- "submit good details"
- );
+ $mech->submit_form_ok(
+ {
+ button => 'submit_register',
+ with_fields => {
+ title => 'Test Report',
+ detail => 'Test report details.',
+ photo => '',
+ name => 'Joe Bloggs',
+ may_show_name => '1',
+ email => 'test-1@example.com',
+ phone => '07903 123 456',
+ category => 'Street lighting',
+ password_register => $test->{password} ? 'secret' : '',
+ }
+ },
+ "submit good details"
+ );
+ };
# check that we got the errors expected
is_deeply $mech->page_errors, [], "check there were no errors";
@@ -635,27 +645,32 @@ subtest "test password errors for a user who is signing in as they report" => su
# submit initial pc form
$mech->get_ok('/around');
- $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } },
- "submit location" );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } },
+ "submit location" );
- # click through to the report page
- $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
- "follow 'skip this step' link" );
+ # click through to the report page
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link" );
- $mech->submit_form_ok(
- {
- button => 'submit_sign_in',
- with_fields => {
- title => 'Test Report',
- detail => 'Test report details.',
- photo => '',
- email => 'test-2@example.com',
- password_sign_in => 'secret1',
- category => 'Street lighting',
- }
- },
- "submit with wrong password"
- );
+ $mech->submit_form_ok(
+ {
+ button => 'submit_sign_in',
+ with_fields => {
+ title => 'Test Report',
+ detail => 'Test report details.',
+ photo => '',
+ email => 'test-2@example.com',
+ password_sign_in => 'secret1',
+ category => 'Street lighting',
+ }
+ },
+ "submit with wrong password"
+ );
+ };
# check that we got the errors expected
is_deeply $mech->page_errors, [
@@ -682,42 +697,47 @@ subtest "test report creation for a user who is signing in as they report" => su
# submit initial pc form
$mech->get_ok('/around');
- $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } },
- "submit location" );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } },
+ "submit location" );
- # click through to the report page
- $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
- "follow 'skip this step' link" );
+ # click through to the report page
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link" );
- $mech->submit_form_ok(
- {
- button => 'submit_sign_in',
- with_fields => {
- title => 'Test Report',
- detail => 'Test report details.',
- photo => '',
- email => 'test-2@example.com',
- password_sign_in => 'secret2',
- category => 'Street lighting',
- }
- },
- "submit good details"
- );
+ $mech->submit_form_ok(
+ {
+ button => 'submit_sign_in',
+ with_fields => {
+ title => 'Test Report',
+ detail => 'Test report details.',
+ photo => '',
+ email => 'test-2@example.com',
+ password_sign_in => 'secret2',
+ category => 'Street lighting',
+ }
+ },
+ "submit good details"
+ );
- # check that we got the errors expected
- is_deeply $mech->page_errors, [
- 'You have successfully signed in; please check and confirm your details are accurate:',
- ], "check there were errors";
+ # check that we got the errors expected
+ is_deeply $mech->page_errors, [
+ 'You have successfully signed in; please check and confirm your details are accurate:',
+ ], "check there were errors";
- # Now submit with a name
- $mech->submit_form_ok(
- {
- with_fields => {
- name => 'Joe Bloggs',
- }
- },
- "submit good details"
- );
+ # Now submit with a name
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ name => 'Joe Bloggs',
+ }
+ },
+ "submit good details"
+ );
+ };
# find the report
my $report = $user->problems->first;
@@ -776,42 +796,47 @@ foreach my $test (
# submit initial pc form
$mech->get_ok('/around');
- $mech->submit_form_ok( { with_fields => { pc => 'GL50 2PR', } },
- "submit location" );
-
- # click through to the report page
- $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
- "follow 'skip this step' link" );
-
- # check that the fields are correctly prefilled
- is_deeply(
- $mech->visible_form_values,
- {
- title => '',
- detail => '',
- may_show_name => '1',
- name => 'Test User',
- phone => '01234 567 890',
- photo => '',
- category => '-- Pick a category --',
- },
- "user's details prefilled"
- );
-
- $mech->submit_form_ok(
- {
- with_fields => {
- title => "Test Report at café",
- detail => 'Test report details.',
- photo => '',
- name => 'Joe Bloggs',
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => 'GL50 2PR', } },
+ "submit location" );
+
+ # click through to the report page
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link" );
+
+ # check that the fields are correctly prefilled
+ is_deeply(
+ $mech->visible_form_values,
+ {
+ title => '',
+ detail => '',
may_show_name => '1',
- phone => '07903 123 456',
- category => $test->{category},
- }
- },
- "submit good details"
- );
+ name => 'Test User',
+ phone => '01234 567 890',
+ photo => '',
+ category => '-- Pick a category --',
+ },
+ "user's details prefilled"
+ );
+
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ title => "Test Report at café",
+ detail => 'Test report details.',
+ photo => '',
+ name => 'Joe Bloggs',
+ may_show_name => '1',
+ phone => '07903 123 456',
+ category => $test->{category},
+ }
+ },
+ "submit good details"
+ );
+ };
# find the report
my $report = $user->problems->first;
@@ -870,27 +895,32 @@ subtest "test report creation for a category that is non public" => sub {
# submit initial pc form
$mech->get_ok('/around');
- $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } },
- "submit location" );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } },
+ "submit location" );
- # click through to the report page
- $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
- "follow 'skip this step' link" );
+ # click through to the report page
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link" );
- $mech->submit_form_ok(
- {
- button => 'submit_register',
- with_fields => {
- title => 'Test Report',
- detail => 'Test report details.',
- photo => '',
- email => 'test-2@example.com',
- name => 'Joe Bloggs',
- category => 'Street lighting',
- }
- },
- "submit good details"
- );
+ $mech->submit_form_ok(
+ {
+ button => 'submit_register',
+ with_fields => {
+ title => 'Test Report',
+ detail => 'Test report details.',
+ photo => '',
+ email => 'test-2@example.com',
+ name => 'Joe Bloggs',
+ category => 'Street lighting',
+ }
+ },
+ "submit good details"
+ );
+ };
# find the report
my $report = $user->problems->first;
@@ -927,11 +957,22 @@ subtest "test report creation for a category that is non public" => sub {
$contact2->category( "Pothol\xc3\xa9s" );
$contact2->update;
-my $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=' . $saved_lat . '&longitude=' . $saved_lon );
+my $extra_details;
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=' . $saved_lat . '&longitude=' . $saved_lon );
+};
$mech->content_contains( "Pothol\xc3\xa9s" );
ok !$extra_details->{titles_list}, 'Non Bromley does not send back list of titles';
-$extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=51.4021&longitude=0.01578');
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=51.4021&longitude=0.01578');
+};
ok $extra_details->{titles_list}, 'Bromley sends back list of titles';
#### test uploading an image
@@ -940,18 +981,22 @@ ok $extra_details->{titles_list}, 'Bromley sends back list of titles';
#### possibly manual testing
# create report without using map
-# create report by clicking on may with javascript off
+# create report by clicking on map with javascript off
# create report with images off
subtest "check that a lat/lon off coast leads to /around" => sub {
my $off_coast_latitude = 50.78301;
my $off_coast_longitude = -0.646929;
- $mech->get_ok( #
- "/report/new"
- . "?latitude=$off_coast_latitude"
- . "&longitude=$off_coast_longitude"
- );
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok( #
+ "/report/new"
+ . "?latitude=$off_coast_latitude"
+ . "&longitude=$off_coast_longitude"
+ );
+ };
is $mech->uri->path, '/around', "redirected to '/around'";
@@ -1015,9 +1060,10 @@ for my $test (
)
{
subtest $test->{desc} => sub {
- if ( $test->{host} =~ /bromley/ && !FixMyStreet::Cobrand->exists('bromley') ) {
- plan skip_all => 'Skipping Bromley tests without Bromley cobrand';
- }
+ my $override = {
+ ALLOWED_COBRANDS => [ $test->{host} =~ /bromley/ ? 'bromley' : 'fixmystreet' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ };
$mech->host( $test->{host} );
@@ -1025,12 +1071,14 @@ for my $test (
$mech->clear_emails_ok;
$mech->get_ok('/');
- $mech->submit_form_ok( { with_fields => { pc => $test->{postcode}, } },
- "submit location" );
- $mech->follow_link_ok(
- { text_regex => qr/skip this step/i, },
- "follow 'skip this step' link"
- );
+ FixMyStreet::override_config $override, sub {
+ $mech->submit_form_ok( { with_fields => { pc => $test->{postcode}, } },
+ "submit location" );
+ $mech->follow_link_ok(
+ { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link"
+ );
+ };
my $fields = $mech->visible_form_values('mapSkippedForm');
if ( $test->{fms_extra_title} ) {
@@ -1072,8 +1120,10 @@ for my $test (
$submission_fields->{name} = 'Test User';
}
- $mech->submit_form_ok( { with_fields => $submission_fields },
- "submit good details" );
+ FixMyStreet::override_config $override, sub {
+ $mech->submit_form_ok( { with_fields => $submission_fields },
+ "submit good details" );
+ };
my $email = $mech->get_email;
ok $email, "got an email";
@@ -1128,18 +1178,23 @@ subtest 'user title not reset if no user title in submission' => sub {
};
$mech->get_ok('/');
- $mech->submit_form_ok( { with_fields => { pc => 'EH99 1SP', } },
- "submit location" );
- $mech->follow_link_ok(
- { text_regex => qr/skip this step/i, },
- "follow 'skip this step' link"
- );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => 'EH99 1SP', } },
+ "submit location" );
+ $mech->follow_link_ok(
+ { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link"
+ );
- my $fields = $mech->visible_form_values('mapSkippedForm');
- ok !exists( $fields->{fms_extra_title} ), 'user title field not displayed';
+ my $fields = $mech->visible_form_values('mapSkippedForm');
+ ok !exists( $fields->{fms_extra_title} ), 'user title field not displayed';
- $mech->submit_form_ok( { with_fields => $submission_fields },
- "submit good details" );
+ $mech->submit_form_ok( { with_fields => $submission_fields },
+ "submit good details" );
+ };
$user->discard_changes;
my $report = $user->problems->first;
@@ -1148,10 +1203,7 @@ subtest 'user title not reset if no user title in submission' => sub {
is $user->title, 'MR', 'User title unchanged';
};
-SKIP: {
- skip( "Need 'lichfielddc' in ALLOWED_COBRANDS config", 100 )
- unless FixMyStreet::Cobrand->exists('lichfielddc');
-
+subtest "test Lichfield" => sub {
for my $test (
{
desc => 'confirm link for cobrand council in two tier cobrand links to cobrand site',
@@ -1190,32 +1242,38 @@ SKIP: {
my $user = $mech->log_in_ok($test_email) if $test->{redirect};
- $mech->get_ok('/around');
- $mech->content_contains( "Lichfield District Council FixMyStreet" );
- $mech->submit_form_ok( { with_fields => { pc => 'WS13 7RD' } }, "submit location" );
- $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" );
- my %optional_fields = $test->{redirect} ? () :
- ( email => $test_email, phone => '07903 123 456' );
-
- # we do this as otherwise test::www::mechanize::catalyst
- # goes to the value set in ->host above irregardless and
- # that is a 404. It works but it is not pleasant.
- $mech->clear_host if $test->{redirect} && $test->{national};
- $mech->submit_form_ok(
- {
- button => $test->{button},
- with_fields => {
- title => 'Test Report',
- detail => 'Test report details.',
- photo => '',
- name => 'Joe Bloggs',
- may_show_name => '1',
- category => $test->{category},
- %optional_fields
- }
- },
- "submit good details"
- );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'lichfielddc', 'fixmystreet' ],
+ BASE_URL => 'http://www.fixmystreet.com',
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok('/around');
+ $mech->content_contains( "Lichfield District Council FixMyStreet" );
+ $mech->submit_form_ok( { with_fields => { pc => 'WS13 7RD' } }, "submit location" );
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" );
+ my %optional_fields = $test->{redirect} ? () :
+ ( email => $test_email, phone => '07903 123 456' );
+
+ # we do this as otherwise test::www::mechanize::catalyst
+ # goes to the value set in ->host above irregardless and
+ # that is a 404. It works but it is not pleasant.
+ $mech->clear_host if $test->{redirect} && $test->{national};
+ $mech->submit_form_ok(
+ {
+ button => $test->{button},
+ with_fields => {
+ title => 'Test Report',
+ detail => 'Test report details.',
+ photo => '',
+ name => 'Joe Bloggs',
+ may_show_name => '1',
+ category => $test->{category},
+ %optional_fields
+ }
+ },
+ "submit good details"
+ );
+ };
is_deeply $mech->page_errors, [], "check there were no errors";
# check that the user has been created/ not changed
@@ -1232,9 +1290,8 @@ SKIP: {
if ( $test->{redirect} ) {
is $mech->uri->path, "/report/" . $report->id, "redirected to report page";
- my $base = FixMyStreet->config('BASE_URL');
- $base =~ s{http://}{};
- $base = "lichfielddc.$base" unless $test->{national};
+ my $base = 'www.fixmystreet.com';
+ $base = "lichfielddc.fixmystreet.com" unless $test->{national};
is $mech->uri->host, $base, 'redirected to correct site';
} else {
# receive token
@@ -1246,21 +1303,34 @@ SKIP: {
ok $url, "extracted confirm url '$url'";
# confirm token
- $mech->get_ok($url);
-
- my $base = FixMyStreet->config('BASE_URL');
- $base =~ s{http://}{http://lichfielddc.} unless $test->{national};
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'lichfielddc', 'fixmystreet' ],
+ BASE_URL => 'http://www.fixmystreet.com',
+ }, sub {
+ $mech->get_ok($url);
+ };
+
+ my $base = 'www.fixmystreet.com';
+ $base = 'lichfielddc.fixmystreet.com' unless $test->{national};
$mech->content_contains( $base . '/report/' .
$report->id, 'confirm page links to correct site' );
if ( $test->{national} ) {
# Shouldn't be found, as it was a county problem
- is $mech->get( '/report/' . $report->id )->code, 404, "report not found";
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'lichfielddc', 'fixmystreet' ],
+ }, sub {
+ is $mech->get( '/report/' . $report->id )->code, 404, "report not found";
+ };
# But should be on the main site
$mech->host( 'www.fixmystreet.com' );
}
- $mech->get_ok( '/report/' . $report->id );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'lichfielddc', 'fixmystreet' ],
+ }, sub {
+ $mech->get_ok( '/report/' . $report->id );
+ };
}
$report->discard_changes;
@@ -1271,12 +1341,9 @@ SKIP: {
$mech->delete_user($user);
};
}
-}
-
-SKIP: {
- skip( "Need 'seesomething' in ALLOWED_COBRANDS config", 100 )
- unless FixMyStreet::Cobrand->exists('seesomething');
+};
+subtest "test SeeSomething" => sub {
$mech->host('seesomething.fixmystreet.com');
$mech->clear_emails_ok;
$mech->log_out_ok;
@@ -1346,22 +1413,27 @@ SKIP: {
}
$mech->get_ok( '/around' );
- $mech->submit_form_ok(
- {
- with_fields => {
- pc => $test->{pc},
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'seesomething' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ pc => $test->{pc},
+ },
},
- },
- 'submit around form',
- );
- $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" );
+ 'submit around form',
+ );
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" );
- $mech->submit_form_ok(
- {
- with_fields => $test->{fields},
- },
- 'Submit form details with no user details',
- );
+ $mech->submit_form_ok(
+ {
+ with_fields => $test->{fields},
+ },
+ 'Submit form details with no user details',
+ );
+ };
is_deeply $mech->page_errors, [], "check there were no errors";
$user =
@@ -1385,7 +1457,7 @@ SKIP: {
}
$bus_contact->delete;
-}
+};
$contact1->delete;
$contact2->delete;
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index ed26d58d5..4745d92cd 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -116,17 +116,22 @@ foreach my $test (
$mech->get_ok('/around');
# submit initial pc form
- $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
- "submit location" );
- is_deeply $mech->page_errors, [], "no errors for pc '$test->{pc}'";
-
- # click through to the report page
- $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
- "follow 'skip this step' link" );
-
- # submit the main form
- $mech->submit_form_ok( { with_fields => $test->{fields} },
- "submit form" );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
+ "submit location" );
+ is_deeply $mech->page_errors, [], "no errors for pc '$test->{pc}'";
+
+ # click through to the report page
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link" );
+
+ # submit the main form
+ $mech->submit_form_ok( { with_fields => $test->{fields} },
+ "submit form" );
+ };
# check that we got the errors expected
is_deeply $mech->page_errors, $test->{errors}, "check errors";
@@ -152,7 +157,12 @@ foreach my $test (
%{ $test->{fields} },
%{ $test->{submit_with} },
};
- $mech->submit_form_ok( { with_fields => $new_values } );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => $new_values } );
+ };
$user = FixMyStreet::App->model('DB::User')->find( { email => $test_email } );
ok $user, 'created user';
diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t
index 14a4b2150..42e69fd03 100644
--- a/t/app/controller/reports.t
+++ b/t/app/controller/reports.t
@@ -42,9 +42,13 @@ is $stats->{'City of Edinburgh Council'}->[2], 1, 'correct number of older repor
is $stats->{'Westminster City Council'}->[1], 5, 'correct number of reports for Westminster';
-$mech->follow_link_ok( { text_regex => qr/Birmingham/ } );
+FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ $mech->follow_link_ok( { text_regex => qr/Birmingham/ } );
+ $mech->get_ok('/reports/Westminster');
+};
-$mech->get_ok('/reports/Westminster');
$mech->title_like(qr/Westminster City Council/);
$mech->content_contains('Westminster City Council');
$mech->content_contains('All reports Test 3 for 2504', 'problem to be marked non public visible');
@@ -55,7 +59,11 @@ is scalar @$problems, 5, 'correct number of problems displayed';
my $private = $westminster_problems[2];
ok $private->update( { non_public => 1 } ), 'problem marked non public';
-$mech->get_ok('/reports/Westminster');
+FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ $mech->get_ok('/reports/Westminster');
+};
$problems = $mech->extract_problem_list;
is scalar @$problems, 4, 'only public problems are displayed';
@@ -65,24 +73,30 @@ $mech->get_ok('/reports');
$stats = $mech->extract_report_stats;
is $stats->{'Westminster City Council'}->[1], 5, 'non public reports included in stats';
-SKIP: {
- skip( "Need 'emptyhomes' in ALLOWED_COBRANDS config", 8 )
- unless FixMyStreet::Cobrand->exists('emptyhomes');
- ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
- $mech->get_ok('/reports');
- # EHA lacks one column the others have
- $mech->content_lacks('state unknown');
-
- skip( "Need 'fiksgatami' in ALLOWED_COBRANDS config", 8 )
- unless FixMyStreet::Cobrand->exists('fiksgatami');
- $mech->create_body_ok(3, 'Oslo');
- mySociety::MaPit::configure('http://mapit.nuug.no/');
- ok $mech->host("fiksgatami.no"), 'change host to fiksgatami';
- $mech->get_ok('/reports');
- # There should only be one Oslo
- $mech->content_contains('Oslo');
- $mech->content_unlike(qr{Oslo">Oslo.*Oslo}s);
-}
+subtest "test emptyhomes all reports page" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'emptyhomes' ],
+ }, sub {
+ ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
+ $mech->get_ok('/reports');
+ # EHA lacks one column the others have
+ $mech->content_lacks('state unknown');
+ };
+};
+
+subtest "test fiksgatami all reports page" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fiksgatami' ],
+ MAPIT_URL => 'http://mapit.nuug.no/',
+ }, sub {
+ $mech->create_body_ok(3, 'Oslo');
+ ok $mech->host("fiksgatami.no"), 'change host to fiksgatami';
+ $mech->get_ok('/reports');
+ # There should only be one Oslo
+ $mech->content_contains('Oslo');
+ $mech->content_unlike(qr{Oslo">Oslo.*Oslo}s);
+ }
+};
done_testing();
diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t
index ec6a01b50..bafa1ddc0 100644
--- a/t/app/controller/rss.t
+++ b/t/app/controller/rss.t
@@ -42,8 +42,13 @@ my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
user_id => $user1->id,
} );
-
-$mech->get_ok("/rss/pc/EH11BB/2");
+$mech->host('www.fixmystreet.com');
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ $mech->get_ok("/rss/pc/EH11BB/2");
+};
$mech->content_contains( "Testing, 10th October" );
$mech->content_lacks( 'Nearest road to the pin' );
@@ -111,7 +116,12 @@ $report->geocode(
);
$report->update();
-$mech->get_ok("/rss/pc/EH11BB/2");
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ $mech->get_ok("/rss/pc/EH11BB/2");
+};
$mech->content_contains( "Testing, 10th October" );
$mech->content_contains( '18 North Bridge, Edinburgh' );
@@ -168,11 +178,17 @@ my $report_to_county_council = FixMyStreet::App->model('DB::Problem')->find_or_c
subtest "check RSS feeds on cobrand have correct URLs for non-cobrand reports" => sub {
$mech->host('lichfielddc.fixmystreet.com');
- $mech->get_ok("/rss/area/Lichfield");
-
my $expected1 = mySociety::Config::get('BASE_URL') . '/report/' . $report_to_county_council->id;
- my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('lichfielddc')->new();
- my $expected2 = $cobrand->base_url . '/report/' . $report_to_council->id;
+ my $expected2;
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'lichfielddc' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok("/rss/area/Lichfield");
+ my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('lichfielddc')->new();
+ $expected2 = $cobrand->base_url . '/report/' . $report_to_council->id;
+ };
$mech->content_contains($expected1, 'non cobrand area report point to fixmystreet.com');
$mech->content_contains($expected2, 'cobrand area report point to cobrand url');
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index ba48300b2..62add01eb 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -185,7 +185,11 @@ subtest "correct text for title after URL" => sub {
parameter => $report->id,
}
)->delete;
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ };
my $email = $mech->get_email;
(my $title = $report->title) =~ s/ /\\s+/;
@@ -318,7 +322,11 @@ foreach my $test (
$report->geocode( $g );
$report->update();
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ };
my $email = $mech->get_email;
my $body = $email->body;
@@ -423,7 +431,11 @@ subtest "check alerts from cobrand send main site url for alerts for different c
}
)->delete;
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ };
my $email = $mech->get_email;
my $body = $email->body;
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index 9138c11a8..18c210f6f 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -497,7 +497,7 @@ foreach my $test ( {
dear => qr'Dear Staffordshire County Council,',
body => '2240',
cobrand => 'lichfielddc',
- url => '',
+ url => 'www.',
}, {
%common,
desc => 'directs NI correctly, 1',
@@ -526,8 +526,13 @@ foreach my $test ( {
},
) {
subtest $test->{ desc } => sub {
- if ( $test->{cobrand} && $test->{cobrand} =~ /lichfielddc/ && !FixMyStreet::Cobrand->exists('lichfielddc') ) {
- plan skip_all => 'Skipping Lichfield tests without Lichfield cobrand';
+ my $override = {
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ BASE_URL => 'http://www.fixmystreet.com',
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ };
+ if ( $test->{cobrand} && $test->{cobrand} =~ /lichfielddc/ ) {
+ $override->{ALLOWED_COBRANDS} = [ 'lichfielddc' ];
}
$mech->clear_emails_ok;
@@ -549,7 +554,9 @@ foreach my $test ( {
cobrand => $test->{ cobrand } || 'fixmystreet',
} );
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ FixMyStreet::override_config $override, sub {
+ FixMyStreet::App->model('DB::Problem')->send_reports();
+ };
$mech->email_count_is( $test->{ email_count } );
if ( $test->{ email_count } ) {
@@ -568,9 +575,8 @@ foreach my $test ( {
}
if ( $test->{url} ) {
- (my $base_url = FixMyStreet->config('BASE_URL')) =~ s{http://}{};
my $id = $problem->id;
- like $email->body, qr[$test->{url}$base_url/report/$id], 'URL present is correct';
+ like $email->body, qr[$test->{url}fixmystreet.com/report/$id], 'URL present is correct';
}
$problem->discard_changes;
diff --git a/t/app/uri_for.t b/t/app/uri_for.t
index bf965fb62..810aade62 100644
--- a/t/app/uri_for.t
+++ b/t/app/uri_for.t
@@ -44,25 +44,29 @@ is(
'FiksGataMi url with lat not zoom'
);
-SKIP: {
- skip( "Need 'emptyhomes' in ALLOWED_COBRANDS config", 2 )
- unless FixMyStreet::Cobrand->exists('emptyhomes');
-
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'emptyhomes' ],
+}, sub {
like(
$reh_en_c->uri_for_email( '/foo' ),
qr{^http://en.},
'adds en to retain language'
);
+};
- # instantiate this here otherwise sets locale to cy and breaks test
- # above
- my $reh_cy_c = ctx_request('http://cy.reportemptyhomes.com/');
+# instantiate this here otherwise sets locale to cy and breaks test
+# above
+my $reh_cy_c;
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'emptyhomes' ],
+}, sub {
+ $reh_cy_c = ctx_request('http://cy.reportemptyhomes.com/');
like(
$reh_cy_c->uri_for_email( '/foo' ),
qr{^http://cy.},
'retains language'
);
-}
+};
done_testing();
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index cb2086a84..91a7038ec 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -2,9 +2,6 @@ use strict;
use warnings;
use Test::More;
-plan skip_all => 'Skipping Bromley test without Bromley cobrand'
- unless FixMyStreet::Cobrand->exists('bromley');
-
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
diff --git a/t/cobrand/councils.t b/t/cobrand/councils.t
index 8fb10cfbe..0cf25ebdf 100644
--- a/t/cobrand/councils.t
+++ b/t/cobrand/councils.t
@@ -6,13 +6,13 @@ use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
foreach my $council (qw/southampton reading bromley/) {
- SKIP: {
- skip( "Need '$council' in ALLOWED_COBRANDS config", 3 )
- unless FixMyStreet::Cobrand->exists($council);
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ $council ],
+ }, sub {
ok $mech->host("$council.fixmystreet.com"), "change host to $council";
$mech->get_ok('/');
- $mech->content_like( qr/$council/i );
- }
+ $mech->content_like( qr/\u$council/ );
+ };
}
done_testing();
diff --git a/t/cobrand/fixmybarangay.t b/t/cobrand/fixmybarangay.t
index 2d9276dc0..b996fa0a6 100644
--- a/t/cobrand/fixmybarangay.t
+++ b/t/cobrand/fixmybarangay.t
@@ -2,9 +2,6 @@ use strict;
use warnings;
use Test::More;
-plan skip_all => 'Skipping FixMyBarangay test without FixMyBarangay cobrand'
- unless FixMyStreet::Cobrand->exists('fixmybarangay');
-
BEGIN {
use FixMyStreet;
FixMyStreet->test_mode(1);
@@ -16,7 +13,11 @@ my $mech = FixMyStreet::TestMech->new;
# Front page test
ok $mech->host("www.fixmybarangay.com"), "change host to FixMyBarangay";
-$mech->get_ok('/');
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmybarangay' ],
+}, sub {
+ $mech->get_ok('/');
+};
$mech->content_like( qr/FixMyBarangay/ );
# Set up bodies
@@ -115,7 +116,11 @@ is $luz_report->state, 'confirmed', 'should be confirmed';
$user = $mech->log_in_ok($fmb_test_email);
-$mech->get_ok( '/report/' . $luz_report->id );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmybarangay' ],
+}, sub {
+ $mech->get_ok( '/report/' . $luz_report->id );
+};
$mech->content_contains( "Remove from site" );
$mech->content_lacks( "Report abuse" );
diff --git a/t/cobrand/get_body_sender.t b/t/cobrand/get_body_sender.t
index 245cb1a13..964f5c0e4 100644
--- a/t/cobrand/get_body_sender.t
+++ b/t/cobrand/get_body_sender.t
@@ -21,10 +21,15 @@ my $body = FixMyStreet::App->model('DB::Body')->find_or_create({
});
my $body_area = $body->body_areas->find_or_create({ area_id => 1000 });
-is_deeply $c->get_body_sender( $body ), { method => 'Email' }, 'defaults to email';
-
-$body_area->update({ area_id => 2481 }); # Croydon LBO
-is_deeply $c->get_body_sender( $body ), { method => 'London' }, 'returns london report it if London borough';
+FixMyStreet::override_config {
+ MAPIT_TYPES => [ 'LBO' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ is_deeply $c->get_body_sender( $body ), { method => 'Email' }, 'defaults to email';
+
+ $body_area->update({ area_id => 2481 }); # Croydon LBO
+ is_deeply $c->get_body_sender( $body ), { method => 'London' }, 'returns london report it if London borough';
+};
$body->send_method( 'TestMethod' );
is $c->get_body_sender( $body )->{ method }, 'TestMethod', 'uses send_method in preference to London';
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 5b20f50e5..b1f3955be 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -7,16 +7,6 @@ use DateTime;
use Test::More;
use JSON;
-plan skip_all => 'Skipping Zurich test without Zurich cobrand'
- unless FixMyStreet::Cobrand->exists('zurich');
-
-# To run this test ensure that you have the following in general.yml:
-#
-# BASE_URL: 'http://zurich.127.0.0.1.xip.io'
-#
-# ALLOWED_COBRANDS:
-# - zurich
-#
# Check that you have the required locale installed - the following
# should return a line with de_CH.utf8 in. If not install that locale.
#
@@ -42,7 +32,11 @@ my $mech = FixMyStreet::TestMech->new;
# Front page test
ok $mech->host("zurich.example.com"), "change host to Zurich";
-$mech->get_ok('/');
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok('/');
+};
$mech->content_like( qr/zurich/i );
# Set up bodies
@@ -71,22 +65,30 @@ my @reports = $mech->create_problems_for_body( 1, 2, 'Test', {
});
my $report = $reports[0];
-$mech->get_ok( '/report/' . $report->id );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/report/' . $report->id );
+};
$mech->content_contains('&Uuml;berpr&uuml;fung ausstehend');
# Check logging in to deal with this report
-$mech->get_ok( '/admin' );
-is $mech->uri->path, '/auth', "got sent to the sign in page";
-
-my $user = $mech->log_in_ok( 'dm1@example.org') ;
-$user->from_body( undef );
-$user->update;
-$mech->get_ok( '/admin' );
-is $mech->uri->path, '/my', "got sent to /my";
-$user->from_body( 2 );
-$user->update;
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/admin' );
+ is $mech->uri->path, '/auth', "got sent to the sign in page";
+
+ my $user = $mech->log_in_ok( 'dm1@example.org') ;
+ $user->from_body( undef );
+ $user->update;
+ $mech->get_ok( '/admin' );
+ is $mech->uri->path, '/my', "got sent to /my";
+ $user->from_body( 2 );
+ $user->update;
-$mech->get_ok( '/admin' );
+ $mech->get_ok( '/admin' );
+};
is $mech->uri->path, '/admin', "am logged in";
$mech->content_contains( 'report_edit/' . $report->id );
@@ -119,8 +121,12 @@ subtest "changing of categories" => sub {
ok ( !$comments_rs->first, "There are no comments yet" );
# change the category via the web interface
- $mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->submit_form_ok( { with_fields => { category => 'Cat2' } } );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ }, sub {
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->submit_form_ok( { with_fields => { category => 'Cat2' } } );
+ };
# check changes correctly saved
$report->discard_changes();
@@ -135,39 +141,47 @@ subtest "changing of categories" => sub {
};
-$mech->get_ok( '/admin/report_edit/' . $report->id );
-$mech->content_contains( 'Unbest&auml;tigt' ); # Unconfirmed email
-$mech->submit_form_ok( { with_fields => { state => 'confirmed' } } );
-$mech->get_ok( '/report/' . $report->id );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->content_contains( 'Unbest&auml;tigt' ); # Unconfirmed email
+ $mech->submit_form_ok( { with_fields => { state => 'confirmed' } } );
+ $mech->get_ok( '/report/' . $report->id );
+};
$mech->content_contains('Aufgenommen');
$mech->content_contains('Test Test');
$mech->content_lacks('photo/' . $report->id . '.jpeg');
$mech->email_count_is(0);
-# Photo publishing
-$mech->get_ok( '/admin/report_edit/' . $report->id );
-$mech->submit_form_ok( { with_fields => { publish_photo => 1 } } );
-$mech->get_ok( '/report/' . $report->id );
-$mech->content_contains('photo/' . $report->id . '.jpeg');
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ # Photo publishing
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->submit_form_ok( { with_fields => { publish_photo => 1 } } );
+ $mech->get_ok( '/report/' . $report->id );
+ $mech->content_contains('photo/' . $report->id . '.jpeg');
-# Internal notes
-$mech->get_ok( '/admin/report_edit/' . $report->id );
-$mech->submit_form_ok( { with_fields => { new_internal_note => 'Initial internal note.' } } );
-$mech->submit_form_ok( { with_fields => { new_internal_note => 'Another internal note.' } } );
-$mech->content_contains( 'Initial internal note.' );
-$mech->content_contains( 'Another internal note.' );
+ # Internal notes
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->submit_form_ok( { with_fields => { new_internal_note => 'Initial internal note.' } } );
+ $mech->submit_form_ok( { with_fields => { new_internal_note => 'Another internal note.' } } );
+ $mech->content_contains( 'Initial internal note.' );
+ $mech->content_contains( 'Another internal note.' );
-# Original description
-$mech->submit_form_ok( { with_fields => { detail => 'Edited details text.' } } );
-$mech->content_contains( 'Edited details text.' );
-$mech->content_contains( 'Originaltext: &ldquo;Test Test 1 for 2 Detail&rdquo;' );
+ # Original description
+ $mech->submit_form_ok( { with_fields => { detail => 'Edited details text.' } } );
+ $mech->content_contains( 'Edited details text.' );
+ $mech->content_contains( 'Originaltext: &ldquo;Test Test 1 for 2 Detail&rdquo;' );
-$mech->get_ok( '/admin/report_edit/' . $report->id );
-$mech->submit_form_ok( { with_fields => { body_subdivision => 3, send_rejected_email => 1 } } );
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->submit_form_ok( { with_fields => { body_subdivision => 3, send_rejected_email => 1 } } );
-$mech->get_ok( '/report/' . $report->id );
-$mech->content_contains('In Bearbeitung');
-$mech->content_contains('Test Test');
+ $mech->get_ok( '/report/' . $report->id );
+ $mech->content_contains('In Bearbeitung');
+ $mech->content_contains('Test Test');
+};
send_reports_for_zurich();
my $email = $mech->get_email;
@@ -177,33 +191,45 @@ $mech->clear_emails_ok;
$mech->log_out_ok;
-$user = $mech->log_in_ok( 'sdm1@example.org') ;
+my $user = $mech->log_in_ok( 'sdm1@example.org') ;
$user->update({ from_body => undef });
-$mech->get_ok( '/admin' );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/admin' );
+};
is $mech->uri->path, '/my', "got sent to /my";
$user->from_body( 3 );
$user->update;
-$mech->get_ok( '/admin' );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/admin' );
+};
is $mech->uri->path, '/admin', "am logged in";
$mech->content_contains( 'report_edit/' . $report->id );
$mech->content_contains( DateTime->now->strftime("%d.%m.%Y") );
$mech->content_contains( 'In Bearbeitung' );
-$mech->get_ok( '/admin/report_edit/' . $report->id );
-$mech->content_contains( 'Initial internal note' );
-
-$mech->submit_form_ok( { with_fields => { status_update => 'This is an update.' } } );
-is $mech->uri->path, '/admin/report_edit/' . $report->id, "still on edit page";
-$mech->content_contains('This is an update');
-ok $mech->form_with_fields( 'status_update' );
-$mech->submit_form_ok( { button => 'no_more_updates' } );
-is $mech->uri->path, '/admin/summary', "redirected now finished with report.";
-
-$mech->get_ok( '/report/' . $report->id );
-$mech->content_contains('In Bearbeitung');
-$mech->content_contains('Test Test');
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->content_contains( 'Initial internal note' );
+
+ $mech->submit_form_ok( { with_fields => { status_update => 'This is an update.' } } );
+ is $mech->uri->path, '/admin/report_edit/' . $report->id, "still on edit page";
+ $mech->content_contains('This is an update');
+ ok $mech->form_with_fields( 'status_update' );
+ $mech->submit_form_ok( { button => 'no_more_updates' } );
+ is $mech->uri->path, '/admin/summary', "redirected now finished with report.";
+
+ $mech->get_ok( '/report/' . $report->id );
+ $mech->content_contains('In Bearbeitung');
+ $mech->content_contains('Test Test');
+};
send_reports_for_zurich();
$email = $mech->get_email;
@@ -216,7 +242,11 @@ is $report->state, 'planned', 'Report now in planned state';
$mech->log_out_ok;
$user = $mech->log_in_ok( 'dm1@example.org') ;
-$mech->get_ok( '/admin' );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/admin' );
+};
$mech->content_contains( 'report_edit/' . $report->id );
$mech->content_contains( DateTime->now->strftime("%d.%m.%Y") );
@@ -227,13 +257,17 @@ $extra->{email_confirmed} = 1;
$report->extra ( { %$extra } );
$report->update;
-$mech->get_ok( '/admin/report_edit/' . $report->id );
-$mech->content_lacks( 'Unbest&auml;tigt' ); # Confirmed email
-$mech->submit_form_ok( { with_fields => { status_update => 'FINAL UPDATE' } } );
-$mech->form_with_fields( 'status_update' );
-$mech->submit_form_ok( { button => 'publish_response' } );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->content_lacks( 'Unbest&auml;tigt' ); # Confirmed email
+ $mech->submit_form_ok( { with_fields => { status_update => 'FINAL UPDATE' } } );
+ $mech->form_with_fields( 'status_update' );
+ $mech->submit_form_ok( { button => 'publish_response' } );
-$mech->get_ok( '/report/' . $report->id );
+ $mech->get_ok( '/report/' . $report->id );
+};
$mech->content_contains('Beantwortet');
$mech->content_contains('Test Test');
$mech->content_contains('FINAL UPDATE');
@@ -254,15 +288,23 @@ $report = $reports[0];
$mech->get_ok( '/admin/report_edit/' . $report->id );
$mech->submit_form_ok( { with_fields => { state => 'planned' } } );
-$mech->get_ok( '/report/' . $report->id );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/report/' . $report->id );
+};
$mech->content_contains('In Bearbeitung');
$mech->content_contains('Second Test');
-$mech->get_ok( '/admin/report_edit/' . $report->id );
-$mech->content_contains( 'Unbest&auml;tigt' );
-$mech->submit_form_ok( { button => 'publish_response', with_fields => { status_update => 'FINAL UPDATE' } } );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->content_contains( 'Unbest&auml;tigt' );
+ $mech->submit_form_ok( { button => 'publish_response', with_fields => { status_update => 'FINAL UPDATE' } } );
-$mech->get_ok( '/report/' . $report->id );
+ $mech->get_ok( '/report/' . $report->id );
+};
$mech->content_contains('Beantwortet');
$mech->content_contains('Second Test');
$mech->content_contains('FINAL UPDATE');
@@ -278,9 +320,13 @@ $mech->email_count_is(0);
});
$report = $reports[0];
-$mech->get_ok( '/admin/report_edit/' . $report->id );
-$mech->submit_form_ok( { with_fields => { body_external => 4 } } );
-$mech->get_ok( '/report/' . $report->id );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->submit_form_ok( { with_fields => { body_external => 4 } } );
+ $mech->get_ok( '/report/' . $report->id );
+};
$mech->content_contains('Beantwortet');
$mech->content_contains('Third Test');
$mech->content_contains('Wir haben Ihr Anliegen an External Body weitergeleitet');
@@ -293,13 +339,17 @@ unlike $email->body, qr/test\@example.com/, 'body does not contain email address
$mech->clear_emails_ok;
# Test calling back, and third_personal boolean setting
-$mech->get_ok( '/admin' );
-is $mech->uri->path, '/admin', "am logged in";
-$mech->content_contains( 'report_edit/' . $report->id );
-$mech->get_ok( '/admin/report_edit/' . $report->id );
-$mech->submit_form_ok( { with_fields => { state => 'unconfirmed' } } );
-$mech->submit_form_ok( { with_fields => { body_external => 4, third_personal => 1 } } );
-$mech->get_ok( '/report/' . $report->id );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+}, sub {
+ $mech->get_ok( '/admin' );
+ is $mech->uri->path, '/admin', "am logged in";
+ $mech->content_contains( 'report_edit/' . $report->id );
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->submit_form_ok( { with_fields => { state => 'unconfirmed' } } );
+ $mech->submit_form_ok( { with_fields => { body_external => 4, third_personal => 1 } } );
+ $mech->get_ok( '/report/' . $report->id );
+};
$mech->content_contains('Beantwortet');
$mech->content_contains('Third Test');
$mech->content_contains('Wir haben Ihr Anliegen an External Body weitergeleitet');
@@ -314,14 +364,23 @@ $mech->log_out_ok;
subtest "only superuser can edit bodies" => sub {
$user = $mech->log_in_ok( 'dm1@example.org' );
- $mech->get( '/admin/body/' . $zurich->id );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ }, sub {
+ $mech->get( '/admin/body/' . $zurich->id );
+ };
is $mech->res->code, 404, "only superuser should be able to edit bodies";
$mech->log_out_ok;
};
subtest "only superuser can see 'Add body' form" => sub {
$user = $mech->log_in_ok( 'dm1@example.org' );
- $mech->get_ok( '/admin/bodies' );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok( '/admin/bodies' );
+ };
$mech->content_lacks( '<form method="post" action="bodies"' );
$mech->log_out_ok;
};
@@ -330,6 +389,7 @@ subtest "phone number is mandatory" => sub {
FixMyStreet::override_config {
MAPIT_TYPES => [ 'O08' ],
MAPIT_URL => 'http://global.mapit.mysociety.org/',
+ ALLOWED_COBRANDS => [ 'zurich' ],
}, sub {
$user = $mech->log_in_ok( 'dm1@example.org' );
$mech->get_ok( '/report/new?lat=47.381817&lon=8.529156' );
@@ -367,10 +427,15 @@ subtest "problems can't be assigned to deleted bodies" => sub {
$user->update;
$report->state( 'confirmed' );
$report->update;
- $mech->get_ok( '/admin/body/' . $external_body->id );
- $mech->submit_form_ok( { with_fields => { deleted => 1 } } );
- $mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->content_lacks( $external_body->name );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok( '/admin/body/' . $external_body->id );
+ $mech->submit_form_ok( { with_fields => { deleted => 1 } } );
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->content_lacks( $external_body->name );
+ };
$user->from_body( 2 );
$user->update;
$mech->log_out_ok;
@@ -382,15 +447,19 @@ subtest "hidden report email are only sent when requested" => sub {
$extra->{email_confirmed} = 1;
$report->extra ( { %$extra } );
$report->update;
- $mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->submit_form_ok( { with_fields => { state => 'hidden', send_rejected_email => 1 } } );
- $mech->email_count_is(1);
- $mech->clear_emails_ok;
- $mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->submit_form_ok( { with_fields => { state => 'hidden', send_rejected_email => undef } } );
- $mech->email_count_is(0);
- $mech->clear_emails_ok;
- $mech->log_out_ok;
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ }, sub {
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->submit_form_ok( { with_fields => { state => 'hidden', send_rejected_email => 1 } } );
+ $mech->email_count_is(1);
+ $mech->clear_emails_ok;
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->submit_form_ok( { with_fields => { state => 'hidden', send_rejected_email => undef } } );
+ $mech->email_count_is(0);
+ $mech->clear_emails_ok;
+ $mech->log_out_ok;
+ };
};
$mech->delete_problems_for_body( 2 );