diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin.t | 49 | ||||
-rw-r--r-- | t/cobrand/councils.t | 36 |
2 files changed, 79 insertions, 6 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index e6a8a34cf..3f69829f7 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -289,6 +289,7 @@ subtest 'check text output' => sub { $mech->get_ok('/admin/body/' . $body->id . '?text=1'); is $mech->content_type, 'text/plain'; $mech->content_contains('test category'); + $mech->content_lacks('<body'); }; @@ -740,13 +741,45 @@ subtest 'adding email to abuse list from report page' => sub { $mech->click_ok('banuser'); $mech->content_contains('User added to abuse list'); - $mech->content_contains('<small>(User in abuse table)</small>'); + $mech->content_contains('<small>User in abuse table</small>'); $abuse = FixMyStreet::App->model('DB::Abuse')->find( { email => $email } ); ok $abuse, 'entry created in abuse table'; $mech->get_ok( '/admin/report_edit/' . $report->id ); - $mech->content_contains('<small>(User in abuse table)</small>'); + $mech->content_contains('<small>User in abuse table</small>'); +}; + +subtest 'remove user from abuse list from edit user page' => sub { + my $abuse = FixMyStreet::App->model('DB::Abuse')->find_or_create( { email => $user->email } ); + $mech->get_ok( '/admin/user_edit/' . $user->id ); + $mech->content_contains('User in abuse table'); + + $mech->click_ok('unban'); + + $abuse = FixMyStreet::App->model('DB::Abuse')->find( { email => $user->email } ); + ok !$abuse, 'record removed from abuse table'; +}; + +subtest 'remove user with phone account from abuse list from edit user page' => sub { + my $abuse_user = $mech->create_user_ok('01234 456789'); + my $abuse = FixMyStreet::App->model('DB::Abuse')->find_or_create( { email => $abuse_user->phone } ); + $mech->get_ok( '/admin/user_edit/' . $abuse_user->id ); + $mech->content_contains('User in abuse table'); + my $abuse_found = FixMyStreet::App->model('DB::Abuse')->find( { email => $abuse_user->phone } ); + ok $abuse_found, 'user in abuse table'; + + $mech->click_ok('unban'); + + $abuse = FixMyStreet::App->model('DB::Abuse')->find( { email => $user->phone } ); + ok !$abuse, 'record removed from abuse table'; +}; + +subtest 'no option to remove user already in abuse list' => sub { + my $abuse = FixMyStreet::App->model('DB::Abuse')->find( { email => $user->email } ); + $abuse->delete if $abuse; + $mech->get_ok( '/admin/user_edit/' . $user->id ); + $mech->content_lacks('User in abuse table'); }; subtest 'flagging user from report page' => sub { @@ -1048,13 +1081,13 @@ subtest 'adding email to abuse list from update page' => sub { $mech->click_ok('banuser'); $mech->content_contains('User added to abuse list'); - $mech->content_contains('<small>(User in abuse table)</small>'); + $mech->content_contains('<small>User in abuse table</small>'); $abuse = FixMyStreet::App->model('DB::Abuse')->find( { email => $email } ); ok $abuse, 'entry created in abuse table'; $mech->get_ok( '/admin/update_edit/' . $update->id ); - $mech->content_contains('<small>(User in abuse table)</small>'); + $mech->content_contains('<small>User in abuse table</small>'); }; subtest 'flagging user from update page' => sub { @@ -1164,7 +1197,7 @@ subtest 'report search' => sub { subtest 'search abuse' => sub { $mech->get_ok( '/admin/users?search=example' ); - $mech->content_like(qr{test4\@example.com.*</td>\s*<td>.*?</td>\s*<td>\(User in abuse table}s); + $mech->content_like(qr{test4\@example.com.*</td>\s*<td>.*?</td>\s*<td>User in abuse table}s); }; subtest 'show flagged entries' => sub { @@ -1325,6 +1358,10 @@ my %default_perms = ( trusted_bodies => undef, ); +# Start this section with user having no name +# Regression test for mysociety/fixmystreetforcouncils#250 +$user->update({ name => '' }); + FixMyStreet::override_config { MAPIT_URL => 'http://mapit.uk/', }, sub { @@ -1332,7 +1369,7 @@ FixMyStreet::override_config { { desc => 'edit user name', fields => { - name => 'Test User', + name => '', email => 'test@example.com', body => $haringey->id, phone => '', diff --git a/t/cobrand/councils.t b/t/cobrand/councils.t index 4de8bbf2e..c44605bd9 100644 --- a/t/cobrand/councils.t +++ b/t/cobrand/councils.t @@ -1,6 +1,15 @@ use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; +my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council' ); +my $contact = $mech->create_contact_ok( body_id => $oxon->id, category => 'Cows', email => 'cows@example.net' ); + +my ($report) = $mech->create_problems_for_body(1, $oxon->id, 'Test', { + category => 'Cows', cobrand => 'fixmystreet', +}); +my $report_id = $report->id; + + foreach my $council (qw/oxfordshire bromley/) { FixMyStreet::override_config { ALLOWED_COBRANDS => [ $council ], @@ -11,4 +20,31 @@ foreach my $council (qw/oxfordshire bromley/) { }; } + +foreach my $test ( + { cobrand => 'fixmystreet', social => 1 }, + { cobrand => 'bromley', social => 0 }, +) { + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ $test->{cobrand} ], + FACEBOOK_APP_ID => 'facebook-app-id', + TWITTER_KEY => 'twitter-key', + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/auth'); + $mech->contains_or_lacks($test->{social}, "Log in with Facebook"); + $mech->contains_or_lacks($test->{social}, "Log in with Twitter"); + + $mech->get_ok("/report/new?lat=51.754926&lon=-1.256179"); + $mech->contains_or_lacks($test->{social}, "Log in with Facebook"); + $mech->contains_or_lacks($test->{social}, "Log in with Twitter"); + + $mech->get_ok("/report/$report_id"); + $mech->contains_or_lacks($test->{social}, "Log in with Facebook"); + $mech->contains_or_lacks($test->{social}, "Log in with Twitter"); + }; +}; + + done_testing(); |