diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ability.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/project_features_compatibility.rb | 4 | ||||
-rw-r--r-- | app/models/event.rb | 6 | ||||
-rw-r--r-- | app/models/note.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/models/snippet.rb | 6 |
6 files changed, 12 insertions, 12 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index 1466407d0d1..671a92632d5 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -24,7 +24,7 @@ class Ability # read the given snippet. def users_that_can_read_personal_snippet(users, snippet) DeclarativePolicy.subject_scope do - users.select { |u| allowed?(u, :read_personal_snippet, snippet) } + users.select { |u| allowed?(u, :read_snippet, snippet) } end end diff --git a/app/models/concerns/project_features_compatibility.rb b/app/models/concerns/project_features_compatibility.rb index eac676f30a5..76d26500267 100644 --- a/app/models/concerns/project_features_compatibility.rb +++ b/app/models/concerns/project_features_compatibility.rb @@ -62,6 +62,10 @@ module ProjectFeaturesCompatibility write_feature_attribute_string(:snippets_access_level, value) end + def pages_access_level=(value) + write_feature_attribute_string(:pages_access_level, value) + end + private def write_feature_attribute_boolean(field, value) diff --git a/app/models/event.rb b/app/models/event.rb index 9611019adb8..35fb062311f 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -145,10 +145,8 @@ class Event < ApplicationRecord Ability.allowed?(user, :read_issue, note? ? note_target : target) elsif merge_request? || merge_request_note? Ability.allowed?(user, :read_merge_request, note? ? note_target : target) - elsif personal_snippet_note? - Ability.allowed?(user, :read_personal_snippet, note_target) - elsif project_snippet_note? - Ability.allowed?(user, :read_project_snippet, note_target) + elsif personal_snippet_note? || project_snippet_note? + Ability.allowed?(user, :read_snippet, note_target) elsif milestone? Ability.allowed?(user, :read_milestone, project) else diff --git a/app/models/note.rb b/app/models/note.rb index de9478ce68d..0434f0963d3 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -367,7 +367,7 @@ class Note < ApplicationRecord end def noteable_ability_name - for_snippet? ? noteable.class.name.underscore : noteable_type.demodulize.underscore + for_snippet? ? 'snippet' : noteable_type.demodulize.underscore end def can_be_discussion_note? diff --git a/app/models/project.rb b/app/models/project.rb index a73ca7d5bbb..236111cba94 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -322,7 +322,7 @@ class Project < ApplicationRecord :pages_enabled?, :public_pages?, :private_pages?, :merge_requests_access_level, :forking_access_level, :issues_access_level, :wiki_access_level, :snippets_access_level, :builds_access_level, - :repository_access_level, + :repository_access_level, :pages_access_level, to: :project_feature, allow_nil: true delegate :scheduled?, :started?, :in_progress?, :failed?, :finished?, prefix: :import, to: :import_state, allow_nil: true @@ -2274,7 +2274,7 @@ class Project < ApplicationRecord end def snippets_visible?(user = nil) - Ability.allowed?(user, :read_project_snippet, self) + Ability.allowed?(user, :read_snippet, self) end def max_attachment_size diff --git a/app/models/snippet.rb b/app/models/snippet.rb index b7f396681af..19685cdb78e 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -215,9 +215,7 @@ class Snippet < ApplicationRecord end def embeddable? - ability = project_id? ? :read_project_snippet : :read_personal_snippet - - Ability.allowed?(nil, ability, self) + Ability.allowed?(nil, :read_snippet, self) end def notes_with_associations @@ -240,7 +238,7 @@ class Snippet < ApplicationRecord end def to_ability_name - model_name.singular + 'snippet' end def valid_secret_token?(token) |