diff options
author | Rémy Coutable <remy@rymai.me> | 2018-09-10 12:24:46 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-09-10 12:24:46 +0000 |
commit | 4a5f4c657d3389affbbe17f2cc8e38365d1d51b2 (patch) | |
tree | de72df08a00789d6063755fca499bda928a933c6 /spec/services | |
parent | d3ff9e9c6745839c2b26404a7e2c79a6ac8036b8 (diff) | |
parent | e39962b019dcdf675875e7cf7d62d375345b7c03 (diff) | |
download | gitlab-ce-4a5f4c657d3389affbbe17f2cc8e38365d1d51b2.tar.gz |
Merge branch 'lock-unlock-quick-actions' into 'master'
Add /lock and /unlock quick actions
Closes #39173
See merge request gitlab-org/gitlab-ce!15197
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/quick_actions/interpret_service_spec.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index bf1c157c4a2..06cad9c00d2 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -272,6 +272,28 @@ describe QuickActions::InterpretService do end end + shared_examples 'lock command' do + let(:issue) { create(:issue, project: project, discussion_locked: false) } + let(:merge_request) { create(:merge_request, source_project: project, discussion_locked: false) } + + it 'returns discussion_locked: true if content contains /lock' do + _, updates = service.execute(content, issuable) + + expect(updates).to eq(discussion_locked: true) + end + end + + shared_examples 'unlock command' do + let(:issue) { create(:issue, project: project, discussion_locked: true) } + let(:merge_request) { create(:merge_request, source_project: project, discussion_locked: true) } + + it 'returns discussion_locked: true if content contains /unlock' do + _, updates = service.execute(content, issuable) + + expect(updates).to eq(discussion_locked: false) + end + end + shared_examples 'empty command' do it 'populates {} if content contains an unsupported command' do _, updates = service.execute(content, issuable) @@ -786,6 +808,26 @@ describe QuickActions::InterpretService do let(:issuable) { issue } end + it_behaves_like 'lock command' do + let(:content) { '/lock' } + let(:issuable) { issue } + end + + it_behaves_like 'lock command' do + let(:content) { '/lock' } + let(:issuable) { merge_request } + end + + it_behaves_like 'unlock command' do + let(:content) { '/unlock' } + let(:issuable) { issue } + end + + it_behaves_like 'unlock command' do + let(:content) { '/unlock' } + let(:issuable) { merge_request } + end + context '/todo' do let(:content) { '/todo' } @@ -961,6 +1003,16 @@ describe QuickActions::InterpretService do let(:content) { '/duplicate #{issue.to_reference}' } let(:issuable) { issue } end + + it_behaves_like 'empty command' do + let(:content) { '/lock' } + let(:issuable) { issue } + end + + it_behaves_like 'empty command' do + let(:content) { '/unlock' } + let(:issuable) { issue } + end end context '/award command' do |