aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
Diffstat (limited to 't/cobrand')
-rw-r--r--t/cobrand/bromley.t6
-rw-r--r--t/cobrand/closest.t6
-rw-r--r--t/cobrand/fixamingata.t18
-rw-r--r--t/cobrand/fixmybarangay.t17
-rw-r--r--t/cobrand/form_extras.t73
-rw-r--r--t/cobrand/form_extras/templates/report/new/after_photo.html12
-rw-r--r--t/cobrand/get_body_sender.t8
-rw-r--r--t/cobrand/restriction.t55
-rw-r--r--t/cobrand/seesomething.t5
-rw-r--r--t/cobrand/two_tier.t4
-rw-r--r--t/cobrand/zurich.t56
-rw-r--r--t/cobrand/zurich_attachments.txt8
12 files changed, 210 insertions, 58 deletions
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index fdded5606..1f61cd3de 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -21,7 +21,7 @@ my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', {
my $report = $reports[0];
for my $update ('in progress', 'unable to fix') {
- FixMyStreet::App->model('DB::Comment')->find_or_create( {
+ FixMyStreet::DB->resultset('Comment')->find_or_create( {
problem_state => $update,
problem_id => $report->id,
user_id => $user->id,
@@ -48,7 +48,7 @@ subtest 'testing special Open311 behaviour', sub {
FixMyStreet::override_config {
SEND_REPORTS_ON_STAGING => 1,
}, sub {
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ FixMyStreet::DB->resultset('Problem')->send_reports();
};
$report->discard_changes;
ok $report->whensent, 'Report marked as sent';
@@ -58,5 +58,5 @@ subtest 'testing special Open311 behaviour', sub {
# Clean up
$mech->delete_user($user);
-$mech->delete_problems_for_body( $body->id );
+$mech->delete_body($body);
done_testing();
diff --git a/t/cobrand/closest.t b/t/cobrand/closest.t
index d06f7e9a0..43b36f608 100644
--- a/t/cobrand/closest.t
+++ b/t/cobrand/closest.t
@@ -4,7 +4,7 @@ use warnings;
use Test::More;
use mySociety::Locale;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
@@ -16,7 +16,7 @@ mySociety::Locale::gettext_domain( 'FixMyStreet' );
my $c = FixMyStreet::Cobrand::UK->new();
my $user =
- FixMyStreet::App->model('DB::User')
+ FixMyStreet::DB->resultset('User')
->find_or_create( { email => 'test@example.com', name => 'Test User' } );
ok $user, "created test user";
@@ -29,7 +29,7 @@ my $dt = DateTime->new(
second => 23
);
-my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
+my $report = FixMyStreet::DB->resultset('Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
bodies_str => '2504',
diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t
index d181d3890..50b7713d1 100644
--- a/t/cobrand/fixamingata.t
+++ b/t/cobrand/fixamingata.t
@@ -8,7 +8,7 @@ BEGIN {
FixMyStreet->test_mode(1);
}
-use t::MapIt;
+use t::Mock::MapIt;
use mySociety::Locale;
use FixMyStreet::TestMech;
@@ -43,7 +43,7 @@ $mech->email_count_is(0);
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixamingata' ],
}, sub {
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ FixMyStreet::DB->resultset('Problem')->send_reports();
};
my $email = $mech->get_email;
like $email->header('Content-Type'), qr/iso-8859-1/, 'encoding looks okay';
@@ -53,16 +53,16 @@ like $email->body, qr/V=E4nligen,/, 'signature looks correct';
$mech->clear_emails_ok;
my $user =
- FixMyStreet::App->model('DB::User')
+ FixMyStreet::DB->resultset('User')
->find_or_create( { email => 'test@example.com', name => 'Test User' } );
ok $user, "created test user";
my $user2 =
- FixMyStreet::App->model('DB::User')
+ FixMyStreet::DB->resultset('User')
->find_or_create( { email => 'commenter@example.com', name => 'Commenter' } );
ok $user2, "created comment user";
-my $comment = FixMyStreet::App->model('DB::Comment')->find_or_create({
+my $comment = FixMyStreet::DB->resultset('Comment')->find_or_create({
problem_id => $report->id,
user_id => $user2->id,
name => 'Other User',
@@ -74,7 +74,7 @@ my $comment = FixMyStreet::App->model('DB::Comment')->find_or_create({
$comment->confirmed( \"current_timestamp - '3 days'::interval" );
$comment->update;
-my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create({
+my $alert = FixMyStreet::DB->resultset('Alert')->find_or_create({
user => $user,
parameter => $report->id,
alert_type => 'new_updates',
@@ -86,7 +86,7 @@ my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create({
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixamingata' ],
}, sub {
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
$mech->email_count_is(1);
@@ -102,7 +102,7 @@ subtest "Test ajax decimal points" => sub {
# A note to the future - the run_if_script line must be within a subtest
# otherwise it fails to work
- LWP::Protocol::PSGI->register(t::MapIt->run_if_script, host => 'mapit.sweden');
+ LWP::Protocol::PSGI->register(t::Mock::MapIt->run_if_script, host => 'mapit.sweden');
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixamingata' ],
@@ -115,7 +115,7 @@ subtest "Test ajax decimal points" => sub {
};
END {
- $mech->delete_problems_for_body(1);
+ $mech->delete_body($body);
ok $mech->host("www.fixmystreet.com"), "change host back";
done_testing();
}
diff --git a/t/cobrand/fixmybarangay.t b/t/cobrand/fixmybarangay.t
index 316739dfa..2f99b8c1e 100644
--- a/t/cobrand/fixmybarangay.t
+++ b/t/cobrand/fixmybarangay.t
@@ -30,8 +30,8 @@ $bsn->update( { send_method => 'Email' } );
my $dps = $mech->create_body_ok( 3, 'DPS', id => 3 );
$dps->update( { send_method => 'Open311', endpoint => 'http://dps.endpoint.example.com', jurisdiction => 'FMB', api_key => 'test' } );
-FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 1, body_id => $dps->id });
-FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 2, body_id => $dps->id });
+FixMyStreet::DB->resultset('BodyArea')->find_or_create({ area_id => 1, body_id => $dps->id });
+FixMyStreet::DB->resultset('BodyArea')->find_or_create({ area_id => 2, body_id => $dps->id });
# Create contacts for these bodies
# TODO: log in as a Bgy user, and create a report using the front end,
@@ -72,7 +72,7 @@ $mech->email_count_is(0);
FixMyStreet::override_config {
SEND_REPORTS_ON_STAGING => 1,
}, sub {
- FixMyStreet::App->model('DB::Problem')->send_reports('fixmybarangay');
+ FixMyStreet::DB->resultset('Problem')->send_reports('fixmybarangay');
};
# Check BGY one sent by email
@@ -89,10 +89,10 @@ is $dps_report->send_method_used, 'Open311', 'DPS report sent via Open311';
is $dps_report->external_id, 248, 'DPS report has right external ID';
my $fmb_test_email = 'luz_test_user@example.com';
-my $user = FixMyStreet::App->model('DB::User')->find_or_create( { email => $fmb_test_email, from_body => $luz->id, password => 'fmbsecret' } );
+my $user = FixMyStreet::DB->resultset('User')->find_or_create( { email => $fmb_test_email, from_body => $luz->id, password => 'fmbsecret' } );
ok $user, "test user does exist";
-my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create({
+my $alert = FixMyStreet::DB->resultset('Alert')->find_or_create({
user => $user,
parameter => '-0.142497580865087',
parameter2 => '51.5016605453401',
@@ -105,7 +105,7 @@ my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create({
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixmybarangay' ],
}, sub {
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
$mech->email_count_is(1);
@@ -141,8 +141,9 @@ is $luz_report->state, 'hidden', 'should be hidden';
$mech->delete_user($fmb_test_email);
-$mech->delete_problems_for_body( $luz->id );
-$mech->delete_problems_for_body( $dps->id );
+$mech->delete_body($luz);
+$mech->delete_body($bsn);
+$mech->delete_body($dps);
ok $mech->host("www.fixmystreet.com"), "change host back";
diff --git a/t/cobrand/form_extras.t b/t/cobrand/form_extras.t
new file mode 100644
index 000000000..9c20b7ad4
--- /dev/null
+++ b/t/cobrand/form_extras.t
@@ -0,0 +1,73 @@
+use strict;
+use warnings;
+
+package FixMyStreet::Cobrand::Tester;
+use parent 'FixMyStreet::Cobrand::FixMyStreet';
+
+sub report_form_extras {
+ ( { name => 'address', required => 1 }, { name => 'passport', required => 0 } )
+}
+
+# To allow a testing template override
+sub path_to_web_templates {
+ my $self = shift;
+ return [
+ FixMyStreet->path_to( 't/cobrand/form_extras/templates' )->stringify,
+ FixMyStreet->path_to( 'templates/web/fixmystreet' )->stringify
+ ];
+}
+
+package main;
+
+use Test::More;
+use FixMyStreet::TestMech;
+
+# disable info logs for this test run
+FixMyStreet::App->log->disable('info');
+END { FixMyStreet::App->log->enable('info'); }
+
+my $mech = FixMyStreet::TestMech->new;
+
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { tester => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ $mech->get_ok('/around');
+ $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } }, "submit location" );
+ $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.',
+ name => 'Joe Bloggs',
+ may_show_name => '1',
+ email => 'test-1@example.com',
+ passport => '123456',
+ password_register => '',
+ }
+ },
+ "submit details without address, with passport",
+ );
+ $mech->content_like(qr{<label for="form_address">Address</label>\s*<p class='form-error'>This information is required</p>}, 'Address is required');
+ $mech->content_contains('value="123456" name="passport"', 'Passport number reshown');
+
+ $mech->submit_form_ok( {
+ button => 'submit_register',
+ with_fields => {
+ address => 'My address',
+ }
+ },
+ "submit details, now with address",
+ );
+ $mech->content_contains('Now check your email');
+
+ my $problem = FixMyStreet::DB->resultset('Problem')->search({}, { order_by => '-id' })->first;
+ is $problem->get_extra_metadata('address'), 'My address', 'Address is stored';
+ is $problem->get_extra_metadata('passport'), '123456', 'Passport number is stored';
+};
+
+END {
+ $mech->delete_problems_for_body(undef);
+ done_testing();
+}
diff --git a/t/cobrand/form_extras/templates/report/new/after_photo.html b/t/cobrand/form_extras/templates/report/new/after_photo.html
new file mode 100644
index 000000000..b0c08ba20
--- /dev/null
+++ b/t/cobrand/form_extras/templates/report/new/after_photo.html
@@ -0,0 +1,12 @@
+<label for="form_address">Address</label>
+[% IF field_errors.address %]
+<p class='form-error'>[% field_errors.address %]</p>
+[% END %]
+<input type="text" value="[% report.get_extra_metadata('address') | html %]" name="address" id="form_address" required>
+
+<label for="form_passport">Passport number (optional)</label>
+[% IF field_errors.passport %]
+<p class='form-error'>[% field_errors.passport %]</p>
+[% END %]
+<input type="text" value="[% report.get_extra_metadata('passport') | html %]" name="passport" id="form_passport">
+
diff --git a/t/cobrand/get_body_sender.t b/t/cobrand/get_body_sender.t
index a9ba49479..66cfc02b7 100644
--- a/t/cobrand/get_body_sender.t
+++ b/t/cobrand/get_body_sender.t
@@ -4,7 +4,7 @@ use warnings;
use Test::More;
use mySociety::Locale;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use_ok 'FixMyStreet::Cobrand';
@@ -12,10 +12,10 @@ mySociety::Locale::gettext_domain( 'FixMyStreet' );
my $c = FixMyStreet::Cobrand::FixMyStreet->new();
-FixMyStreet::App->model('DB::BodyArea')->search( { body_id => 1000 } )->delete;
-FixMyStreet::App->model('DB::Body')->search( { name => 'Body of a Thousand' } )->delete;
+FixMyStreet::DB->resultset('BodyArea')->search( { body_id => 1000 } )->delete;
+FixMyStreet::DB->resultset('Body')->search( { name => 'Body of a Thousand' } )->delete;
-my $body = FixMyStreet::App->model('DB::Body')->find_or_create({
+my $body = FixMyStreet::DB->resultset('Body')->find_or_create({
id => 1000,
name => 'Body of a Thousand',
});
diff --git a/t/cobrand/restriction.t b/t/cobrand/restriction.t
new file mode 100644
index 000000000..873a396b7
--- /dev/null
+++ b/t/cobrand/restriction.t
@@ -0,0 +1,55 @@
+use strict;
+use warnings;
+
+package FixMyStreet::Cobrand::Tester;
+
+use parent 'FixMyStreet::Cobrand::Default';
+
+sub problems_restriction {
+ my ($self, $rs) = @_;
+ return $rs->search({ cobrand => 'tester' });
+}
+
+sub updates_restriction {
+ my ($self, $rs) = @_;
+ return $rs->search({ 'problem.cobrand' => 'tester' }, { join => 'problem' });
+}
+
+package main;
+
+use Test::More;
+use FixMyStreet::TestMech;
+
+my $c = FixMyStreet::App->new;
+my $cobrand = FixMyStreet::Cobrand::Tester->new({c => $c});
+$c->stash->{cobrand} = $cobrand;
+
+my $mech = FixMyStreet::TestMech->new;
+
+my ($prob1) = $mech->create_problems_for_body(1, 1234, 'Title');
+my ($prob2) = $mech->create_problems_for_body(1, 1234, 'Title', { cobrand => 'tester' });
+$mech->create_problems_for_body(1, 1234, 'Title', { latitude => 0, longitude => 0 });
+$mech->create_problems_for_body(1, 1234, 'Title', { cobrand => 'tester', latitude => 0, longitude => 0 });
+
+for (1..2) {
+ $c->model('DB::Comment')->create({
+ problem_id => $_ == 1 ? $prob1->id : $prob2->id,
+ user_id => $prob2->user_id,
+ name => 'User',
+ mark_fixed => 'false',
+ text => 'This is some update text',
+ state => 'confirmed',
+ cobrand => 'tester',
+ anonymous => 'f',
+ });
+}
+
+is($c->model('DB::Problem')->count, 4, 'Four reports in database');
+is($cobrand->problems->count, 2, 'Two reports in the right cobrand');
+is($cobrand->updates->count, 1, 'One update in the right cobrand');
+
+my $nearby = $c->model('DB::Nearby')->nearby($c, 5, [], 10, 0.003, 0.004);
+is(@$nearby, 1, 'One report close to the origin point');
+
+$mech->delete_problems_for_body(1234);
+done_testing();
diff --git a/t/cobrand/seesomething.t b/t/cobrand/seesomething.t
index 57a8a11ed..4da1c9c6e 100644
--- a/t/cobrand/seesomething.t
+++ b/t/cobrand/seesomething.t
@@ -2,7 +2,6 @@ use strict;
use warnings;
use DateTime;
use Test::More;
-use JSON;
use FixMyStreet;
use FixMyStreet::TestMech;
@@ -10,7 +9,7 @@ use FixMyStreet::TestMech;
my $EMAIL = 'seesomething@example.com';
my $mech = FixMyStreet::TestMech->new;
-my $db = FixMyStreet::App->model('DB')->schema;
+my $db = FixMyStreet::DB->storage->schema;
my $dt_parser = $db->storage->datetime_parser;
$db->txn_begin;
@@ -32,7 +31,7 @@ $user->update({ from_body => $body });
my $date = $dt_parser->format_datetime(DateTime->now);
-my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
+my $report = FixMyStreet::DB->resultset('Problem')->find_or_create( {
postcode => 'EH1 1BB',
bodies_str => '2520',
areas => ',2520,',
diff --git a/t/cobrand/two_tier.t b/t/cobrand/two_tier.t
index b3d6ca7db..f52e66abc 100644
--- a/t/cobrand/two_tier.t
+++ b/t/cobrand/two_tier.t
@@ -20,8 +20,8 @@ FixMyStreet::override_config {
for my $c (@cobrands) {
my ($m, $id) = @$c;
my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($m);
- my $body_restriction = $cobrand->body_restriction;
- is $body_restriction, $id, "body_restriction for $m";
+ my $council_id = $cobrand->council_id;
+ is $council_id, $id, "council_id for $m";
}
};
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 721ee547c..4734dc837 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -4,10 +4,12 @@
use strict;
use warnings;
use DateTime;
+use Email::MIME;
+use LWP::Protocol::PSGI;
use Test::More;
use Test::LongString;
-use JSON;
use Path::Tiny;
+use t::Mock::MapItZurich;
# Check that you have the required locale installed - the following
# should return a line with de_CH.utf8 in. If not install that locale.
@@ -19,9 +21,7 @@ use Path::Tiny;
# commonlib/bin/gettext-makemo FixMyStreet
use FixMyStreet;
-my $c = FixMyStreet::App->new();
-my $cobrand = FixMyStreet::Cobrand::Zurich->new({ c => $c });
-$c->stash->{cobrand} = $cobrand;
+my $cobrand = FixMyStreet::Cobrand::Zurich->new();
my $sample_file = path(__FILE__)->parent->parent->child("app/controller/sample.jpg");
ok $sample_file->exists, "sample file $sample_file exists";
@@ -37,7 +37,7 @@ sub send_reports_for_zurich {
ALLOWED_COBRANDS => ['zurich']
}, sub {
# Actually send the report
- $c->model('DB::Problem')->send_reports('zurich');
+ FixMyStreet::DB->resultset('Problem')->send_reports('zurich');
};
}
sub reset_report_state {
@@ -74,7 +74,7 @@ $division->parent( $zurich->id );
$division->send_method( 'Zurich' );
$division->endpoint( 'division@example.org' );
$division->update;
-$division->body_areas->find_or_create({ area_id => 274456 });
+$division->body_areas->find_or_create({ area_id => 423017 });
my $subdivision = $mech->create_body_ok( 3, 'Subdivision A' );
$subdivision->parent( $division->id );
$subdivision->send_method( 'Zurich' );
@@ -195,7 +195,7 @@ subtest "changing of categories" => sub {
sub get_moderated_count {
# my %date_params = ( );
- # my $moderated = FixMyStreet::App->model('DB::Problem')->search({
+ # my $moderated = FixMyStreet::DB->resultset('Problem')->search({
# extra => { like => '%moderated_overdue,I1:0%' }, %date_params } )->count;
# return $moderated;
@@ -703,10 +703,11 @@ subtest "only superuser can edit bodies" => sub {
};
subtest "only superuser can see 'Add body' form" => sub {
+ LWP::Protocol::PSGI->register(t::Mock::MapItZurich->run_if_script, host => 'mapit.zurich');
$user = $mech->log_in_ok( 'dm1@example.org' );
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'zurich' ],
- MAPIT_URL => 'http://global.mapit.mysociety.org/',
+ MAPIT_URL => 'http://mapit.zurich/',
MAPIT_TYPES => [ 'O08' ],
MAPIT_ID_WHITELIST => [ 423017 ],
}, sub {
@@ -717,12 +718,12 @@ subtest "only superuser can see 'Add body' form" => sub {
};
subtest "phone number is mandatory" => sub {
+ LWP::Protocol::PSGI->register(t::Mock::MapItZurich->run_if_script, host => 'mapit.zurich');
FixMyStreet::override_config {
MAPIT_TYPES => [ 'O08' ],
- MAPIT_URL => 'http://global.mapit.mysociety.org/',
+ MAPIT_URL => 'http://mapit.zurich/',
ALLOWED_COBRANDS => [ 'zurich' ],
- MAPIT_ID_WHITELIST => [ 274456 ],
- MAPIT_GENERATION => 2,
+ MAPIT_ID_WHITELIST => [ 423017 ],
MAP_TYPE => 'Zurich,OSM',
}, sub {
$user = $mech->log_in_ok( 'dm1@example.org' );
@@ -734,12 +735,12 @@ subtest "phone number is mandatory" => sub {
};
subtest "phone number is not mandatory for reports from mobile apps" => sub {
+ LWP::Protocol::PSGI->register(t::Mock::MapItZurich->run_if_script, host => 'mapit.zurich');
FixMyStreet::override_config {
MAPIT_TYPES => [ 'O08' ],
- MAPIT_URL => 'http://global.mapit.mysociety.org/',
+ MAPIT_URL => 'http://mapit.zurich/',
ALLOWED_COBRANDS => [ 'zurich' ],
MAPIT_ID_WHITELIST => [ 423017 ],
- MAPIT_GENERATION => 4,
MAP_TYPE => 'Zurich,OSM',
}, sub {
$mech->post_ok( '/report/new/mobile?lat=47.381817&lon=8.529156' , {
@@ -761,6 +762,7 @@ subtest "phone number is not mandatory for reports from mobile apps" => sub {
};
subtest "problems can't be assigned to deleted bodies" => sub {
+ LWP::Protocol::PSGI->register(t::Mock::MapItZurich->run_if_script, host => 'mapit.zurich');
$user = $mech->log_in_ok( 'dm1@example.org' );
$user->from_body( $zurich->id );
$user->update;
@@ -768,7 +770,7 @@ subtest "problems can't be assigned to deleted bodies" => sub {
$report->update;
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'zurich' ],
- MAPIT_URL => 'http://global.mapit.mysociety.org/',
+ MAPIT_URL => 'http://mapit.zurich/',
MAPIT_TYPES => [ 'O08' ],
MAPIT_ID_WHITELIST => [ 423017 ],
MAP_TYPE => 'Zurich,OSM',
@@ -789,6 +791,7 @@ subtest "problems can't be assigned to deleted bodies" => sub {
};
subtest "photo must be supplied for categories that require it" => sub {
+ LWP::Protocol::PSGI->register(t::Mock::MapItZurich->run_if_script, host => 'mapit.zurich');
FixMyStreet::App->model('DB::Contact')->find_or_create({
body => $division,
category => "Graffiti - photo required",
@@ -802,10 +805,9 @@ subtest "photo must be supplied for categories that require it" => sub {
});
FixMyStreet::override_config {
MAPIT_TYPES => [ 'O08' ],
- MAPIT_URL => 'http://global.mapit.mysociety.org/',
+ MAPIT_URL => 'http://mapit.zurich/',
ALLOWED_COBRANDS => [ 'zurich' ],
- MAPIT_ID_WHITELIST => [ 274456 ],
- MAPIT_GENERATION => 2,
+ MAPIT_ID_WHITELIST => [ 423017 ],
MAP_TYPE => 'Zurich,OSM',
}, sub {
$mech->post_ok( '/report/new', {
@@ -848,7 +850,7 @@ subtest "test stats" => sub {
subtest "test admin_log" => sub {
diag $report->id;
- my @entries = FixMyStreet::App->model('DB::AdminLog')->search({
+ my @entries = FixMyStreet::DB->resultset('AdminLog')->search({
object_type => 'problem',
object_id => $report->id,
});
@@ -868,7 +870,6 @@ subtest 'email images to external partners' => sub {
my $photo = path(__FILE__)->parent->child('zurich-logo_portal.x.jpg')->slurp_raw;
my $photoset = FixMyStreet::App::Model::PhotoSet->new({
- c => $c,
data_items => [ $photo ],
});
my $fileid = $photoset->data;
@@ -888,15 +889,26 @@ subtest 'email images to external partners' => sub {
my @emails = $mech->get_email;
my $email_as_string = $mech->get_first_email(@emails);
my ($boundary) = $email_as_string =~ /boundary="([A-Za-z0-9.]*)"/ms;
- my $changes = $email_as_string =~ s{$boundary}{}g;
- is $changes, 4, '4 boundaries'; # header + 3 around the 2x parts (text + 1 image)
+ my $email = Email::MIME->new($email_as_string);
my $expected_email_content = path(__FILE__)->parent->child('zurich_attachments.txt')->slurp;
my $REPORT_ID = $report->id;
$expected_email_content =~ s{REPORT_ID}{$REPORT_ID}g;
+ $expected_email_content =~ s{BOUNDARY}{$boundary}g;
+ my $expected_email = Email::MIME->new($expected_email_content);
- is_string $email_as_string, $expected_email_content, 'MIME email text ok'
+ my @email_parts;
+ $email->walk_parts(sub {
+ my ($part) = @_;
+ push @email_parts, [ { $part->header_pairs }, $part->body ];
+ });
+ my @expected_email_parts;
+ $expected_email->walk_parts(sub {
+ my ($part) = @_;
+ push @expected_email_parts, [ { $part->header_pairs }, $part->body ];
+ });
+ is_deeply \@email_parts, \@expected_email_parts, 'MIME email text ok'
or do {
(my $test_name = $0) =~ s{/}{_}g;
my $path = path("test-output-$test_name.tmp");
diff --git a/t/cobrand/zurich_attachments.txt b/t/cobrand/zurich_attachments.txt
index 1c989c4d9..4ccc90205 100644
--- a/t/cobrand/zurich_attachments.txt
+++ b/t/cobrand/zurich_attachments.txt
@@ -1,12 +1,12 @@
MIME-Version: 1.0
Subject: =?iso-8859-1?Q?Z=FCri?= wie neu: Weitergeleitete Meldung #REPORT_ID
-Content-Type: multipart/mixed; boundary=""
+Content-Type: multipart/mixed; boundary="BOUNDARY"
To: "External Body" <external_body@example.org>
Content-Transfer-Encoding: 7bit
From: FixMyStreet <division@example.org>
---
+--BOUNDARY
MIME-Version: 1.0
Subject: =?iso-8859-1?Q?Z=FCri?= wie neu: Weitergeleitete Meldung #REPORT_ID
Content-Type: text/plain; charset="iso-8859-1"
@@ -23,7 +23,7 @@ gis-zentrum@zuerich.ch.=
---
+--BOUNDARY
MIME-Version: 1.0
Content-Type: image/jpeg; name="REPORT_ID.0.jpeg"
Content-Disposition: inline; filename="REPORT_ID.0.jpeg"
@@ -37,4 +37,4 @@ BxcYVVaUpf/EABcBAQEBAQAAAAAAAAAAAAAAAAAFBgT/xAAgEQEAAAQHAQAAAAAAAAAAAAAAAwQV
UgECFlNhodGx/9oADAMBAAIRAxEAPwCywAIozyxS5R58tbbujSW33j6zFRj3fGbKbjAGAgAACs9N
FCbtUfYg2mO1BM25e/V+lQeW3ISo/9k=
-----
+--BOUNDARY--