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
Léo-Paul Géneau
gitlab-ce
Commits
3726dc4b
Commit
3726dc4b
authored
Oct 14, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if project exists before creating deployment
parent
4e934259
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
+20
-5
app/services/create_deployment_service.rb
app/services/create_deployment_service.rb
+6
-0
app/workers/build_success_worker.rb
app/workers/build_success_worker.rb
+0
-2
spec/services/create_deployment_service_spec.rb
spec/services/create_deployment_service_spec.rb
+14
-3
No files found.
app/services/create_deployment_service.rb
View file @
3726dc4b
...
@@ -2,6 +2,8 @@ require_relative 'base_service'
...
@@ -2,6 +2,8 @@ require_relative 'base_service'
class
CreateDeploymentService
<
BaseService
class
CreateDeploymentService
<
BaseService
def
execute
(
deployable
=
nil
)
def
execute
(
deployable
=
nil
)
return
unless
executable?
ActiveRecord
::
Base
.
transaction
do
ActiveRecord
::
Base
.
transaction
do
@deployable
=
deployable
@deployable
=
deployable
@environment
=
prepare_environment
@environment
=
prepare_environment
...
@@ -14,6 +16,10 @@ class CreateDeploymentService < BaseService
...
@@ -14,6 +16,10 @@ class CreateDeploymentService < BaseService
private
private
def
executable?
project
&&
name
.
present?
end
def
deploy
def
deploy
project
.
deployments
.
create
(
project
.
deployments
.
create
(
environment:
@environment
,
environment:
@environment
,
...
...
app/workers/build_success_worker.rb
View file @
3726dc4b
...
@@ -4,8 +4,6 @@ class BuildSuccessWorker
...
@@ -4,8 +4,6 @@ class BuildSuccessWorker
def
perform
(
build_id
)
def
perform
(
build_id
)
Ci
::
Build
.
find_by
(
id:
build_id
).
try
do
|
build
|
Ci
::
Build
.
find_by
(
id:
build_id
).
try
do
|
build
|
return
unless
build
.
project
create_deployment
(
build
)
create_deployment
(
build
)
end
end
end
end
...
...
spec/services/create_deployment_service_spec.rb
View file @
3726dc4b
...
@@ -84,6 +84,17 @@ describe CreateDeploymentService, services: true do
...
@@ -84,6 +84,17 @@ describe CreateDeploymentService, services: true do
expect
(
subject
).
to
be_persisted
expect
(
subject
).
to
be_persisted
end
end
end
end
context
'when project was removed'
do
let
(
:project
)
{
nil
}
it
'does not create deployment or environment'
do
expect
{
subject
}.
not_to
raise_error
expect
(
Environment
.
count
).
to
be_zero
expect
(
Deployment
.
count
).
to
be_zero
end
end
end
end
describe
'processing of builds'
do
describe
'processing of builds'
do
...
...
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