Unverified Commit 5de0b078 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Prevent creating 2 Ci::Project entities when enable CI


Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 21e9cc2a494b
......@@ -751,13 +751,9 @@ def ensure_gitlab_ci_project
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
# Create Ci::Project
Ci::CreateProjectService.new.execute(user, self)
end
end
......@@ -58,7 +58,7 @@ def execute(project, user, oldrev, newrev, ref)
# 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)
......
......@@ -103,7 +103,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
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
......
......@@ -199,7 +199,7 @@ def current_project
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
......
......@@ -417,9 +417,8 @@
describe :enable_ci do
let(:project) { create :project }
let(:user) { create :user }
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) }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment