Commit 011fc17d authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'refactoring-ee-entities-8' into 'master'

Separate merge request approval rules in own class files

See merge request gitlab-org/gitlab!26860
parents e8e2c02a b02b3b14
---
title: Separate merge request approval entities into own class files
merge_request: 26860
author: Rajendra Kadam
type: added
......@@ -262,32 +262,6 @@ module EE
end
end
class ProjectApprovalRule < ApprovalRule
expose :protected_branches, using: ::API::Entities::ProtectedBranch, if: -> (rule, _) { rule.project.multiple_approval_rules_available? }
end
class MergeRequestApprovalRule < ApprovalRule
class SourceRule < Grape::Entity
expose :approvals_required
end
expose :source_rule, using: SourceRule
end
class MergeRequestApprovalStateRule < MergeRequestApprovalRule
expose :code_owner
expose :approved_approvers, as: :approved_by, using: ::API::Entities::UserBasic
expose :approved?, as: :approved
end
class MergeRequestApprovalState < Grape::Entity
expose :approval_rules_overwritten do |approval_state|
approval_state.approval_rules_overwritten?
end
expose :wrapped_approval_rules, as: :rules, using: MergeRequestApprovalStateRule
end
# Being used in private project-level approvals API.
# This overrides the `eligible_approvers` to be exposed as `approvers`.
#
......
# frozen_string_literal: true
module EE
module API
module Entities
class MergeRequestApprovalRule < ApprovalRule
class SourceRule < Grape::Entity
expose :approvals_required
end
expose :source_rule, using: MergeRequestApprovalRule::SourceRule
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class MergeRequestApprovalState < Grape::Entity
expose :approval_rules_overwritten do |approval_state|
approval_state.approval_rules_overwritten?
end
expose :wrapped_approval_rules, as: :rules, using: MergeRequestApprovalStateRule
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class MergeRequestApprovalStateRule < MergeRequestApprovalRule
expose :code_owner
expose :approved_approvers, as: :approved_by, using: ::API::Entities::UserBasic
expose :approved?, as: :approved
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class ProjectApprovalRule < ApprovalRule
expose :protected_branches, using: ::API::Entities::ProtectedBranch, if: -> (rule, _) { rule.project.multiple_approval_rules_available? }
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment