summaryrefslogtreecommitdiff
path: root/app/models/snippet.rb
diff options
context:
space:
mode:
authorMark Chao <mchao@gitlab.com>2018-12-11 14:28:06 +0800
committerMark Chao <mchao@gitlab.com>2018-12-20 14:32:51 +0800
commit30c6db8f0354847c275335c120d7218c0098c41f (patch)
tree921d83eea0ca710a95b028775557816cbc341e57 /app/models/snippet.rb
parent00096b52ced2962d237540c494f2ad6c3add70ef (diff)
downloadgitlab-ce-30c6db8f0354847c275335c120d7218c0098c41f.tar.gz
Move embeddable? to model to be used outside view
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r--app/models/snippet.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 11856b55902..e623ee8161f 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -175,6 +175,14 @@ class Snippet < ActiveRecord::Base
:visibility_level
end
+ def embeddable?
+ if project_id?
+ Ability.allowed?(nil, :read_project_snippet, self)
+ else
+ Ability.allowed?(nil, :read_personal_snippet, self)
+ end
+ end
+
def notes_with_associations
notes.includes(:author)
end