Commit a9aff2f7 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'adam-backport-ee-1406' into 'master'

Backport changes from gitlab-org/gitlab-ee!1406

See merge request !9897
parents e316958f 47270e1c
Pipeline #6987336 passed with stages
in 120 minutes and 53 seconds
module Gitlab module Gitlab
module Checks module Checks
class ChangeAccess class ChangeAccess
attr_reader :user_access, :project, :skip_authorization # protocol is currently used only in EE
attr_reader :user_access, :project, :skip_authorization, :protocol
def initialize( def initialize(
change, user_access:, project:, env: {}, skip_authorization: false) change, user_access:, project:, env: {}, skip_authorization: false,
protocol:
)
@oldrev, @newrev, @ref = change.values_at(:oldrev, :newrev, :ref) @oldrev, @newrev, @ref = change.values_at(:oldrev, :newrev, :ref)
@branch_name = Gitlab::Git.branch_name(@ref) @branch_name = Gitlab::Git.branch_name(@ref)
@user_access = user_access @user_access = user_access
@project = project @project = project
@env = env @env = env
@skip_authorization = skip_authorization @skip_authorization = skip_authorization
@protocol = protocol
end end
def exec def exec
......
...@@ -153,7 +153,9 @@ module Gitlab ...@@ -153,7 +153,9 @@ module Gitlab
user_access: user_access, user_access: user_access,
project: project, project: project,
env: @env, env: @env,
skip_authorization: deploy_key?).exec skip_authorization: deploy_key?,
protocol: protocol
).exec
end end
def matching_merge_request?(newrev, branch_name) def matching_merge_request?(newrev, branch_name)
......
...@@ -12,8 +12,16 @@ describe Gitlab::Checks::ChangeAccess, lib: true do ...@@ -12,8 +12,16 @@ describe Gitlab::Checks::ChangeAccess, lib: true do
ref: 'refs/heads/master' ref: 'refs/heads/master'
} }
end end
let(:protocol) { 'ssh' }
subject { described_class.new(changes, project: project, user_access: user_access).exec }
subject do
described_class.new(
changes,
project: project,
user_access: user_access,
protocol: protocol
).exec
end
before { allow(user_access).to receive(:can_do_action?).with(:push_code).and_return(true) } before { allow(user_access).to receive(:can_do_action?).with(:push_code).and_return(true) }
......
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