aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/questionnaire.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-05-16 15:47:42 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-05-16 15:47:42 +0100
commit23aa50cd6e1fb77de2d1e3ae8d29a8f8408a7930 (patch)
tree511442f4c72e6d0968171631a0f0305893ac0a53 /t/app/controller/questionnaire.t
parenta48756f51e0199bf09ce7cbd66c2fcd80acb05ad (diff)
Fixes and improvements for tests.
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();