summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-03-18 10:27:26 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-03-18 11:07:30 -0300
commit2eeeb266e36abdbe78be8f71081bb19e83175819 (patch)
tree040cee798731e6ef3392337817273bff32b1a9e9
parenta5bad46505d152fe824fb9c51cb15a2a45caff14 (diff)
downloadgitlab-ce-2eeeb266e36abdbe78be8f71081bb19e83175819.tar.gz
Reuse `for_commit?` on conditional validations
-rw-r--r--app/models/todo.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/todo.rb b/app/models/todo.rb
index 024cdcc0d87..4be5806b8d1 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -29,8 +29,8 @@ class Todo < ActiveRecord::Base
delegate :name, :email, to: :author, prefix: true, allow_nil: true
validates :action, :project, :target_type, :user, presence: true
- validates :target_id, presence: true, if: ->(t) { t.target_type.present? && t.target_type != 'Commit' }
- validates :commit_id, presence: true, if: ->(t) { t.target_type.present? && t.target_type == 'Commit' }
+ validates :target_id, presence: true, unless: :for_commit?
+ validates :commit_id, presence: true, if: :for_commit?
default_scope { reorder(id: :desc) }