diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-11-25 11:05:34 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-11-25 11:05:34 +0100 |
commit | 895d97af87c66f4763e8d1fc0ef6cae19924b18d (patch) | |
tree | 09a596fb057d11bf94d7c3a323f38049061c6518 /spec/models/merge_request_spec.rb | |
parent | 0a5a65df0c7d08e3ce041e10906549313a9ad156 (diff) | |
parent | afe90d529c82566886d1f2513dd6bee4fa73ff94 (diff) | |
download | gitlab-ce-895d97af87c66f4763e8d1fc0ef6cae19924b18d.tar.gz |
Merge branch 'master' into fix/rename-mwbs-to-merge-when-pipeline-succeeds
* master: (312 commits)
Fix bad selection on dropdown menu for tags filter
Fixed issue boards scrolling with a lot of lists & issues
You can only assign default_branch when editing a project ...
Don't convert data which already is the target type
Stop supporting Google and Azure as backup strategies
renames some of the specs and adds changelog entry
Fixed dragging issue moving wrong issue after multiple drags of issue
Fixed issue boards issue sorting when dragging issue into list
Rephrase some system notes to be compatible with new system note style
Add missing JIRA file that redirects to the new location
Fix documentation to create the `pg_trm` extension before creating the DB
Document that we always use `do...end` for `before` in RSpec
Backport Note#commands_changes from EE
Log mv_namespace parameters
Add default_branch attr to Project API payload in docs.
Fix title case to sentence case
properly escape username validation error message flash
Remove header ids from University docs
Add missing documentation.
Added test that checks the correct select box is there for the LFS ...
...
Conflicts:
app/services/system_note_service.rb
spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb
spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb
spec/services/system_note_service_spec.rb
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r-- | spec/models/merge_request_spec.rb | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index e295a920b45..19baf238b8d 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -856,13 +856,31 @@ describe MergeRequest, models: true do context 'when it is only allowed to merge when build is green' do context 'and a failed pipeline is associated' do before do - pipeline.statuses << create(:commit_status, status: 'failed', project: project) + pipeline.update(status: 'failed') allow(subject).to receive(:pipeline) { pipeline } end it { expect(subject.mergeable_ci_state?).to be_falsey } end + context 'and a successful pipeline is associated' do + before do + pipeline.update(status: 'success') + allow(subject).to receive(:pipeline) { pipeline } + end + + it { expect(subject.mergeable_ci_state?).to be_truthy } + end + + context 'and a skipped pipeline is associated' do + before do + pipeline.update(status: 'skipped') + allow(subject).to receive(:pipeline) { pipeline } + end + + it { expect(subject.mergeable_ci_state?).to be_truthy } + end + context 'when no pipeline is associated' do before do allow(subject).to receive(:pipeline) { nil } @@ -919,6 +937,16 @@ describe MergeRequest, models: true do expect(merge_request.mergeable_discussions_state?).to be_falsey end end + + context 'with no discussions' do + before do + merge_request.notes.destroy_all + end + + it 'returns true' do + expect(merge_request.mergeable_discussions_state?).to be_truthy + end + end end context 'when project.only_allow_merge_if_all_discussions_are_resolved == false' do @@ -1180,6 +1208,50 @@ describe MergeRequest, models: true do end end end + + describe "#discussions_to_be_resolved?" do + context "when discussions are not resolvable" do + before do + allow(subject).to receive(:discussions_resolvable?).and_return(false) + end + + it "returns false" do + expect(subject.discussions_to_be_resolved?).to be false + end + end + + context "when discussions are resolvable" do + before do + allow(subject).to receive(:discussions_resolvable?).and_return(true) + + allow(first_discussion).to receive(:resolvable?).and_return(true) + allow(second_discussion).to receive(:resolvable?).and_return(false) + allow(third_discussion).to receive(:resolvable?).and_return(true) + end + + context "when all resolvable discussions are resolved" do + before do + allow(first_discussion).to receive(:resolved?).and_return(true) + allow(third_discussion).to receive(:resolved?).and_return(true) + end + + it "returns false" do + expect(subject.discussions_to_be_resolved?).to be false + end + end + + context "when some resolvable discussions are not resolved" do + before do + allow(first_discussion).to receive(:resolved?).and_return(true) + allow(third_discussion).to receive(:resolved?).and_return(false) + end + + it "returns true" do + expect(subject.discussions_to_be_resolved?).to be true + end + end + end + end end describe '#conflicts_can_be_resolved_in_ui?' do |