diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-10-06 14:07:53 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-10-11 16:17:32 +0100 |
commit | e1038dac8f5ba0fe2f20781468b3cbe763b7ed68 (patch) | |
tree | 92bac1075a1de16b80cc411b0add8b2aa11f38f6 | |
parent | 9fc69a31cda118948e3714bc7f4fff9d0a3ca84e (diff) |
Fix bug in fetching existing shortlisted report.
It would always create a new report rather than return an existing one,
if present.
-rw-r--r-- | perllib/FixMyStreet/DB/Result/User.pm | 2 | ||||
-rw-r--r-- | t/app/model/user_planned_report.t | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm index 8d42d5926..7aa7a3272 100644 --- a/perllib/FixMyStreet/DB/Result/User.pm +++ b/perllib/FixMyStreet/DB/Result/User.pm @@ -355,7 +355,7 @@ sub adopt { around add_to_planned_reports => sub { my ( $orig, $self ) = ( shift, shift ); my ( $report_col ) = @_; - my $existing = $self->user_planned_reports->search_rs({ report_id => $report_col->{id}, removed => undef })->first; + my $existing = $self->user_planned_reports->search_rs({ report_id => $report_col->id, removed => undef })->first; return $existing if $existing; return $self->$orig(@_); }; diff --git a/t/app/model/user_planned_report.t b/t/app/model/user_planned_report.t index 6c0823044..a9c2ee9b5 100644 --- a/t/app/model/user_planned_report.t +++ b/t/app/model/user_planned_report.t @@ -19,6 +19,10 @@ $user->add_to_planned_reports($problem); is $user->active_planned_reports, 1; is $user->planned_reports, 1; +$user->add_to_planned_reports($problem); +is $user->active_planned_reports, 1; +is $user->planned_reports, 1; + $user->remove_from_planned_reports($problem); is $user->active_planned_reports, 0; is $user->planned_reports, 1; |