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
Jérome Perrin
gitlab-ce
Commits
41aa605d
Commit
41aa605d
authored
Nov 21, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve deploy command message
parent
d375e3f1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
8 deletions
+29
-8
lib/gitlab/chat_commands/deploy.rb
lib/gitlab/chat_commands/deploy.rb
+14
-1
lib/mattermost/presenter.rb
lib/mattermost/presenter.rb
+6
-1
spec/lib/gitlab/chat_commands/command_spec.rb
spec/lib/gitlab/chat_commands/command_spec.rb
+1
-1
spec/lib/gitlab/chat_commands/deploy_spec.rb
spec/lib/gitlab/chat_commands/deploy_spec.rb
+8
-5
No files found.
lib/gitlab/chat_commands/deploy.rb
View file @
41aa605d
module
Gitlab
module
Gitlab
module
ChatCommands
module
ChatCommands
class
Deploy
<
BaseCommand
class
Deploy
<
BaseCommand
include
Gitlab
::
Routing
.
url_helpers
def
self
.
match
(
text
)
def
self
.
match
(
text
)
/\Adeploy\s+(?<from>.*)\s+to+\s+(?<to>.*)\z/
.
match
(
text
)
/\Adeploy\s+(?<from>.*)\s+to+\s+(?<to>.*)\z/
.
match
(
text
)
end
end
...
@@ -25,7 +27,7 @@ module Gitlab
...
@@ -25,7 +27,7 @@ module Gitlab
return
unless
actions
.
present?
return
unless
actions
.
present?
if
actions
.
one?
if
actions
.
one?
actions
.
first
.
play
(
current_user
)
play!
(
from
,
to
,
actions
.
first
)
else
else
Result
.
new
(
:error
,
'Too many actions defined'
)
Result
.
new
(
:error
,
'Too many actions defined'
)
end
end
...
@@ -33,12 +35,23 @@ module Gitlab
...
@@ -33,12 +35,23 @@ module Gitlab
private
private
def
play!
(
from
,
to
,
action
)
new_action
=
action
.
play
(
current_user
)
Result
.
new
(
:success
,
"Deployment from
#{
from
}
to
#{
to
}
started. Follow the progress:
#{
url
(
new_action
)
}
."
)
end
def
find_actions
(
from
,
to
)
def
find_actions
(
from
,
to
)
environment
=
project
.
environments
.
find_by
(
name:
from
)
environment
=
project
.
environments
.
find_by
(
name:
from
)
return
unless
environment
return
unless
environment
environment
.
actions_for
(
to
).
select
(
&
:starts_environment?
)
environment
.
actions_for
(
to
).
select
(
&
:starts_environment?
)
end
end
def
url
(
subject
)
polymorphic_url
(
[
subject
.
project
.
namespace
.
becomes
(
Namespace
),
subject
.
project
,
subject
])
end
end
end
end
end
end
end
lib/mattermost/presenter.rb
View file @
41aa605d
...
@@ -49,7 +49,12 @@ module Mattermost
...
@@ -49,7 +49,12 @@ module Mattermost
private
private
def
show_result
(
result
)
def
show_result
(
result
)
ephemeral_response
(
result
.
message
)
case
result
.
type
when
:success
in_channel_response
(
result
.
message
)
else
ephemeral_response
(
result
.
message
)
end
end
end
def
not_found
def
not_found
...
...
spec/lib/gitlab/chat_commands/command_spec.rb
View file @
41aa605d
...
@@ -74,7 +74,7 @@ describe Gitlab::ChatCommands::Command, service: true do
...
@@ -74,7 +74,7 @@ describe Gitlab::ChatCommands::Command, service: true do
end
end
it
'returns action'
do
it
'returns action'
do
expect
(
subject
[
:text
]).
to
include
(
manual
.
name
)
expect
(
subject
[
:text
]).
to
include
(
'Deployment from staging to production started'
)
expect
(
subject
[
:response_type
]).
to
be
(
:in_channel
)
expect
(
subject
[
:response_type
]).
to
be
(
:in_channel
)
end
end
...
...
spec/lib/gitlab/chat_commands/deploy_spec.rb
View file @
41aa605d
...
@@ -36,8 +36,9 @@ describe Gitlab::ChatCommands::Deploy, service: true do
...
@@ -36,8 +36,9 @@ describe Gitlab::ChatCommands::Deploy, service: true do
create
(
:ci_build
,
:manual
,
project:
project
,
pipeline:
build
.
pipeline
,
name:
'first'
,
environment:
'production'
)
create
(
:ci_build
,
:manual
,
project:
project
,
pipeline:
build
.
pipeline
,
name:
'first'
,
environment:
'production'
)
end
end
it
'returns action'
do
it
'returns success result'
do
expect
(
subject
).
to
eq
(
manual1
)
expect
(
subject
.
type
).
to
eq
(
:success
)
expect
(
subject
.
message
).
to
include
(
'Deployment from staging to production started'
)
end
end
context
'when duplicate action exists'
do
context
'when duplicate action exists'
do
...
@@ -46,7 +47,8 @@ describe Gitlab::ChatCommands::Deploy, service: true do
...
@@ -46,7 +47,8 @@ describe Gitlab::ChatCommands::Deploy, service: true do
end
end
it
'returns error'
do
it
'returns error'
do
expect
(
subject
.
message
).
to
eq
(
'Too many actions defined'
)
expect
(
subject
.
type
).
to
eq
(
:error
)
expect
(
subject
.
message
).
to
include
(
'Too many actions defined'
)
end
end
end
end
...
@@ -57,8 +59,9 @@ describe Gitlab::ChatCommands::Deploy, service: true do
...
@@ -57,8 +59,9 @@ describe Gitlab::ChatCommands::Deploy, service: true do
name:
'teardown'
,
environment:
'production'
)
name:
'teardown'
,
environment:
'production'
)
end
end
it
'returns error'
do
it
'returns success result'
do
expect
(
subject
).
to
eq
(
manual1
)
expect
(
subject
.
type
).
to
eq
(
:success
)
expect
(
subject
.
message
).
to
include
(
'Deployment from staging to production started'
)
end
end
end
end
end
end
...
...
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