diff options
author | Adam Niedzielski <adamsunday@gmail.com> | 2017-03-13 12:31:27 +0100 |
---|---|---|
committer | Adam Niedzielski <adamsunday@gmail.com> | 2017-03-13 12:31:27 +0100 |
commit | 47270e1cfdee8e54bc7cc7f4b374ce795a1797fc (patch) | |
tree | 65d155525b14eb2d9bb4dfc4d341c645e58ca387 | |
parent | 32da7602686f2b8161175d82b121deb9e01b2db5 (diff) | |
download | gitlab-ce-47270e1cfdee8e54bc7cc7f4b374ce795a1797fc.tar.gz |
Backport changes from gitlab-org/gitlab-ee!1406adam-backport-ee-1406
-rw-r--r-- | lib/gitlab/checks/change_access.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/git_access.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/checks/change_access_spec.rb | 12 |
3 files changed, 19 insertions, 5 deletions
diff --git a/lib/gitlab/checks/change_access.rb b/lib/gitlab/checks/change_access.rb index 273118135a9..c85f79127bc 100644 --- a/lib/gitlab/checks/change_access.rb +++ b/lib/gitlab/checks/change_access.rb @@ -1,16 +1,20 @@ module Gitlab module Checks 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( - 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) @branch_name = Gitlab::Git.branch_name(@ref) @user_access = user_access @project = project @env = env @skip_authorization = skip_authorization + @protocol = protocol end def exec diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index ffb178334bc..eea2f206902 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -153,7 +153,9 @@ module Gitlab user_access: user_access, project: project, env: @env, - skip_authorization: deploy_key?).exec + skip_authorization: deploy_key?, + protocol: protocol + ).exec end def matching_merge_request?(newrev, branch_name) diff --git a/spec/lib/gitlab/checks/change_access_spec.rb b/spec/lib/gitlab/checks/change_access_spec.rb index cadfbadca10..e22f88b7a32 100644 --- a/spec/lib/gitlab/checks/change_access_spec.rb +++ b/spec/lib/gitlab/checks/change_access_spec.rb @@ -12,8 +12,16 @@ describe Gitlab::Checks::ChangeAccess, lib: true do ref: 'refs/heads/master' } end - - subject { described_class.new(changes, project: project, user_access: user_access).exec } + let(:protocol) { 'ssh' } + + 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) } |