summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-29 15:01:54 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-29 15:01:54 +0000
commita1c45338f37560b044f23f1af07fea7bef2107cd (patch)
treead9deb2fe7158f1cd52f9599255c013784eae8c0 /spec
parentab2e67550b350efb73a397a53040ec9c46966b0d (diff)
parent5e4384ec9bc5e015c6a5427e337d8f5412e91d1e (diff)
downloadgitlab-ce-a1c45338f37560b044f23f1af07fea7bef2107cd.tar.gz
Merge branch 'support-edit-target-branch-in-mr' into 'master'
Support editing target branch of merge request ### What does this MR do? This MR makes it possible to edit the target branch of a merge request and adds a system note when this happens. ### Why was this MR needed? Because lots of people requested this feature. :) ### Screenshots **Edit MR page** ![image](https://gitlab.com/gitlab-org/gitlab-ce/uploads/9b3d405bf7b5f945e35bae3534c2b67b/image.png) **New MR page** ![image](https://gitlab.com/gitlab-org/gitlab-ce/uploads/3657a2a9efad6d10e8470637d1166bdb/image.png) **System note** ![image](https://gitlab.com/gitlab-org/gitlab-ce/uploads/cc8066f3d3bdf09c0cce27193210567d/image.png) ### What are the relevant issue numbers? * Closes https://github.com/gitlabhq/gitlabhq/issues/7105 * See: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/130! See merge request !738
Diffstat (limited to 'spec')
-rw-r--r--spec/services/merge_requests/update_service_spec.rb11
-rw-r--r--spec/services/system_note_service_spec.rb14
2 files changed, 24 insertions, 1 deletions
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb
index 0a0760056cf..c75173c1452 100644
--- a/spec/services/merge_requests/update_service_spec.rb
+++ b/spec/services/merge_requests/update_service_spec.rb
@@ -20,7 +20,8 @@ describe MergeRequests::UpdateService do
description: 'Also please fix',
assignee_id: user2.id,
state_event: 'close',
- label_ids: [label.id]
+ label_ids: [label.id],
+ target_branch: 'target'
}
end
@@ -39,6 +40,7 @@ describe MergeRequests::UpdateService do
it { expect(@merge_request).to be_closed }
it { expect(@merge_request.labels.count).to eq(1) }
it { expect(@merge_request.labels.first.title).to eq('Bug') }
+ it { expect(@merge_request.target_branch).to eq('target') }
it 'should execute hooks with update action' do
expect(service).to have_received(:execute_hooks).
@@ -77,6 +79,13 @@ describe MergeRequests::UpdateService do
expect(note).not_to be_nil
expect(note.note).to eq 'Title changed from **Old title** to **New title**'
end
+
+ it 'creates system note about branch change' do
+ note = find_note('Target')
+
+ expect(note).not_to be_nil
+ expect(note.note).to eq 'Target branch changed from `master` to `target`'
+ end
end
end
end
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index 0dcc94e8bd4..700286b585a 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -228,6 +228,20 @@ describe SystemNoteService do
end
end
+ describe '.change_branch' do
+ subject { described_class.change_branch(noteable, project, author, 'target', old_branch, new_branch) }
+ let(:old_branch) { 'old_branch'}
+ let(:new_branch) { 'new_branch'}
+
+ it_behaves_like 'a system note'
+
+ context 'when target branch name changed' do
+ it 'sets the note text' do
+ expect(subject.note).to eq "Target branch changed from `#{old_branch}` to `#{new_branch}`"
+ end
+ end
+ end
+
describe '.cross_reference' do
subject { described_class.cross_reference(noteable, mentioner, author) }