summaryrefslogtreecommitdiff
path: root/app/models/snippet.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-21 15:23:20 +0200
committerDouwe Maan <douwe@gitlab.com>2015-04-24 12:30:36 +0200
commite739eb036df23db4a03681190bf07ba0b8f1302c (patch)
tree599e01be53f1818f2d7260734fc0dd4fab71dcff /app/models/snippet.rb
parent0ff778c0f4a3b599d0f36a1deee5607d03e52b9a (diff)
downloadgitlab-ce-e739eb036df23db4a03681190bf07ba0b8f1302c.tar.gz
Move participants method to shared Participable concern.
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r--app/models/snippet.rb15
1 files changed, 3 insertions, 12 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index c11c28805eb..d2af26539b6 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -19,6 +19,7 @@ class Snippet < ActiveRecord::Base
include Sortable
include Linguist::BlobHelper
include Gitlab::VisibilityLevel
+ include Participable
default_value_for :visibility_level, Snippet::PRIVATE
@@ -47,6 +48,8 @@ class Snippet < ActiveRecord::Base
scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) }
scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) }
+ participant :author, :notes
+
def self.content_types
[
".rb", ".py", ".pl", ".scala", ".c", ".cpp", ".java",
@@ -87,18 +90,6 @@ class Snippet < ActiveRecord::Base
visibility_level
end
- def participants(current_user = self.author)
- users = []
- users << author
-
- notes.each do |note|
- users << note.author
- users.push *note.mentioned_users(current_user)
- end
-
- users.uniq
- end
-
class << self
def search(query)
where('(title LIKE :query OR file_name LIKE :query)', query: "%#{query}%")