Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
35212deb
Commit
35212deb
authored
Nov 29, 2016
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zj-issue-search-slash-command' into 'master'
Add issue search slash command See merge request !7752
parents
63f5c4ea
6a08de73
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
71 additions
and
9 deletions
+71
-9
changelogs/unreleased/zj-issue-search-slash-command.yml
changelogs/unreleased/zj-issue-search-slash-command.yml
+4
-0
lib/gitlab/chat_commands/base_command.rb
lib/gitlab/chat_commands/base_command.rb
+1
-3
lib/gitlab/chat_commands/command.rb
lib/gitlab/chat_commands/command.rb
+1
-0
lib/gitlab/chat_commands/issue_command.rb
lib/gitlab/chat_commands/issue_command.rb
+1
-5
lib/gitlab/chat_commands/issue_search.rb
lib/gitlab/chat_commands/issue_search.rb
+17
-0
spec/lib/gitlab/chat_commands/issue_search_spec.rb
spec/lib/gitlab/chat_commands/issue_search_spec.rb
+46
-0
spec/requests/api/services_spec.rb
spec/requests/api/services_spec.rb
+1
-1
No files found.
changelogs/unreleased/zj-issue-search-slash-command.yml
0 → 100644
View file @
35212deb
---
title
:
Add issue search slash command
merge_request
:
author
:
lib/gitlab/chat_commands/base_command.rb
View file @
35212deb
...
...
@@ -40,9 +40,7 @@ module Gitlab
private
def
find_by_iid
(
iid
)
resource
=
collection
.
find_by
(
iid:
iid
)
readable?
(
resource
)
?
resource
:
nil
collection
.
find_by
(
iid:
iid
)
end
end
end
...
...
lib/gitlab/chat_commands/command.rb
View file @
35212deb
...
...
@@ -4,6 +4,7 @@ module Gitlab
COMMANDS
=
[
Gitlab
::
ChatCommands
::
IssueShow
,
Gitlab
::
ChatCommands
::
IssueCreate
,
Gitlab
::
ChatCommands
::
IssueSearch
,
Gitlab
::
ChatCommands
::
Deploy
,
].
freeze
...
...
lib/gitlab/chat_commands/issue_command.rb
View file @
35212deb
...
...
@@ -6,11 +6,7 @@ module Gitlab
end
def
collection
project
.
issues
end
def
readable?
(
issue
)
self
.
class
.
can?
(
current_user
,
:read_issue
,
issue
)
IssuesFinder
.
new
(
current_user
,
project_id:
project
.
id
).
execute
end
end
end
...
...
lib/gitlab/chat_commands/issue_search.rb
0 → 100644
View file @
35212deb
module
Gitlab
module
ChatCommands
class
IssueSearch
<
IssueCommand
def
self
.
match
(
text
)
/\Aissue\s+search\s+(?<query>.*)/
.
match
(
text
)
end
def
self
.
help_message
"issue search <your query>"
end
def
execute
(
match
)
collection
.
search
(
match
[
:query
]).
limit
(
QUERY_LIMIT
)
end
end
end
end
spec/lib/gitlab/chat_commands/issue_search_spec.rb
0 → 100644
View file @
35212deb
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
spec/requests/api/services_spec.rb
View file @
35212deb
...
...
@@ -128,7 +128,7 @@ describe API::API, api: true do
)
end
it
'retu
sn
status 200'
do
it
'retu
rns
status 200'
do
post
api
(
"/projects/
#{
project
.
id
}
/services/mattermost_slash_commands/trigger"
),
params
expect
(
response
).
to
have_http_status
(
200
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment