diff options
Diffstat (limited to 't/cobrand/bathnes.t')
-rw-r--r-- | t/cobrand/bathnes.t | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/t/cobrand/bathnes.t b/t/cobrand/bathnes.t index 6586dcb96..006dd757d 100644 --- a/t/cobrand/bathnes.t +++ b/t/cobrand/bathnes.t @@ -1,6 +1,10 @@ +use Test::MockModule; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; +my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::BathNES'); +$cobrand->mock('area_types', sub { [ 'UTA' ] }); + my $body = $mech->create_body_ok(2551, 'Bath and North East Somerset Council'); my @cats = ('Litter', 'Other', 'Potholes', 'Traffic lights'); for my $contact ( @cats ) { @@ -11,7 +15,7 @@ my $counciluser = $mech->create_user_ok('counciluser@example.com', name => 'Coun my $normaluser = $mech->create_user_ok('normaluser@example.com', name => 'Normal User'); $normaluser->update({ phone => "+447123456789" }); -$mech->create_problems_for_body(1, $body->id, 'Title', { +my ($problem) = $mech->create_problems_for_body(1, $body->id, 'Title', { areas => ",2651,", category => 'Potholes', cobrand => 'fixmystreet', user => $normaluser, service => 'iOS', extra => { _fields => [ @@ -59,6 +63,19 @@ subtest 'cobrand displays council name' => sub { $mech->content_like( qr/Bath and North East Somerset\b/ ); }; +subtest 'check override contact display name' => sub { + $mech->log_in_ok( $superuser->email ); + $mech->get_ok("/admin/body/" . $body->id . '/Litter'); + $mech->content_contains('<h1>Litter</h1>'); + $mech->content_contains('extra[display_name]'); + $mech->submit_form_ok({ with_fields => { + 'extra[display_name]' => 'Wittering' + }}); + $mech->get_ok('/reports/Bath+and+North+East+Somerset'); + $mech->content_like(qr/Traffic lights<\/option>\s*<option value="Litter">\s*Wittering<\/option>/); + $mech->content_lacks('Litter</option>'); +}; + subtest 'extra CSV columns are absent if permission not granted' => sub { $mech->log_in_ok( $counciluser->email ); @@ -156,28 +173,28 @@ subtest 'extra CSV columns are present if permission granted' => sub { is $rows[1]->[18], 'iOS', 'Site Used shows whether report made via app'; is $rows[1]->[19], '', 'Reported As is empty if not made on behalf of another user/body'; - is $rows[1]->[20], 'normaluser@example.com', 'User email is correct'; + is $rows[1]->[20], $normaluser->email, 'User email is correct'; is $rows[1]->[21], '+447123456789', 'User phone number is correct'; is $rows[1]->[22], '', 'Staff User is empty if not made on behalf of another user'; is $rows[1]->[23], 'width = 10cm; depth = 25cm', 'Attribute Data is correct'; is $rows[2]->[18], 'bathnes', 'Site Used shows correct cobrand'; is $rows[2]->[19], 'body', 'Reported As is correct if made on behalf of body'; - is $rows[2]->[20], 'counciluser@example.com', 'User email is correct'; + is $rows[2]->[20], $counciluser->email, 'User email is correct'; is $rows[2]->[21], '', 'User phone number is correct'; is $rows[2]->[22], '', 'Staff User is empty if not made on behalf of another user'; is $rows[2]->[23], '', 'Attribute Data is correct'; is $rows[3]->[18], 'bathnes', 'Site Used shows correct cobrand'; is $rows[3]->[19], 'another_user', 'Reported As is set if reported on behalf of another user'; - is $rows[3]->[20], 'normaluser@example.com', 'User email is correct'; + is $rows[3]->[20], $normaluser->email, 'User email is correct'; is $rows[3]->[21], '+447123456789', 'User phone number is correct'; - is $rows[3]->[22], 'counciluser@example.com', 'Staff User is correct if made on behalf of another user'; + is $rows[3]->[22], $counciluser->email, 'Staff User is correct if made on behalf of another user'; is $rows[3]->[23], '', 'Attribute Data is correct'; is $rows[4]->[18], 'bathnes', 'Site Used shows correct cobrand'; is $rows[4]->[19], 'anonymous_user', 'Reported As is set if reported on behalf of another user'; - is $rows[4]->[20], 'counciluser@example.com', 'User email is correct'; + is $rows[4]->[20], $counciluser->email, 'User email is correct'; is $rows[4]->[21], '', 'User phone number is correct'; is $rows[4]->[22], '', 'Staff User is empty if not made on behalf of another user'; is $rows[4]->[23], '', 'Attribute Data is correct'; @@ -199,4 +216,17 @@ subtest 'extra CSV columns are present if permission granted' => sub { }; +subtest 'check cobrand correctly reset on each request' => sub { + FixMyStreet::override_config { + 'ALLOWED_COBRANDS' => [ 'bathnes', 'fixmystreet' ], + }, sub { + $mech->log_in_ok( $superuser->email ); + $mech->host('www.fixmystreet.com'); + $mech->get_ok( '/contact?id=' . $problem->id ); + $mech->host('bathnes.fixmystreet.com'); + $mech->get_ok( '/contact?reject=1&id=' . $problem->id ); + $mech->content_contains('Reject report'); + } +}; + done_testing(); |