From 8deb709fa2d44bcbaba54734f7f4f4385980d8df Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 23 Jun 2011 17:11:36 +0100 Subject: add extra states to problem count --- t/app/controller/admin.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index ba5095cea..51c55c323 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -77,7 +77,7 @@ my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create( ); subtest 'check summary counts' => sub { - my $problems = FixMyStreet::App->model('DB::Problem')->search( { state => { -in => [qw/confirmed fixed/] } } ); + my $problems = FixMyStreet::App->model('DB::Problem')->search( { state => { -in => [qw/confirmed fixed closed investigating planned/, 'in progress', 'fixed - user', 'fixed - council'] } } ); my $problem_count = $problems->count; $problems->update( { cobrand => '' } ); -- cgit v1.2.3 From ef93992a2abbb3c800a2d6bbc112b284c4e227a6 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Mon, 27 Jun 2011 16:36:22 +0100 Subject: user searching and editing --- t/app/controller/admin.t | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 51c55c323..2ada0d2ea 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -721,6 +721,98 @@ subtest 'report search' => sub { $mech->content_like( qr{]*hidden[^>]*> \s* \s* $r_id \s* }xs ); }; +subtest 'user search' => sub { + $mech->get_ok('/admin/search_users'); + $mech->get_ok('/admin/search_users?search=' . $user->name); + + $mech->content_contains( $user->name); + my $u_id = $user->id; + $mech->content_like( qr{user_edit/$u_id">Edit} ); + + $mech->get_ok('/admin/search_users?search=' . $user->email); + + $mech->content_like( qr{user_edit/$u_id">Edit} ); + + $user->from_council(2509); + $user->update; + $mech->get_ok('/admin/search_users?search=2509' ); + $mech->content_contains(2509); +}; + +$log_entries = FixMyStreet::App->model('DB::AdminLog')->search( + { + object_type => 'user', + object_id => $user->id + }, + { + order_by => { -desc => 'id' }, + } +); + +is $log_entries->count, 0, 'no admin log entries'; + +for my $test ( + { + desc => 'edit user name', + fields => { + name => 'Test User', + email => 'test@example.com', + council => 2509, + }, + changes => { + name => 'Changed User', + }, + log_count => 1, + log_entries => [qw/edit/], + }, + { + desc => 'edit user email', + fields => { + name => 'Changed User', + email => 'test@example.com', + council => 2509, + }, + changes => { + email => 'changed@example.com', + }, + log_count => 2, + log_entries => [qw/edit edit/], + }, + { + desc => 'edit user council', + fields => { + name => 'Changed User', + email => 'changed@example.com', + council => 2509, + }, + changes => { + council => 2607, + }, + log_count => 3, + log_entries => [qw/edit edit edit/], + }, +) { + subtest $test->{desc} => sub { + $mech->get_ok( '/admin/user_edit/' . $user->id ); + + my $visible = $mech->visible_form_values; + is_deeply $visible, $test->{fields}, 'expected user'; + + my $expected = { + %{ $test->{fields} }, + %{ $test->{changes} } + }; + + $mech->submit_form_ok( { with_fields => $expected } ); + + $visible = $mech->visible_form_values; + is_deeply $visible, $expected, 'user updated'; + + $mech->content_contains( 'Updated!' ); + }; +} + + $mech->delete_user( $user ); $mech->delete_user( $user2 ); $mech->delete_user( $user3 ); -- cgit v1.2.3 From cad4d9856b13328fd1e64ff6b48ee47234741960 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 29 Jun 2011 17:54:26 +0100 Subject: make sure cobrand summary tests pass even if we have barnet entries in db --- t/app/controller/admin.t | 3 +++ 1 file changed, 3 insertions(+) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 2ada0d2ea..c5d253459 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -82,6 +82,8 @@ subtest 'check summary counts' => sub { my $problem_count = $problems->count; $problems->update( { cobrand => '' } ); + FixMyStreet::App->model('DB::Problem')->search( { council => 2489 } )->update( { council => 1 } ); + my $q = FixMyStreet::App->model('DB::Questionnaire')->find_or_new( { problem => $report, }); $q->whensent( \'ms_current_timestamp()' ); $q->in_storage ? $q->update : $q->insert; @@ -130,6 +132,7 @@ subtest 'check summary counts' => sub { $alert->cobrand(''); $alert->update; + FixMyStreet::App->model('DB::Problem')->search( { council => 1 } )->update( { council => 2489 } ); ok $mech->host('fixmystreet.com'); }; -- cgit v1.2.3 From b756440e4b5c0b356ee0d65d1647124317535c95 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 30 Jun 2011 16:53:56 +0100 Subject: some extra info on updates --- t/app/controller/admin.t | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index c5d253459..dcf45e983 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -639,6 +639,76 @@ for my $test ( }; } +for my $test ( + { + desc => 'user is problem owner', + problem_user => $user, + update_user => $user, + update_fixed => 0, + update_reopen => 0, + update_state => undef, + user_council => undef, + content => 'user is problem owner', + }, + { + desc => 'user is council user', + problem_user => $user, + update_user => $user2, + update_fixed => 0, + update_reopen => 0, + update_state => undef, + user_council => 2504, + content => 'user is from same council as problem - 2504', + }, + { + desc => 'update changed problem state', + problem_user => $user, + update_user => $user2, + update_fixed => 0, + update_reopen => 0, + update_state => 'planned', + user_council => 2504, + content => 'Update changed problem state to planned', + }, + { + desc => 'update marked problem as fixed', + problem_user => $user, + update_user => $user3, + update_fixed => 1, + update_reopen => 0, + update_state => undef, + user_council => undef, + content => 'Update marked problem as fixed', + }, + { + desc => 'update reopened problem', + problem_user => $user, + update_user => $user, + update_fixed => 0, + update_reopen => 1, + update_state => undef, + user_council => undef, + content => 'Update reopened problem', + }, +) { + subtest $test->{desc} => sub { + $report->user( $test->{problem_user} ); + $report->update; + + $update->user( $test->{update_user} ); + $update->problem_state( $test->{update_state} ); + $update->mark_fixed( $test->{update_fixed} ); + $update->mark_open( $test->{update_reopen} ); + $update->update; + + $test->{update_user}->from_council( $test->{user_council} ); + $test->{update_user}->update; + + $mech->get_ok('/admin/update_edit/' . $update->id ); + $mech->content_contains( $test->{content} ); + }; +} + subtest 'editing update email creates new user if required' => sub { my $user = FixMyStreet::App->model('DB::User')->find( { email => 'test4@example.com' } -- cgit v1.2.3