summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorMarius Mathiesen <marius@shortcut.no>2009-07-13 12:04:58 +0200
committerMarius Mathiesen <marius@shortcut.no>2009-07-13 12:06:33 +0200
commit7aeaa92122b12ab70e90bb36060a589dfa82383c (patch)
treed5b65878a462dfe8061c9e99f1b2fffb2d3ebec4 /app/models
parentf689bbd2b0f8342d8822f22ae8cf95199fa6d9ce (diff)
downloadgitorious-mainline-outdated-7aeaa92122b12ab70e90bb36060a589dfa82383c.zip
gitorious-mainline-outdated-7aeaa92122b12ab70e90bb36060a589dfa82383c.tar.gz
gitorious-mainline-outdated-7aeaa92122b12ab70e90bb36060a589dfa82383c.tar.bz2
Comment shouldn't require a body if they apply to a merge request and change its state
Diffstat (limited to 'app/models')
-rw-r--r--app/models/comment.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/comment.rb b/app/models/comment.rb
index f5a6367..b5d4986 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -36,7 +36,8 @@ class Comment < ActiveRecord::Base
attr_protected :user_id
- validates_presence_of :user_id, :target, :body, :project_id
+ validates_presence_of :user_id, :target, :project_id
+ validates_presence_of :body, :if => Proc.new {|mr| mr.body_required?}
named_scope :with_shas, proc{|*shas|
{:conditions => { :sha1 => shas.flatten }, :include => :user}
@@ -74,6 +75,14 @@ class Comment < ActiveRecord::Base
def state_changed_from
state_change.to_a.size > 1 ? state_change.first : nil
end
+
+ def body_required?
+ if applies_to_merge_request?
+ return state_change.blank?
+ else
+ return true
+ end
+ end
protected
def notify_target_if_supported