diff options
author | Rémy Coutable <remy@rymai.me> | 2016-08-09 20:54:18 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-08-13 00:06:12 +0200 |
commit | 39f7f63fe951ff861ad151125188e6cdd598b6ff (patch) | |
tree | 8fa991298d3be0c8537f8402f4e17a5cd5e2eb28 /spec/services | |
parent | 7cc4ab14b8a2f1d7d374a320b79374764527659f (diff) | |
download | gitlab-ce-39f7f63fe951ff861ad151125188e6cdd598b6ff.tar.gz |
Add the /title slash command
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/slash_commands/interpret_service_spec.rb | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/spec/services/slash_commands/interpret_service_spec.rb b/spec/services/slash_commands/interpret_service_spec.rb index d03c84f59b3..66ebe091893 100644 --- a/spec/services/slash_commands/interpret_service_spec.rb +++ b/spec/services/slash_commands/interpret_service_spec.rb @@ -15,6 +15,7 @@ describe SlashCommands::InterpretService, services: true do is_expected.to match_array([ :open, :reopen, :close, + :title, :assign, :reassign, :unassign, :remove_assignee, :milestone, @@ -53,6 +54,14 @@ describe SlashCommands::InterpretService, services: true do end end + shared_examples 'title command' do + it 'populates title: "A brand new title" if content contains /title A brand new title' do + changes = service.execute(content, issuable) + + expect(changes).to eq(title: 'A brand new title') + end + end + shared_examples 'assign command' do it 'fetches assignee and populates assignee_id if content contains /assign' do changes = service.execute(content, issuable) @@ -190,6 +199,21 @@ describe SlashCommands::InterpretService, services: true do let(:issuable) { merge_request } end + it_behaves_like 'title command' do + let(:content) { '/title A brand new title' } + let(:issuable) { issue } + end + + it_behaves_like 'title command' do + let(:content) { '/title A brand new title' } + let(:issuable) { merge_request } + end + + it_behaves_like 'empty command' do + let(:content) { '/title' } + let(:issuable) { issue } + end + it_behaves_like 'assign command' do let(:content) { "/assign @#{user.username}" } let(:issuable) { issue } @@ -200,16 +224,14 @@ describe SlashCommands::InterpretService, services: true do let(:issuable) { merge_request } end - it 'does not populate assignee_id if content contains /assign with an unknown user' do - changes = service.execute('/assign joe', issue) - - expect(changes).to be_empty + it_behaves_like 'empty command' do + let(:content) { '/assign @abcd1234' } + let(:issuable) { issue } end - it 'does not populate assignee_id if content contains /assign without user' do - changes = service.execute('/assign', issue) - - expect(changes).to be_empty + it_behaves_like 'empty command' do + let(:content) { '/assign' } + let(:issuable) { issue } end it_behaves_like 'unassign command' do |