diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-05-24 11:49:54 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-05-24 11:49:54 +0300 |
commit | e97a87433b2f55b2f688771cbe47d627f49d4b44 (patch) | |
tree | 68b698985cca79d2d9b1351ec186b356e5e3bec2 /spec/presenters | |
parent | 56d2d462271da802a0126fa588f7ae76ae18f09f (diff) | |
parent | 13aa6f6740118743e47f24f01aa54fed30079f4d (diff) |
Merge branch 'mr-conflict-notification' into 'master'
MR unmergeable notification
See merge request gitlab-org/gitlab-ce!18042
Diffstat (limited to 'spec/presenters')
-rw-r--r-- | spec/presenters/merge_request_presenter_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb index e3b37739e8e..d5fb4a7742c 100644 --- a/spec/presenters/merge_request_presenter_spec.rb +++ b/spec/presenters/merge_request_presenter_spec.rb @@ -70,6 +70,41 @@ describe MergeRequestPresenter do end end + describe "#unmergeable_reasons" do + let(:presenter) { described_class.new(resource, current_user: user) } + + before do + # Mergeable base state + allow(resource).to receive(:has_no_commits?).and_return(false) + allow(resource).to receive(:source_branch_exists?).and_return(true) + allow(resource).to receive(:target_branch_exists?).and_return(true) + allow(resource.project.repository).to receive(:can_be_merged?).and_return(true) + end + + it "handles mergeable request" do + expect(presenter.unmergeable_reasons).to eq([]) + end + + it "handles no commit" do + allow(resource).to receive(:has_no_commits?).and_return(true) + + expect(presenter.unmergeable_reasons).to eq(["no commits"]) + end + + it "handles branches missing" do + allow(resource).to receive(:source_branch_exists?).and_return(false) + allow(resource).to receive(:target_branch_exists?).and_return(false) + + expect(presenter.unmergeable_reasons).to eq(["source branch is missing", "target branch is missing"]) + end + + it "handles merge conflict" do + allow(resource.project.repository).to receive(:can_be_merged?).and_return(false) + + expect(presenter.unmergeable_reasons).to eq(["has merge conflicts"]) + end + end + describe '#conflict_resolution_path' do let(:project) { create :project } let(:user) { create :user } |