diff options
author | Mark Chao <mchao@gitlab.com> | 2018-12-11 14:28:06 +0800 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-12-20 14:32:51 +0800 |
commit | 30c6db8f0354847c275335c120d7218c0098c41f (patch) | |
tree | 921d83eea0ca710a95b028775557816cbc341e57 /app/models/snippet.rb | |
parent | 00096b52ced2962d237540c494f2ad6c3add70ef (diff) | |
download | gitlab-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.rb | 8 |
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 |