Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-01-20 13:28:40 +0300
committerJarka Kadlecova <jarka@gitlab.com>2017-01-25 12:10:05 +0300
commit0c350b79395d6712c7c4fee649cdbd77aa4052cc (patch)
tree2899a67fbe65c29b84c35ab417dbec96913095c4 /app/models/concerns
parentbf708e55c2e6035b64861a1cda8bfe3d3b4a2105 (diff)
address comments
Diffstat (limited to 'app/models/concerns')
-rw-r--r--app/models/concerns/cache_markdown_field.rb8
-rw-r--r--app/models/concerns/mentionable.rb6
-rw-r--r--app/models/concerns/participable.rb3
3 files changed, 12 insertions, 5 deletions
diff --git a/app/models/concerns/cache_markdown_field.rb b/app/models/concerns/cache_markdown_field.rb
index 25970158e70..a600f9c14c5 100644
--- a/app/models/concerns/cache_markdown_field.rb
+++ b/app/models/concerns/cache_markdown_field.rb
@@ -51,6 +51,10 @@ module CacheMarkdownField
CACHING_CLASSES.map(&:constantize)
end
+ def skip_project_check?
+ false
+ end
+
extend ActiveSupport::Concern
included do
@@ -112,9 +116,7 @@ module CacheMarkdownField
invalidation_method = "#{html_field}_invalidated?".to_sym
define_method(cache_method) do
- options = {
- skip_project_check: is_a?(Note) && for_personal_snippet?
- }
+ options = { skip_project_check: skip_project_check? }
html = Banzai::Renderer.cacheless_render_field(self, markdown_field, options)
__send__("#{html_field}=", html)
true
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index 9ded015aad3..ef2c1e5d414 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -52,7 +52,7 @@ module Mentionable
options = options.merge(
cache_key: [self, attr],
author: author,
- skip_project_check: is_a?(Note) && for_personal_snippet?
+ skip_project_check: skip_project_check?
)
extractor.analyze(text, options)
@@ -125,4 +125,8 @@ module Mentionable
def cross_reference_exists?(target)
SystemNoteService.cross_reference_exists?(target, local_reference)
end
+
+ def skip_project_check?
+ false
+ end
end
diff --git a/app/models/concerns/participable.rb b/app/models/concerns/participable.rb
index 5d8a223fc21..4865c0a14b1 100644
--- a/app/models/concerns/participable.rb
+++ b/app/models/concerns/participable.rb
@@ -96,7 +96,8 @@ module Participable
participants.merge(ext.users)
- if self.is_a?(PersonalSnippet)
+ case self
+ when PersonalSnippet
Ability.users_that_can_read_personal_snippet(participants.to_a, self)
else
Ability.users_that_can_read_project(participants.to_a, project)