Commit d77d8964 authored by Tiago Botelho's avatar Tiago Botelho

Refactors EE project entity when verifying it mirroring is available

parent f5c8b4c6
......@@ -19,10 +19,18 @@ module EE
expose :repository_storage, if: ->(_project, options) { options[:current_user].try(:admin?) }
expose :approvals_before_merge, if: ->(project, _) { project.feature_available?(:merge_request_approvers) }
expose :mirror, if: ->(project, _) { project.feature_available?(:repository_mirrors) }
expose :mirror_user_id, if: ->(project, _) { project.mirror? && project.feature_available?(:repository_mirrors) }
expose :mirror_trigger_builds, if: ->(project, _) { project.mirror? && project.feature_available?(:repository_mirrors) }
expose :only_mirror_protected_branches, if: ->(project, _) { project.mirror? && project.feature_available?(:repository_mirrors) }
expose :mirror_overwrites_diverged_branches, if: ->(project, _) { project.mirror? && project.feature_available?(:repository_mirrors) }
expose :mirror_user_id, if: ->(project, _) { mirroring_available? }
expose :mirror_trigger_builds, if: ->(project, _) { mirroring_available? }
expose :only_mirror_protected_branches, if: ->(project, _) { mirroring_available? }
expose :mirror_overwrites_diverged_branches, if: ->(project, _) { mirroring_available? }
private
alias_method :project, :object
def mirroring_available?
project.mirror? && project.feature_available?(:repository_mirrors)
end
end
end
......
......@@ -4,6 +4,7 @@ describe API::Projects do
include ExternalAuthorizationServiceHelpers
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
describe 'POST /projects' do
context 'when importing with mirror attributes' do
......
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