aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand/bromley.t
diff options
context:
space:
mode:
Diffstat (limited to 't/cobrand/bromley.t')
-rw-r--r--t/cobrand/bromley.t62
1 files changed, 61 insertions, 1 deletions
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 1f61cd3de..6066c66b6 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -7,7 +7,7 @@ my $mech = FixMyStreet::TestMech->new;
# Create test data
my $user = $mech->create_user_ok( 'bromley@example.com' );
-my $body = $mech->create_body_ok( 2482, 'Bromley', id => 2482 );
+my $body = $mech->create_body_ok( 2482, 'Bromley Council', id => 2482 );
$mech->create_contact_ok(
body_id => $body->id,
category => 'Other',
@@ -56,6 +56,66 @@ subtest 'testing special Open311 behaviour', sub {
is $report->external_id, 248, 'Report has right external ID';
};
+for my $test (
+ {
+ cobrand => 'bromley',
+ fields => {
+ submit_update => 1,
+ rznvy => 'unregistered@example.com',
+ update => 'Update from an unregistered user',
+ add_alert => undef,
+ first_name => 'Unreg',
+ last_name => 'User',
+ fms_extra_title => 'DR',
+ may_show_name => undef,
+ }
+ },
+ {
+ cobrand => 'fixmystreet',
+ fields => {
+ submit_update => 1,
+ rznvy => 'unregistered@example.com',
+ update => 'Update from an unregistered user',
+ add_alert => undef,
+ name => 'Unreg User',
+ fms_extra_title => 'DR',
+ may_show_name => undef,
+ }
+ },
+)
+{
+ subtest 'check Bromley update emails via ' . $test->{cobrand} . ' cobrand are correct' => sub {
+ $mech->log_out_ok();
+ $mech->clear_emails_ok();
+
+ my $report_id = $report->id;
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ $test->{cobrand} ],
+ }, sub {
+ $mech->get_ok("/report/$report_id");
+ $mech->submit_form_ok(
+ {
+ with_fields => $test->{fields}
+ },
+ 'submit update'
+ );
+ };
+ $mech->content_contains('Nearly done! Now check your email');
+
+ my $email = $mech->get_email;
+ ok $email, "got an email";
+ like $email->body, qr/This update will be sent to Bromley Council/i, "Email indicates problem will be sent to Bromley";
+ unlike $email->body, qr/Note that we do not send updates to/i, "Email does not say updates aren't sent to Bromley";
+
+ my $unreg_user = FixMyStreet::App->model( 'DB::User' )->find( { email => 'unregistered@example.com' } );
+
+ ok $unreg_user, 'found user';
+
+ $mech->delete_user( $unreg_user );
+ };
+}
+
# Clean up
$mech->delete_user($user);
$mech->delete_body($body);