summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2013-01-15 00:52:25 +0100
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2013-01-15 00:52:25 +0100
commit30227869482bbbdbfea153f2b45ef3bb9a9fd218 (patch)
treeaff64071116447092751770d2896998f62d1b44a /app/models/note.rb
parent8ee5fce9d64b70d8981896457484fae622d142c9 (diff)
parentaca0caa8cc1a6bd481f87dd810284e69d3747050 (diff)
downloadgitlab-ce-30227869482bbbdbfea153f2b45ef3bb9a9fd218.tar.gz
Merge commit 'master' into discussions
Conflicts: app/assets/stylesheets/sections/notes.scss app/contexts/notes/load_context.rb app/models/project.rb app/observers/note_observer.rb app/roles/votes.rb app/views/commit/show.html.haml app/views/merge_requests/_show.html.haml app/views/merge_requests/diffs.js.haml app/views/merge_requests/show.js.haml app/views/notes/_note.html.haml features/steps/project/project_merge_requests.rb spec/models/note_spec.rb
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index b62b3fe61d5..3ad03cc601b 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -4,7 +4,6 @@
#
# id :integer not null, primary key
# note :text
-# noteable_id :string(255)
# noteable_type :string(255)
# author_id :integer
# created_at :datetime not null
@@ -12,6 +11,8 @@
# project_id :integer
# attachment :string(255)
# line_code :string(255)
+# commit_id :string(255)
+# noteable_id :integer
#
require 'carrierwave/orm/activerecord'
@@ -41,11 +42,11 @@ class Note < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
# Scopes
- scope :for_commits, ->{ where(noteable_type: "Commit") }
- scope :common, ->{ where(noteable_id: nil, commit_id: nil) }
- scope :today, ->{ where("created_at >= :date", date: Date.today) }
- scope :last_week, ->{ where("created_at >= :date", date: (Date.today - 7.days)) }
- scope :since, ->(day) { where("created_at >= :date", date: (day)) }
+ scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) }
+ scope :inline, where("line_code IS NOT NULL")
+ scope :not_inline, where("line_code IS NULL")
+
+ scope :common, ->{ where(noteable_type: ["", nil]) }
scope :fresh, ->{ order("created_at ASC, id ASC") }
scope :inc_author_project, ->{ includes(:project, :author) }
scope :inc_author, ->{ includes(:author) }
@@ -126,7 +127,7 @@ class Note < ActiveRecord::Base
# override to return commits, which are not active record
def noteable
if for_commit?
- project.commit(commit_id)
+ project.repository.commit(commit_id)
else
super
end