diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2016-11-29 14:04:17 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2016-11-29 14:04:17 +0300 |
commit | 35212deb062dda60220a9a0929c26196c1c598b5 (patch) | |
tree | 1f8eaa14f3774c1dfe38b96e964bbff9eb1f2b91 /spec | |
parent | 63f5c4ea5436f312693da0559602803c733dc9cb (diff) | |
parent | 6a08de7386fd41c9bbe27c32338328c6e6b40027 (diff) |
Merge branch 'zj-issue-search-slash-command' into 'master'
Add issue search slash command
See merge request !7752
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/chat_commands/issue_search_spec.rb | 46 | ||||
-rw-r--r-- | spec/requests/api/services_spec.rb | 2 |
2 files changed, 47 insertions, 1 deletions
diff --git a/spec/lib/gitlab/chat_commands/issue_search_spec.rb b/spec/lib/gitlab/chat_commands/issue_search_spec.rb new file mode 100644 index 00000000000..24c06a967fa --- /dev/null +++ b/spec/lib/gitlab/chat_commands/issue_search_spec.rb @@ -0,0 +1,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 diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb index ce9c96ace21..bb0344e5995 100644 --- a/spec/requests/api/services_spec.rb +++ b/spec/requests/api/services_spec.rb @@ -128,7 +128,7 @@ describe API::API, api: true do ) end - it 'retusn status 200' do + it 'returns status 200' do post api("/projects/#{project.id}/services/mattermost_slash_commands/trigger"), params expect(response).to have_http_status(200) |