Merge branch 'frozen-string-enable-app-presenters' into 'master'
Enable frozen string in presenters and policies See merge request gitlab-org/gitlab-ce!20819
This commit is contained in:
commit
891cb10fc9
49 changed files with 101 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationSetting
|
||||
class TermPolicy < BasePolicy
|
||||
include Gitlab::Utils::StrongMemoize
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_dependency 'declarative_policy'
|
||||
|
||||
class BasePolicy < DeclarativePolicy::Base
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Ci
|
||||
class BuildPolicy < CommitStatusPolicy
|
||||
condition(:protected_ref) do
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Ci
|
||||
class PipelinePolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Ci
|
||||
class PipelineSchedulePolicy < PipelinePolicy
|
||||
alias_method :pipeline_schedule, :subject
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Ci
|
||||
class RunnerPolicy < BasePolicy
|
||||
with_options scope: :subject, score: 0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Ci
|
||||
class TriggerPolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Clusters
|
||||
class ClusterPolicy < BasePolicy
|
||||
alias_method :cluster, :subject
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CommitStatusPolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DeployKeyPolicy < BasePolicy
|
||||
with_options scope: :subject, score: 0
|
||||
condition(:private_deploy_key) { @subject.private? }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DeployTokenPolicy < BasePolicy
|
||||
with_options scope: :subject, score: 0
|
||||
condition(:maintainer) { @subject.project.team.maintainer?(@user) }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DeploymentPolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class EnvironmentPolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ExternalIssuePolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class GlobalPolicy < BasePolicy
|
||||
desc "User is blocked"
|
||||
with_options scope: :user, score: 0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class GroupLabelPolicy < BasePolicy
|
||||
delegate { @subject.group }
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class GroupMemberPolicy < BasePolicy
|
||||
delegate :group
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class GroupPolicy < BasePolicy
|
||||
desc "Group is public"
|
||||
with_options scope: :subject, score: 0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class IssuablePolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class IssuePolicy < IssuablePolicy
|
||||
# This class duplicates the same check of Issue#readable_by? for performance reasons
|
||||
# Make sure to sync this class checks with issue.rb to avoid security problems.
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MergeRequestPolicy < IssuablePolicy
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class NamespacePolicy < BasePolicy
|
||||
rule { anonymous }.prevent_all
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class NilPolicy < BasePolicy
|
||||
rule { default }.prevent_all
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class NotePolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
delegate { @subject.noteable if DeclarativePolicy.has_policy?(@subject.noteable) }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class PersonalSnippetPolicy < BasePolicy
|
||||
condition(:public_snippet, scope: :subject) { @subject.public? }
|
||||
condition(:is_author) { @user && @subject.author == @user }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProjectLabelPolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProjectMemberPolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProjectPolicy < BasePolicy
|
||||
extend ClassMethods
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProjectPolicy
|
||||
module ClassMethods
|
||||
def create_read_update_admin_destroy(name)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProjectSnippetPolicy < BasePolicy
|
||||
delegate :project
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProtectedBranchPolicy < BasePolicy
|
||||
delegate { @subject.project }
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UserPolicy < BasePolicy
|
||||
desc "The current user is the user in question"
|
||||
condition(:user_is_self, score: 0) { @subject == @user }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Ci
|
||||
class BuildMetadataPresenter < Gitlab::View::Presenter::Delegated
|
||||
TIMEOUT_SOURCES = {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Ci
|
||||
class BuildPresenter < CommitStatusPresenter
|
||||
def erased_by_user?
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Ci
|
||||
class GroupVariablePresenter < Gitlab::View::Presenter::Delegated
|
||||
presents :variable
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Ci
|
||||
class PipelinePresenter < Gitlab::View::Presenter::Delegated
|
||||
include Gitlab::Utils::StrongMemoize
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Ci
|
||||
class VariablePresenter < Gitlab::View::Presenter::Delegated
|
||||
presents :variable
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Clusters
|
||||
class ClusterPresenter < Gitlab::View::Presenter::Delegated
|
||||
presents :cluster
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
|
||||
CALLOUT_FAILURE_MESSAGES = {
|
||||
unknown_failure: 'There is an unknown failure, please try again',
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ConversationalDevelopmentIndex
|
||||
class MetricPresenter < Gitlab::View::Presenter::Simple
|
||||
def cards
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class GenericCommitStatusPresenter < CommitStatusPresenter
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class GroupMemberPresenter < MemberPresenter
|
||||
private
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MemberPresenter < Gitlab::View::Presenter::Delegated
|
||||
presents :member
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MembersPresenter < Gitlab::View::Presenter::Delegated
|
||||
include Enumerable
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include GitlabRoutingHelper
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProjectMemberPresenter < MemberPresenter
|
||||
private
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProjectPresenter < Gitlab::View::Presenter::Delegated
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Projects
|
||||
module Settings
|
||||
class DeployKeysPresenter < Gitlab::View::Presenter::Simple
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Enable frozen string in app/presenters and app/policies
|
||||
merge_request: 20819
|
||||
author: gfyoung
|
||||
type: performance
|
Loading…
Reference in a new issue