diff options
Diffstat (limited to 't/app/controller/admin.t')
-rw-r--r-- | t/app/controller/admin.t | 352 |
1 files changed, 200 insertions, 152 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 09d99cfdf..9ec15ec21 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -163,19 +163,32 @@ subtest 'check contact creation' => sub { $mech->get_ok('/admin/council_contacts/2650'); $mech->submit_form_ok( { with_fields => { - category => 'test category', - email => 'test@example.com', - note => 'test note', + category => 'test category', + email => 'test@example.com', + note => 'test note', + non_public => undef, } } ); $mech->content_contains( 'test category' ); $mech->content_contains( '<td>test@example.com' ); $mech->content_contains( '<td>test note' ); + $mech->content_contains( '<td>Public' ); + + $mech->submit_form_ok( { with_fields => { + category => 'private category', + email => 'test@example.com', + note => 'test note', + non_public => 'on', + } } ); + + $mech->content_contains( 'private category' ); + $mech->content_contains( '<td>Non Public' ); $mech->submit_form_ok( { with_fields => { category => 'test/category', email => 'test@example.com', note => 'test/note', + non_public => 'on', } } ); $mech->get_ok('/admin/council_edit/2650/test/category'); @@ -187,11 +200,21 @@ subtest 'check contact editing' => sub { $mech->submit_form_ok( { with_fields => { email => 'test2@example.com', note => 'test2 note', + non_public => undef, } } ); $mech->content_contains( 'test category' ); $mech->content_contains( '<td>test2@example.com' ); $mech->content_contains( '<td>test2 note' ); + $mech->content_contains( '<td>Public' ); + + $mech->submit_form_ok( { with_fields => { + email => 'test2@example.com', + note => 'test2 note', + non_public => 'on', + } } ); + + $mech->content_contains( '<td>Non Public' ); $mech->get_ok('/admin/council_edit/2650/test%20category'); $mech->content_contains( '<td><strong>test2@example.com' ); @@ -293,206 +316,229 @@ ok $report, "created test report - $report_id"; foreach my $test ( { description => 'edit report title', - fields => { - title => 'Report to Edit', - detail => 'Detail for Report to Edit', - state => 'confirmed', - name => 'Test User', - email => $user->email, - anonymous => 0, - flagged => undef, - }, - changes => { - title => 'Edited Report', + fields => { + title => 'Report to Edit', + detail => 'Detail for Report to Edit', + state => 'confirmed', + name => 'Test User', + email => $user->email, + anonymous => 0, + flagged => undef, + non_public => undef, }, - log_count => 1, - log_entries => [ qw/edit/ ], - resend => 0, + changes => { title => 'Edited Report', }, + log_count => 1, + log_entries => [qw/edit/], + resend => 0, }, { description => 'edit report description', - fields => { - title => 'Edited Report', - detail => 'Detail for Report to Edit', - state => 'confirmed', - name => 'Test User', - email => $user->email, - anonymous => 0, - flagged => undef, - }, - changes => { - detail => 'Edited Detail', + fields => { + title => 'Edited Report', + detail => 'Detail for Report to Edit', + state => 'confirmed', + name => 'Test User', + email => $user->email, + anonymous => 0, + flagged => undef, + non_public => undef, }, - log_count => 2, - log_entries => [ qw/edit edit/ ], - resend => 0, + changes => { detail => 'Edited Detail', }, + log_count => 2, + log_entries => [qw/edit edit/], + resend => 0, }, { description => 'edit report user name', - fields => { - title => 'Edited Report', - detail => 'Edited Detail', - state => 'confirmed', - name => 'Test User', - email => $user->email, - anonymous => 0, - flagged => undef, - }, - changes => { - name => 'Edited User', + fields => { + title => 'Edited Report', + detail => 'Edited Detail', + state => 'confirmed', + name => 'Test User', + email => $user->email, + anonymous => 0, + flagged => undef, + non_public => undef, }, - log_count => 3, - log_entries => [ qw/edit edit edit/ ], - resend => 0, - user => $user, + changes => { name => 'Edited User', }, + log_count => 3, + log_entries => [qw/edit edit edit/], + resend => 0, + user => $user, }, { description => 'edit report set flagged true', - fields => { - title => 'Edited Report', - detail => 'Edited Detail', - state => 'confirmed', - name => 'Edited User', - email => $user->email, - anonymous => 0, - flagged => undef, + fields => { + title => 'Edited Report', + detail => 'Edited Detail', + state => 'confirmed', + name => 'Edited User', + email => $user->email, + anonymous => 0, + flagged => undef, + non_public => undef, }, changes => { - flagged => 'on', + flagged => 'on', }, - log_count => 4, - log_entries => [ qw/edit edit edit edit/ ], - resend => 0, - user => $user, + log_count => 4, + log_entries => [qw/edit edit edit edit/], + resend => 0, + user => $user, }, { description => 'edit report user email', - fields => { - title => 'Edited Report', - detail => 'Edited Detail', - state => 'confirmed', - name => 'Edited User', - email => $user->email, - anonymous => 0, - flagged => 'on', - }, - changes => { - email => $user2->email, + fields => { + title => 'Edited Report', + detail => 'Edited Detail', + state => 'confirmed', + name => 'Edited User', + email => $user->email, + anonymous => 0, + flagged => 'on', + non_public => undef, }, - log_count => 5, - log_entries => [ qw/edit edit edit edit edit/ ], - resend => 0, - user => $user2, + changes => { email => $user2->email, }, + log_count => 5, + log_entries => [qw/edit edit edit edit edit/], + resend => 0, + user => $user2, }, { description => 'change state to unconfirmed', - fields => { - title => 'Edited Report', - detail => 'Edited Detail', - state => 'confirmed', - name => 'Edited User', - email => $user2->email, - anonymous => 0, - flagged => 'on', - }, - changes => { - state => 'unconfirmed' + fields => { + title => 'Edited Report', + detail => 'Edited Detail', + state => 'confirmed', + name => 'Edited User', + email => $user2->email, + anonymous => 0, + flagged => 'on', + non_public => undef, }, + changes => { state => 'unconfirmed' }, log_count => 6, - log_entries => [ qw/state_change edit edit edit edit edit/ ], - resend => 0, + log_entries => [qw/state_change edit edit edit edit edit/], + resend => 0, }, { description => 'change state to confirmed', - fields => { - title => 'Edited Report', - detail => 'Edited Detail', - state => 'unconfirmed', - name => 'Edited User', - email => $user2->email, - anonymous => 0, - flagged => 'on', - }, - changes => { - state => 'confirmed' + fields => { + title => 'Edited Report', + detail => 'Edited Detail', + state => 'unconfirmed', + name => 'Edited User', + email => $user2->email, + anonymous => 0, + flagged => 'on', + non_public => undef, }, + changes => { state => 'confirmed' }, log_count => 7, - log_entries => [ qw/state_change state_change edit edit edit edit edit/ ], - resend => 0, + log_entries => [qw/state_change state_change edit edit edit edit edit/], + resend => 0, }, { description => 'change state to fixed', - fields => { - title => 'Edited Report', - detail => 'Edited Detail', - state => 'confirmed', - name => 'Edited User', - email => $user2->email, - anonymous => 0, - flagged => 'on', - }, - changes => { - state => 'fixed' + fields => { + title => 'Edited Report', + detail => 'Edited Detail', + state => 'confirmed', + name => 'Edited User', + email => $user2->email, + anonymous => 0, + flagged => 'on', + non_public => undef, }, + changes => { state => 'fixed' }, log_count => 8, - log_entries => [ qw/state_change state_change state_change edit edit edit edit edit/ ], + log_entries => + [qw/state_change state_change state_change edit edit edit edit edit/], resend => 0, }, { description => 'change state to hidden', - fields => { - title => 'Edited Report', - detail => 'Edited Detail', - state => 'fixed', - name => 'Edited User', - email => $user2->email, - anonymous => 0, - flagged => 'on', + fields => { + title => 'Edited Report', + detail => 'Edited Detail', + state => 'fixed', + name => 'Edited User', + email => $user2->email, + anonymous => 0, + flagged => 'on', + non_public => undef, }, - changes => { - state => 'hidden' - }, - log_count => 9, - log_entries => [ qw/state_change state_change state_change state_change edit edit edit edit edit/ ], + changes => { state => 'hidden' }, + log_count => 9, + log_entries => [ + qw/state_change state_change state_change state_change edit edit edit edit edit/ + ], resend => 0, }, { description => 'edit and change state', - fields => { - title => 'Edited Report', - detail => 'Edited Detail', - state => 'hidden', - name => 'Edited User', - email => $user2->email, - anonymous => 0, - flagged => 'on', + fields => { + title => 'Edited Report', + detail => 'Edited Detail', + state => 'hidden', + name => 'Edited User', + email => $user2->email, + anonymous => 0, + flagged => 'on', + non_public => undef, }, changes => { - state => 'confirmed', + state => 'confirmed', anonymous => 1, }, - log_count => 11, - log_entries => [ qw/edit state_change state_change state_change state_change state_change edit edit edit edit edit/ ], + log_count => 11, + log_entries => [ + qw/edit state_change state_change state_change state_change state_change edit edit edit edit edit/ + ], resend => 0, }, { description => 'resend', - fields => { - title => 'Edited Report', - detail => 'Edited Detail', - state => 'confirmed', - name => 'Edited User', - email => $user2->email, - anonymous => 1, - flagged => 'on', - }, - changes => { + fields => { + title => 'Edited Report', + detail => 'Edited Detail', + state => 'confirmed', + name => 'Edited User', + email => $user2->email, + anonymous => 1, + flagged => 'on', + non_public => undef, }, - log_count => 12, - log_entries => [ qw/resend edit state_change state_change state_change state_change state_change edit edit edit edit edit/ ], + changes => {}, + log_count => 12, + log_entries => [ + qw/resend edit state_change state_change state_change state_change state_change edit edit edit edit edit/ + ], resend => 1, }, -) { + { + description => 'non public', + fields => { + title => 'Edited Report', + detail => 'Edited Detail', + state => 'confirmed', + name => 'Edited User', + email => $user2->email, + anonymous => 1, + flagged => 'on', + non_public => undef, + }, + changes => { + non_public => 'on', + }, + log_count => 13, + log_entries => [ + qw/edit resend edit state_change state_change state_change state_change state_change edit edit edit edit edit/ + ], + resend => 0, + }, + ) +{ subtest $test->{description} => sub { $log_entries->reset; $mech->get_ok("/admin/report_edit/$report_id"); @@ -523,6 +569,8 @@ foreach my $test ( } $test->{changes}->{flagged} = 1 if $test->{changes}->{flagged}; + $test->{changes}->{non_public} = 1 if $test->{changes}->{non_public}; + is $report->$_, $test->{changes}->{$_}, "$_ updated" for grep { $_ ne 'email' } keys %{ $test->{changes} }; if ( $test->{user} ) { @@ -547,6 +595,7 @@ subtest 'change email to new user' => sub { email => $report->user->email, anonymous => 1, flagged => 'on', + non_public => 'on', }; is_deeply( $mech->visible_form_values(), $fields, 'initial form values' ); @@ -1017,9 +1066,8 @@ subtest 'report search' => sub { }; subtest 'search abuse' => sub { - $mech->get_ok( '/admin/search_abuse?search=example' ); - - $mech->content_contains('test4@example.com'); + $mech->get_ok( '/admin/search_users?search=example' ); + $mech->content_like(qr/test4\@example.com.*\n.*\n.*Email in abuse table/); }; subtest 'show flagged entries' => sub { |