blob: 24c06a967fa4ed8f30fe13fca196e283eaced5f7 (
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
|
require 'spec_helper'
describe Gitlab::ChatCommands::IssueSearch, service: true do
describe '#execute' do
let!(:issue) { create(:issue, title: 'find me') }
let!(:confidential) { create(:issue, :confidential, project: project, title: 'mepmep find') }
let(:project) { issue.project }
let(:user) { issue.author }
let(:regex_match) { described_class.match("issue search find") }
subject do
described_class.new(project, user).execute(regex_match)
end
context 'when the user has no access' do
it 'only returns the open issues' do
expect(subject).not_to include(confidential)
end
end
context 'the user has access' do
before do
project.team << [user, :master]
end
it 'returns all results' do
expect(subject).to include(confidential, issue)
end
end
context 'without hits on the query' do
it 'returns an empty collection' do
expect(subject).to be_empty
end
end
end
describe 'self.match' do
let(:query) { "my search keywords" }
it 'matches the query' do
match = described_class.match("issue search #{query}")
expect(match[:query]).to eq(query)
end
end
end
|