diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Northamptonshire.pm | 19 | ||||
-rw-r--r-- | t/cobrand/northamptonshire.t | 11 |
2 files changed, 30 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm index 7baeaba96..abea3bfd5 100644 --- a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm +++ b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm @@ -36,6 +36,25 @@ sub on_map_default_status { 'open' } sub report_sent_confirmation_email { 'id' } +has body_obj => ( + is => 'lazy', + default => sub { + FixMyStreet::DB->resultset('Body')->find({ name => 'Northamptonshire County Council' }); + }, +); + +sub updates_disallowed { + my $self = shift; + my ($problem) = @_; + + # Only open reports + return 1 if $problem->is_fixed || $problem->is_closed; + # Not on reports made by the body user + return 1 if $problem->user_id == $self->body_obj->comment_user_id; + + return $self->next::method(@_); +} + sub problems_on_map_restriction { my ($self, $rs) = @_; # Northamptonshire don't want to show district/borough reports diff --git a/t/cobrand/northamptonshire.t b/t/cobrand/northamptonshire.t index 09023f4c0..78f5e83e1 100644 --- a/t/cobrand/northamptonshire.t +++ b/t/cobrand/northamptonshire.t @@ -3,6 +3,8 @@ use Test::MockModule; use FixMyStreet::TestMech; use Open311::PostServiceRequestUpdates; +use_ok 'FixMyStreet::Cobrand::Northamptonshire'; + my $mech = FixMyStreet::TestMech->new; use open ':std', ':encoding(UTF-8)'; @@ -94,4 +96,13 @@ subtest 'check updates sent for non defects' => sub { is $comment->send_fail_count, 1, "comment sending attempted"; }; +subtest 'check updates disallowed correctly' => sub { + my $cobrand = FixMyStreet::Cobrand::Northamptonshire->new; + is $cobrand->updates_disallowed($report), 0; + $report->update({ state => 'closed' }); + is $cobrand->updates_disallowed($report), 1; + $report->update({ state => 'confirmed', user => $counciluser }); + is $cobrand->updates_disallowed($report), 1; +}; + done_testing(); |