diff options
author | Struan Donald <struan@exo.org.uk> | 2012-11-22 19:26:18 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-11-22 19:29:01 +0000 |
commit | bacba6c39090cbd6dfbca7f89303480e1dcc742a (patch) | |
tree | e74e20d7b86fa91b86aee116fe522fcb527c5393 /t | |
parent | 0492b90bdb2a4666f85cdab3d8f636910bbe40c1 (diff) |
use the problem_state of the comment to set the update state rather
than the state of the problem in case a second update has changed the
problem state since. On the of chance that there is no problem_state
for the comment then fall back to the state of the problem
Diffstat (limited to 't')
-rw-r--r-- | t/open311.t | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/t/open311.t b/t/open311.t index e897d3524..f9315982d 100644 --- a/t/open311.t +++ b/t/open311.t @@ -191,6 +191,7 @@ my $comment = FixMyStreet::App->model('DB::Comment')->new( { anonymous => 0, text => 'this is a comment', confirmed => $dt, + problem_state => 'confirmed', extra => { title => 'Mr', email_alerts_requested => 0 }, } ); @@ -317,6 +318,7 @@ foreach my $test ( }, ) { subtest $test->{desc} => sub { + $comment->problem_state( $test->{state} ); $comment->problem->state( $test->{state} ); $comment->anonymous( $test->{anon} ); @@ -334,6 +336,59 @@ foreach my $test ( }; } +my $dt2 = $dt->clone; +$dt2->add( 'minutes' => 1 ); + +my $comment2 = FixMyStreet::App->model('DB::Comment')->new( { + id => 38363, + user => $user, + problem => $problem, + anonymous => 0, + text => 'this is a comment', + confirmed => $dt, + problem_state => 'confirmed', + extra => { title => 'Mr', email_alerts_requested => 0 }, +} ); + +for my $test ( + { + desc => 'comment with fixed - council state sends status of CLOSED even if problem is open', + state => 'fixed - council', + problem_state => 'confirmed', + status => 'CLOSED', + extended => 'FIXED', + }, + { + desc => 'comment marked open sends status of OPEN even if problem is closed', + state => 'confirmed', + problem_state => 'fixed - council', + status => 'OPEN', + extended => 'OPEN', + }, + { + desc => 'comment with no problem state falls back to report state', + state => '', + problem_state => 'fixed - council', + status => 'CLOSED', + extended => 'FIXED', + }, +) { + subtest $test->{desc} => sub { + $comment->problem_state( $test->{state} ); + $comment->problem->state( $test->{problem_state} ); + my $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>' ); + + my $c = CGI::Simple->new( $results->{ req }->content ); + is $c->param('status'), $test->{status}, 'correct status'; + + if ( $test->{extended} ) { + my $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>', { extended_statuses => 1 } ); + my $c = CGI::Simple->new( $results->{ req }->content ); + is $c->param('status'), $test->{extended}, 'correct extended status'; + } + }; +} + for my $test ( { |