aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/questionnaire.t
diff options
context:
space:
mode:
authorDave Whiteland <dave@mysociety.org>2012-05-29 15:57:41 +0100
committerDave Whiteland <dave@mysociety.org>2012-05-29 15:57:41 +0100
commit67da8efc720d2d0bd22bd9fe8655b7e983b35bb4 (patch)
tree38b8570647124df06c637d4b923f6010211ef328 /t/app/controller/questionnaire.t
parent40b3a51d33caefa8f5fb97ce9be18ef936c7e260 (diff)
parent131ff6e9bf3626d6a8fff6ae54669d250148a63a (diff)
Merge remote branch 'origin/master' into fmb-read-only
Conflicts: bin/send-reports perllib/FixMyStreet/Cobrand/Default.pm perllib/FixMyStreet/Cobrand/FixMyStreet.pm templates/web/fixmystreet/alert/index.html templates/web/fixmystreet/around/display_location.html web/cobrands/fixmystreet/_layout.scss web/js/map-OpenLayers.js
Diffstat (limited to 't/app/controller/questionnaire.t')
-rw-r--r--t/app/controller/questionnaire.t132
1 files changed, 72 insertions, 60 deletions
diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t
index 0e2a71184..2d4fdb711 100644
--- a/t/app/controller/questionnaire.t
+++ b/t/app/controller/questionnaire.t
@@ -322,67 +322,79 @@ for my $test (
};
}
-# EHA extra checking
-ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
-
-# Reset, and all the questionaire sending function - FIXME should it detect site itself somehow?
-$report->send_questionnaire( 1 );
-$report->update;
-$questionnaire->delete;
-FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( {
- site => 'emptyhomes'
-} );
-$email = $mech->get_email;
-ok $email, "got an email";
-$mech->clear_emails_ok;
-
-like $email->body, qr/fill in this short questionnaire/i, "got questionnaire email";
-($token) = $email->body =~ m{http://.*?/Q/(\S+)};
-ok $token, "extracted questionnaire token '$token'";
-
-$mech->get_ok("/Q/" . $token);
-$mech->content_contains( 'should have reported what they have done' );
-
-# Test already answered the ever reported question, so not shown again
-$dt = $dt->add( weeks => 4 );
-my $questionnaire2 = FixMyStreet::App->model('DB::Questionnaire')->find_or_create(
- {
- problem_id => $report->id,
- whensent => $dt->ymd . ' ' . $dt->hms,
- ever_reported => 1,
- }
-);
-ok $questionnaire2, 'added another questionnaire';
-ok $mech->host("fixmystreet.com"), 'change host to fixmystreet';
-$mech->get_ok("/Q/" . $token);
-$mech->title_like( qr/Questionnaire/ );
-$mech->content_contains( 'Has this problem been fixed?' );
-$mech->content_lacks( 'ever reported' );
-
-# EHA extra checking
-ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
-$mech->get_ok("/Q/" . $token);
-$mech->content_contains( 'made a lot of progress' );
-
-$token = FixMyStreet::App->model("DB::Token")->find( { scope => 'questionnaire', token => $token } );
-ok $token, 'found token for questionnaire';
-$questionnaire = FixMyStreet::App->model('DB::Questionnaire')->find( { id => $token->data } );
-ok $questionnaire, 'found questionnaire';
-
-# I18N Unicode extra testing using FiksGataMi
-$report->send_questionnaire( 1 );
-$report->cobrand( 'fiksgatami' );
-$report->update;
-$questionnaire->delete;
-$questionnaire2->delete;
-FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( { site => 'fixmystreet' } ); # It's either fixmystreet or emptyhomes
-$email = $mech->get_email;
-ok $email, "got an email";
-$mech->clear_emails_ok;
+SKIP: {
+ skip( "Need 'emptyhomes' in ALLOWED_COBRANDS config", 18 )
+ unless FixMyStreet::Cobrand->exists('emptyhomes');
+
+ # EHA extra checking
+ ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
+
+ # Reset, and all the questionaire sending function - FIXME should it detect site itself somehow?
+ $report->send_questionnaire( 1 );
+ $report->update;
+ $questionnaire->delete;
+
+ FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( {
+ site => 'emptyhomes'
+ } );
+ $email = $mech->get_email;
+ ok $email, "got an email";
+ $mech->clear_emails_ok;
+
+ like $email->body, qr/fill in this short questionnaire/i, "got questionnaire email";
+ ($token) = $email->body =~ m{http://.*?/Q/(\S+)};
+ ok $token, "extracted questionnaire token '$token'";
+
+ $mech->get_ok("/Q/" . $token);
+ $mech->content_contains( 'should have reported what they have done' );
+
+ # Test already answered the ever reported question, so not shown again
+ $dt = $dt->add( weeks => 4 );
+ my $questionnaire2 = FixMyStreet::App->model('DB::Questionnaire')->find_or_create(
+ {
+ problem_id => $report->id,
+ whensent => $dt->ymd . ' ' . $dt->hms,
+ ever_reported => 1,
+ }
+ );
+ ok $questionnaire2, 'added another questionnaire';
+ ok $mech->host("fixmystreet.com"), 'change host to fixmystreet';
+ $mech->get_ok("/Q/" . $token);
+ $mech->title_like( qr/Questionnaire/ );
+ $mech->content_contains( 'Has this problem been fixed?' );
+ $mech->content_lacks( 'ever reported' );
+
+ # EHA extra checking
+ ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
+ $mech->get_ok("/Q/" . $token);
+ $mech->content_contains( 'made a lot of progress' );
+
+ $token = FixMyStreet::App->model("DB::Token")->find( { scope => 'questionnaire', token => $token } );
+ ok $token, 'found token for questionnaire';
+ $questionnaire = FixMyStreet::App->model('DB::Questionnaire')->find( { id => $token->data } );
+ ok $questionnaire, 'found questionnaire';
+
+ $questionnaire2->delete;
+}
-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';
+SKIP: {
+ skip( "Need 'fiksgatami' in ALLOWED_COBRANDS config", 5 )
+ unless FixMyStreet::Cobrand->exists('fiksgatami');
+
+ # I18N Unicode extra testing using FiksGataMi
+ $report->send_questionnaire( 1 );
+ $report->cobrand( 'fiksgatami' );
+ $report->update;
+ $questionnaire->delete;
+ FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( { site => 'fixmystreet' } ); # It's either fixmystreet or emptyhomes
+ $email = $mech->get_email;
+ ok $email, "got an email";
+ $mech->clear_emails_ok;
+
+ 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();