diff options
author | Rémy Coutable <remy@rymai.me> | 2019-03-25 15:11:57 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-03-25 15:11:57 +0000 |
commit | 1f42dd868b3410cff688193bad0ca25673b18ce6 (patch) | |
tree | 1e30dff79604c605d1dc8218777ccd451be4f3ff /spec | |
parent | 722ac2c9ae6663e9cca9239e33a2a5c3d7e1c828 (diff) | |
parent | 1c0588e7173dc9a545434f4bad41172f9fe145e5 (diff) | |
download | gitlab-ce-1f42dd868b3410cff688193bad0ca25673b18ce6.tar.gz |
Merge branch 'ce-6543-extract-ee-specific-files-lines-for-some-discussion-tests' into 'master'
Resolve CE/EE differences in MergeRequestPresenter spec
See merge request gitlab-org/gitlab-ce!26546
Diffstat (limited to 'spec')
-rw-r--r-- | spec/presenters/merge_request_presenter_spec.rb | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb index fd03f594c35..4a0f91c4c7a 100644 --- a/spec/presenters/merge_request_presenter_spec.rb +++ b/spec/presenters/merge_request_presenter_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe MergeRequestPresenter do - let(:resource) { create :merge_request, source_project: project } - let(:project) { create :project } + let(:resource) { create(:merge_request, source_project: project) } + let(:project) { create(:project) } let(:user) { create(:user) } describe '#ci_status' do @@ -523,4 +523,46 @@ describe MergeRequestPresenter do end end end + + describe '#can_push_to_source_branch' do + before do + allow(resource).to receive(:source_branch_exists?) { source_branch_exists } + + allow_any_instance_of(Gitlab::UserAccess::RequestCacheExtension) + .to receive(:can_push_to_branch?) + .with(resource.source_branch) + .and_return(can_push_to_branch) + end + + subject do + described_class.new(resource, current_user: user).can_push_to_source_branch? + end + + context 'when source branch exists AND user can push to source branch' do + let(:source_branch_exists) { true } + let(:can_push_to_branch) { true } + + it 'returns true' do + is_expected.to eq(true) + end + end + + context 'when source branch does not exists' do + let(:source_branch_exists) { false } + let(:can_push_to_branch) { true } + + it 'returns false' do + is_expected.to eq(false) + end + end + + context 'when user cannot push to source branch' do + let(:source_branch_exists) { true } + let(:can_push_to_branch) { false } + + it 'returns false' do + is_expected.to eq(false) + end + end + end end |