diff options
Diffstat (limited to 'app/models/todo.rb')
-rw-r--r-- | app/models/todo.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/app/models/todo.rb b/app/models/todo.rb index aefd9d5ef28..6b71845856a 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -89,11 +89,12 @@ class Todo < ApplicationRecord ]) end - # Returns `true` if the current user has any todos for the given target. + # Returns `true` if the current user has any todos for the given target with the optional given state. # # target - The value of the `target_type` column, such as `Issue`. - def any_for_target?(target) - exists?(target: target) + # state - The value of the `state` column, such as `pending` or `done`. + def any_for_target?(target, state = nil) + state.nil? ? exists?(target: target) : exists?(target: target, state: state) end # Updates the state of a relation of todos to the new state. |