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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
dbda72a7
Commit
dbda72a7
authored
Jan 26, 2017
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename presenters for consitency
parent
52ca0d2c
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
51 additions
and
36 deletions
+51
-36
lib/gitlab/chat_commands/command.rb
lib/gitlab/chat_commands/command.rb
+1
-1
lib/gitlab/chat_commands/issue_new.rb
lib/gitlab/chat_commands/issue_new.rb
+5
-5
lib/gitlab/chat_commands/issue_search.rb
lib/gitlab/chat_commands/issue_search.rb
+3
-5
lib/gitlab/chat_commands/issue_show.rb
lib/gitlab/chat_commands/issue_show.rb
+1
-1
lib/gitlab/chat_commands/presenters/deploy.rb
lib/gitlab/chat_commands/presenters/deploy.rb
+0
-8
lib/gitlab/chat_commands/presenters/help.rb
lib/gitlab/chat_commands/presenters/help.rb
+3
-3
lib/gitlab/chat_commands/presenters/issuable.rb
lib/gitlab/chat_commands/presenters/issuable.rb
+1
-3
lib/gitlab/chat_commands/presenters/issue_new.rb
lib/gitlab/chat_commands/presenters/issue_new.rb
+9
-3
lib/gitlab/chat_commands/presenters/issue_search.rb
lib/gitlab/chat_commands/presenters/issue_search.rb
+3
-1
lib/gitlab/chat_commands/presenters/issue_show.rb
lib/gitlab/chat_commands/presenters/issue_show.rb
+4
-2
spec/lib/gitlab/chat_commands/command_spec.rb
spec/lib/gitlab/chat_commands/command_spec.rb
+1
-1
spec/lib/gitlab/chat_commands/issue_new_spec.rb
spec/lib/gitlab/chat_commands/issue_new_spec.rb
+1
-1
spec/lib/gitlab/chat_commands/presenters/issue_new_spec.rb
spec/lib/gitlab/chat_commands/presenters/issue_new_spec.rb
+17
-0
spec/lib/gitlab/chat_commands/presenters/issue_search_spec.rb
.../lib/gitlab/chat_commands/presenters/issue_search_spec.rb
+1
-1
spec/lib/gitlab/chat_commands/presenters/issue_show_spec.rb
spec/lib/gitlab/chat_commands/presenters/issue_show_spec.rb
+1
-1
No files found.
lib/gitlab/chat_commands/command.rb
View file @
dbda72a7
...
@@ -3,7 +3,7 @@ module Gitlab
...
@@ -3,7 +3,7 @@ module Gitlab
class
Command
<
BaseCommand
class
Command
<
BaseCommand
COMMANDS
=
[
COMMANDS
=
[
Gitlab
::
ChatCommands
::
IssueShow
,
Gitlab
::
ChatCommands
::
IssueShow
,
Gitlab
::
ChatCommands
::
Issue
Create
,
Gitlab
::
ChatCommands
::
Issue
New
,
Gitlab
::
ChatCommands
::
IssueSearch
,
Gitlab
::
ChatCommands
::
IssueSearch
,
Gitlab
::
ChatCommands
::
Deploy
,
Gitlab
::
ChatCommands
::
Deploy
,
].
freeze
].
freeze
...
...
lib/gitlab/chat_commands/issue_
create
.rb
→
lib/gitlab/chat_commands/issue_
new
.rb
View file @
dbda72a7
module
Gitlab
module
Gitlab
module
ChatCommands
module
ChatCommands
class
Issue
Create
<
IssueCommand
class
Issue
New
<
IssueCommand
def
self
.
match
(
text
)
def
self
.
match
(
text
)
# we can not match \n with the dot by passing the m modifier as than
# we can not match \n with the dot by passing the m modifier as than
# the title and description are not seperated
# the title and description are not seperated
...
@@ -21,10 +21,10 @@ module Gitlab
...
@@ -21,10 +21,10 @@ module Gitlab
issue
=
create_issue
(
title:
title
,
description:
description
)
issue
=
create_issue
(
title:
title
,
description:
description
)
if
issue
.
errors
.
any?
if
issue
.
persisted?
presenter
(
issue
).
display_errors
else
presenter
(
issue
).
present
presenter
(
issue
).
present
else
presenter
(
issue
).
display_errors
end
end
end
end
...
@@ -35,7 +35,7 @@ module Gitlab
...
@@ -35,7 +35,7 @@ module Gitlab
end
end
def
presenter
(
issue
)
def
presenter
(
issue
)
Gitlab
::
ChatCommands
::
Presenters
::
NewIssue
.
new
(
issue
)
Gitlab
::
ChatCommands
::
Presenters
::
IssueNew
.
new
(
issue
)
end
end
end
end
end
end
...
...
lib/gitlab/chat_commands/issue_search.rb
View file @
dbda72a7
...
@@ -12,12 +12,10 @@ module Gitlab
...
@@ -12,12 +12,10 @@ module Gitlab
def
execute
(
match
)
def
execute
(
match
)
issues
=
collection
.
search
(
match
[
:query
]).
limit
(
QUERY_LIMIT
)
issues
=
collection
.
search
(
match
[
:query
]).
limit
(
QUERY_LIMIT
)
if
issues
.
none?
if
issues
.
present?
Presenters
::
Access
.
new
(
issues
).
not_found
Presenters
::
IssueSearch
.
new
(
issues
).
present
elsif
issues
.
one?
Presenters
::
ShowIssue
.
new
(
issues
.
first
).
present
else
else
Presenters
::
ListIssues
.
new
(
issues
).
present
Presenters
::
Access
.
new
(
issues
).
not_found
end
end
end
end
end
end
...
...
lib/gitlab/chat_commands/issue_show.rb
View file @
dbda72a7
...
@@ -13,7 +13,7 @@ module Gitlab
...
@@ -13,7 +13,7 @@ module Gitlab
issue
=
find_by_iid
(
match
[
:iid
])
issue
=
find_by_iid
(
match
[
:iid
])
if
issue
if
issue
Gitlab
::
ChatCommands
::
Presenters
::
ShowIssue
.
new
(
issue
).
present
Gitlab
::
ChatCommands
::
Presenters
::
IssueShow
.
new
(
issue
).
present
else
else
Gitlab
::
ChatCommands
::
Presenters
::
Access
.
new
.
not_found
Gitlab
::
ChatCommands
::
Presenters
::
Access
.
new
.
not_found
end
end
...
...
lib/gitlab/chat_commands/presenters/deploy.rb
View file @
dbda72a7
...
@@ -15,14 +15,6 @@ module Gitlab
...
@@ -15,14 +15,6 @@ module Gitlab
def
too_many_actions
def
too_many_actions
ephemeral_response
(
text:
"Too many actions defined"
)
ephemeral_response
(
text:
"Too many actions defined"
)
end
end
private
def
resource_url
polymorphic_url
(
[
@resource
.
project
.
namespace
.
becomes
(
Namespace
),
@resource
.
project
,
@resource
]
)
end
end
end
end
end
end
end
...
...
lib/gitlab/chat_commands/presenters/help.rb
View file @
dbda72a7
...
@@ -9,10 +9,10 @@ module Gitlab
...
@@ -9,10 +9,10 @@ module Gitlab
private
private
def
help_message
(
trigger
)
def
help_message
(
trigger
)
if
@resource
.
none?
if
@resource
.
present?
"No commands available :thinking_face:"
else
header_with_list
(
"Available commands"
,
full_commands
(
trigger
))
header_with_list
(
"Available commands"
,
full_commands
(
trigger
))
else
"No commands available :thinking_face:"
end
end
end
end
...
...
lib/gitlab/chat_commands/presenters/issuable.rb
View file @
dbda72a7
module
Gitlab
module
Gitlab
module
ChatCommands
module
ChatCommands
module
Presenters
module
Presenters
class
Issuable
<
Presenters
::
Base
module
Issuable
private
def
color
(
issuable
)
def
color
(
issuable
)
issuable
.
open?
?
'#38ae67'
:
'#d22852'
issuable
.
open?
?
'#38ae67'
:
'#d22852'
end
end
...
...
lib/gitlab/chat_commands/presenters/
new_issue
.rb
→
lib/gitlab/chat_commands/presenters/
issue_new
.rb
View file @
dbda72a7
module
Gitlab
module
Gitlab
module
ChatCommands
module
ChatCommands
module
Presenters
module
Presenters
class
NewIssue
<
Presenters
::
Issuable
class
IssueNew
<
Presenters
::
Base
include
Presenters
::
Issuable
def
present
def
present
in_channel_response
(
sho
w_issue
)
in_channel_response
(
ne
w_issue
)
end
end
private
private
def
show_issue
def
new_issue
{
{
attachments:
[
attachments:
[
{
{
...
@@ -33,6 +35,10 @@ module Gitlab
...
@@ -33,6 +35,10 @@ module Gitlab
"I opened an issue on behalf on
#{
author_profile_link
}
: *
#{
@resource
.
to_reference
}
* from
#{
project
.
name_with_namespace
}
"
"I opened an issue on behalf on
#{
author_profile_link
}
: *
#{
@resource
.
to_reference
}
* from
#{
project
.
name_with_namespace
}
"
end
end
def
project_link
"[
#{
project
.
name_with_namespace
}
](
#{
url_for
(
project
)
}
)"
end
def
author_profile_link
def
author_profile_link
"[
#{
author
.
to_reference
}
](
#{
url_for
(
author
)
}
)"
"[
#{
author
.
to_reference
}
](
#{
url_for
(
author
)
}
)"
end
end
...
...
lib/gitlab/chat_commands/presenters/
list_issues
.rb
→
lib/gitlab/chat_commands/presenters/
issue_search
.rb
View file @
dbda72a7
module
Gitlab
module
Gitlab
module
ChatCommands
module
ChatCommands
module
Presenters
module
Presenters
class
ListIssues
<
Presenters
::
Issuable
class
IssueSearch
<
Presenters
::
Base
include
Presenters
::
Issuable
def
present
def
present
text
=
if
@resource
.
count
>=
5
text
=
if
@resource
.
count
>=
5
"Here are the first 5 issues I found:"
"Here are the first 5 issues I found:"
...
...
lib/gitlab/chat_commands/presenters/
show_issue
.rb
→
lib/gitlab/chat_commands/presenters/
issue_show
.rb
View file @
dbda72a7
module
Gitlab
module
Gitlab
module
ChatCommands
module
ChatCommands
module
Presenters
module
Presenters
class
ShowIssue
<
Presenters
::
Issuable
class
IssueShow
<
Presenters
::
Base
include
Presenters
::
Issuable
def
present
def
present
in_channel_response
(
show_issue
)
in_channel_response
(
show_issue
)
end
end
...
@@ -16,7 +18,7 @@ module Gitlab
...
@@ -16,7 +18,7 @@ module Gitlab
title_link:
resource_url
,
title_link:
resource_url
,
author_name:
author
.
name
,
author_name:
author
.
name
,
author_icon:
author
.
avatar_url
,
author_icon:
author
.
avatar_url
,
fallback:
"
New i
ssue
#{
@resource
.
to_reference
}
:
#{
@resource
.
title
}
"
,
fallback:
"
I
ssue
#{
@resource
.
to_reference
}
:
#{
@resource
.
title
}
"
,
pretext:
pretext
,
pretext:
pretext
,
text:
text
,
text:
text
,
color:
color
(
@resource
),
color:
color
(
@resource
),
...
...
spec/lib/gitlab/chat_commands/command_spec.rb
View file @
dbda72a7
...
@@ -78,7 +78,7 @@ describe Gitlab::ChatCommands::Command, service: true do
...
@@ -78,7 +78,7 @@ describe Gitlab::ChatCommands::Command, service: true do
context
'IssueCreate is triggered'
do
context
'IssueCreate is triggered'
do
let
(
:params
)
{
{
text:
'issue create my title'
}
}
let
(
:params
)
{
{
text:
'issue create my title'
}
}
it
{
is_expected
.
to
eq
(
Gitlab
::
ChatCommands
::
Issue
Create
)
}
it
{
is_expected
.
to
eq
(
Gitlab
::
ChatCommands
::
Issue
New
)
}
end
end
context
'IssueSearch is triggered'
do
context
'IssueSearch is triggered'
do
...
...
spec/lib/gitlab/chat_commands/issue_
create
_spec.rb
→
spec/lib/gitlab/chat_commands/issue_
new
_spec.rb
View file @
dbda72a7
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
ChatCommands
::
Issue
Create
,
service:
true
do
describe
Gitlab
::
ChatCommands
::
Issue
New
,
service:
true
do
describe
'#execute'
do
describe
'#execute'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
spec/lib/gitlab/chat_commands/presenters/issue_new_spec.rb
0 → 100644
View file @
dbda72a7
require
'spec_helper'
describe
Gitlab
::
ChatCommands
::
Presenters
::
IssueNew
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:attachment
)
{
subject
[
:attachments
].
first
}
subject
{
described_class
.
new
(
issue
).
present
}
it
{
is_expected
.
to
be_a
(
Hash
)
}
it
'shows the issue'
do
expect
(
subject
[
:response_type
]).
to
be
(
:in_channel
)
expect
(
subject
).
to
have_key
(
:attachments
)
expect
(
attachment
[
:title
]).
to
start_with
(
issue
.
title
)
end
end
spec/lib/gitlab/chat_commands/presenters/
list_issues
_spec.rb
→
spec/lib/gitlab/chat_commands/presenters/
issue_search
_spec.rb
View file @
dbda72a7
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
ChatCommands
::
Presenters
::
ListIssues
do
describe
Gitlab
::
ChatCommands
::
Presenters
::
IssueSearch
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:message
)
{
subject
[
:text
]
}
let
(
:message
)
{
subject
[
:text
]
}
...
...
spec/lib/gitlab/chat_commands/presenters/
show_issue
_spec.rb
→
spec/lib/gitlab/chat_commands/presenters/
issue_show
_spec.rb
View file @
dbda72a7
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
ChatCommands
::
Presenters
::
ShowIssue
do
describe
Gitlab
::
ChatCommands
::
Presenters
::
IssueShow
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:attachment
)
{
subject
[
:attachments
].
first
}
let
(
:attachment
)
{
subject
[
:attachments
].
first
}
...
...
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