-
-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Northumberland] Add comment when assigned user or extra details updated
- Loading branch information
1 parent
80cb76a
commit 9643271
Showing
6 changed files
with
202 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
use CGI::Simple; | ||
use FixMyStreet::TestMech; | ||
use FixMyStreet::Script::CSVExport; | ||
use Test::MockModule; | ||
use File::Temp 'tempdir'; | ||
|
||
# disable info logs for this test run | ||
FixMyStreet::App->log->disable('info'); | ||
END { FixMyStreet::App->log->enable('info'); } | ||
|
||
my $mech = FixMyStreet::TestMech->new; | ||
|
||
my $body = $mech->create_body_ok(2248, 'Northumberland County Council', { cobrand => 'northumberland' }); | ||
|
@@ -111,4 +116,120 @@ FixMyStreet::override_config { | |
}; | ||
}; | ||
|
||
FixMyStreet::override_config { | ||
ALLOWED_COBRANDS => [ 'northumberland', 'fixmystreet' ], | ||
MAPIT_URL => 'http://mapit.uk/', | ||
}, sub { | ||
my $o = Open311->new( fixmystreet_body => $body ); | ||
|
||
my $superuser = $mech->create_user_ok( | ||
'[email protected]', | ||
name => 'Super User', | ||
is_superuser => 1, | ||
); | ||
$mech->log_in_ok( $superuser->email ); | ||
|
||
for my $host ( 'northumberland', 'fixmystreet' ) { | ||
ok $mech->host($host), "change host to $host"; | ||
|
||
my ($problem_to_update) = $mech->create_problems_for_body( | ||
1, | ||
$body->id, | ||
'Test', | ||
{ cobrand => $host, external_id => 123 }, | ||
); | ||
|
||
subtest "User assignment on $host site" => sub { | ||
$mech->get_ok( '/report/' . $problem_to_update->id ); | ||
$mech->submit_form_ok({ form_id => 'planned_form' }); | ||
my $comment | ||
= $problem_to_update->comments->order_by('-id')->first; | ||
is_deeply $comment->get_extra_metadata, { | ||
shortlisted_user => $superuser->email, | ||
is_superuser => 1, | ||
}, 'Comment created for user assignment'; | ||
|
||
my $id = $o->post_service_request_update($comment); | ||
my $cgi = CGI::Simple->new($o->test_req_used->content); | ||
is $cgi->param('attribute[assigned_to_user_email]'), | ||
$superuser->email, | ||
'correct assigned_to_user_email attribute'; | ||
is $cgi->param('attribute[extra_details]'), | ||
'', | ||
'correct extra_details attribute'; | ||
|
||
$mech->get_ok( '/report/' . $problem_to_update->id ); | ||
$mech->submit_form_ok({ form_id => 'planned_form' }); | ||
$comment | ||
= $problem_to_update->comments->order_by('-id')->first; | ||
is_deeply $comment->get_extra_metadata, { | ||
shortlisted_user => undef, | ||
is_superuser => 1, | ||
}, 'Comment created for user un-assignment'; | ||
|
||
$id = $o->post_service_request_update($comment); | ||
$cgi = CGI::Simple->new($o->test_req_used->content); | ||
is $cgi->param('attribute[assigned_to_user_email]'), | ||
'', | ||
'correct assigned_to_user_email attribute'; | ||
is $cgi->param('attribute[extra_details]'), | ||
'', | ||
'correct extra_details attribute'; | ||
}; | ||
|
||
subtest "Extra details on $host site" => sub { | ||
$mech->get_ok( '/report/' . $problem_to_update->id ); | ||
$mech->submit_form( | ||
button => 'save', | ||
with_fields => { | ||
detailed_information => 'ABC', | ||
include_update => 0, | ||
}, | ||
); | ||
my $comment | ||
= $problem_to_update->comments->order_by('-id')->first; | ||
is_deeply $comment->get_extra_metadata, { | ||
detailed_information => 1, | ||
is_superuser => 1, | ||
}, 'Comment created for extra details'; | ||
|
||
my $id = $o->post_service_request_update($comment); | ||
my $cgi = CGI::Simple->new($o->test_req_used->content); | ||
is $cgi->param('attribute[assigned_to_user_email]'), | ||
'', | ||
'correct assigned_to_user_email attribute'; | ||
is $cgi->param('attribute[extra_details]'), | ||
'ABC', | ||
'correct extra_details attribute'; | ||
|
||
$mech->get_ok( '/report/' . $problem_to_update->id ); | ||
$mech->submit_form( | ||
button => 'save', | ||
with_fields => { | ||
detailed_information => '', | ||
include_update => 0, | ||
}, | ||
); | ||
$comment | ||
= $problem_to_update->comments->order_by('-id')->first; | ||
is_deeply $comment->get_extra_metadata, { | ||
detailed_information => 1, | ||
is_superuser => 1, | ||
}, 'Comment created for extra details unsetting'; | ||
is_deeply $problem_to_update->get_extra_metadata, | ||
{}, | ||
'Extra details unset on problem'; | ||
|
||
$id = $o->post_service_request_update($comment); | ||
$cgi = CGI::Simple->new($o->test_req_used->content); | ||
is $cgi->param('attribute[assigned_to_user_email]'), | ||
'', | ||
'correct assigned_to_user_email attribute'; | ||
is $cgi->param('attribute[extra_details]'), | ||
'', | ||
'correct extra_details attribute'; | ||
}; | ||
} | ||
}; | ||
|
||
done_testing(); |