diff options
author | YarNayar <YarTheGreat@gmail.com> | 2017-01-31 16:27:29 +0300 |
---|---|---|
committer | YarNayar <YarTheGreat@gmail.com> | 2017-02-03 13:01:43 +0300 |
commit | 9bb08a7e53b22d7af8484e3921b6fe51996ca981 (patch) | |
tree | 297304815c23591bd2c38d3d2555401b452dfc79 /spec/services/slash_commands | |
parent | b525aff665f139cd12ac5a6df78d722427e759cc (diff) |
Adds /target_branch slash command functionality for merge requests
Allows to use slash command /target_branch <target_branch_name> in merge requests notes and description.
Command allows to specify target branch for current merge request.
Proposed in #23619
Diffstat (limited to 'spec/services/slash_commands')
-rw-r--r-- | spec/services/slash_commands/interpret_service_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/services/slash_commands/interpret_service_spec.rb b/spec/services/slash_commands/interpret_service_spec.rb index 66fc8fc360b..0b0925983eb 100644 --- a/spec/services/slash_commands/interpret_service_spec.rb +++ b/spec/services/slash_commands/interpret_service_spec.rb @@ -653,5 +653,37 @@ describe SlashCommands::InterpretService, services: true do let(:issuable) { issue } end end + + context '/target_branch command' do + let(:non_empty_project) { create(:project) } + let(:another_merge_request) { create(:merge_request, author: developer, source_project: non_empty_project) } + let(:service) { described_class.new(non_empty_project, developer)} + + it 'updates target_branch if /target_branch command is executed' do + _, updates = service.execute('/target_branch merge-test', merge_request) + + expect(updates).to eq(target_branch: 'merge-test') + end + + it 'handles blanks around param' do + _, updates = service.execute('/target_branch merge-test ', merge_request) + + expect(updates).to eq(target_branch: 'merge-test') + end + + context 'ignores command with no argument' do + it_behaves_like 'empty command' do + let(:content) { '/target_branch' } + let(:issuable) { another_merge_request } + end + end + + context 'ignores non-existing target branch' do + it_behaves_like 'empty command' do + let(:content) { '/target_branch totally_non_existing_branch' } + let(:issuable) { another_merge_request } + end + end + end end end |