blob: 5ef363274adce7acb5fc4cb0bd5910cfb6dfb945 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
require 'spec_helper'
describe Mattermost::Commands::IssueService do
let(:project) { create(:project) }
let(:issue ) { create(:issue, :confidential, title: 'Bird is the word', project: project) }
let(:user) { issue.author }
subject { described_class.new(project, user, params).execute }
before do
project.team << [user, :developer]
end
describe '#execute' do
context 'show as subcommand' do
context 'issue can be found' do
let(:params) { { text: "issue show #{issue.iid}" } }
it 'returns the merge request' do
expect(subject).to eq issue
end
context 'the user has no access' do
let(:non_member) { create(:user) }
subject { described_class.new(project, non_member, params).execute }
it 'returns nil' do
expect(subject).to eq nil
end
end
end
context 'issue can not be found' do
let(:params) { { text: 'issue show 12345' } }
it 'returns nil' do
expect(subject).to eq nil
end
end
end
context 'search as a subcommand' do
context 'with results' do
let(:params) { { text: "issue search is the word" } }
it 'returns the issue' do
expect(subject).to eq [issue]
end
end
context 'without results' do
let(:params) { { text: 'issue search mepmep' } }
it 'returns an empty collection' do
expect(subject).to eq []
end
end
end
context 'create as subcommand' do
let(:title) { 'my new issue' }
let(:params) { { text: "issue create #{title}" } }
it 'return the new issue' do
expect(subject).to be_a Issue
end
it 'creates a new issue' do
expect { subject }.to change { Issue.count }.by(1)
end
end
end
describe 'help_message' do
context 'issues are disabled' do
it 'returns nil' do
allow(described_class).to receive(:available?).and_return false
expect(described_class.help_message(project)).to eq nil
end
end
end
end
|