Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
ef653cf732c4
Commit
ef653cf7
authored
Oct 02, 2015
by
Dmitriy Zaporozhets
Browse files
Prevent creating 2 Ci::Project entities when enable CI
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
21e9cc2a494b
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/models/project.rb
View file @
ef653cf7
...
...
@@ -751,8 +751,7 @@
gitlab_ci_project
||
create_gitlab_ci_project
end
def
enable_ci
(
user
)
# Enable service
def
enable_ci
service
=
gitlab_ci_service
||
create_gitlab_ci_service
service
.
active
=
true
service
.
save
...
...
@@ -756,8 +755,5 @@
service
=
gitlab_ci_service
||
create_gitlab_ci_service
service
.
active
=
true
service
.
save
# Create Ci::Project
Ci
::
CreateProjectService
.
new
.
execute
(
user
,
self
)
end
end
app/services/git_push_service.rb
View file @
ef653cf7
...
...
@@ -58,7 +58,7 @@
# If CI was disabled but .gitlab-ci.yml file was pushed
# we enable CI automatically
if
!
project
.
gitlab_ci?
&&
gitlab_ci_yaml?
(
newrev
)
project
.
enable_ci
(
user
)
project
.
enable_ci
end
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
...
...
features/steps/project/commits/commits.rb
View file @
ef653cf7
...
...
@@ -103,7 +103,7 @@
end
step
'commit has ci status'
do
@project
.
enable_ci
(
@user
)
@project
.
enable_ci
create
:ci_commit
,
gl_project:
@project
,
sha:
sample_commit
.
id
end
...
...
features/steps/shared/project.rb
View file @
ef653cf7
...
...
@@ -199,7 +199,7 @@
step
'project "Shop" has CI enabled'
do
project
=
Project
.
find_by
(
name:
"Shop"
)
project
.
enable_ci
(
@user
)
project
.
enable_ci
end
step
'project "Shop" has CI build'
do
...
...
spec/models/project_spec.rb
View file @
ef653cf7
...
...
@@ -417,5 +417,4 @@
describe
:enable_ci
do
let
(
:project
)
{
create
:project
}
let
(
:user
)
{
create
:user
}
...
...
@@ -421,5 +420,5 @@
before
{
project
.
enable_ci
(
user
)
}
before
{
project
.
enable_ci
}
it
{
expect
(
project
.
gitlab_ci?
).
to
be_truthy
}
it
{
expect
(
project
.
gitlab_ci_project
).
to
be_a
(
Ci
::
Project
)
}
...
...
Write
Preview
Supports
Markdown
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