summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-10-13 16:23:12 +0200
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-10-13 16:23:12 +0200
commitb1461de993daf6d43c8a54482eecacc6bb58df4d (patch)
tree56ed0f0fda021640620a824a261170c8e14aca0e /app/models/note.rb
parentdb3d90cbcb41c5b9a62998b185c90c10f9d03968 (diff)
downloadgitlab-ce-b1461de993daf6d43c8a54482eecacc6bb58df4d.tar.gz
Make Note methods saner
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index ae51e486675..e2f4a89d7d6 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -48,11 +48,12 @@ class Note < ActiveRecord::Base
@notify_author ||= false
end
- def target
- if commit?
+ # override to return commits, which are not active record
+ def noteable
+ if for_commit?
project.commit(noteable_id)
else
- noteable
+ super
end
# Temp fix to prevent app crash
# if note commit id doesnt exist
@@ -74,22 +75,22 @@ class Note < ActiveRecord::Base
# Boolean
#
def notify_only_author?(user)
- commit? && commit_author &&
+ for_commit? && commit_author &&
commit_author.email != user.email
end
- def commit?
+ def for_commit?
noteable_type == "Commit"
end
- def line_note?
+ def for_diff_line?
line_code.present?
end
def commit_author
@commit_author ||=
- project.users.find_by_email(target.author_email) ||
- project.users.find_by_name(target.author_name)
+ project.users.find_by_email(noteable.author_email) ||
+ project.users.find_by_name(noteable.author_name)
rescue
nil
end