Commit 5de0b078 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Prevent creating 2 Ci::Project entities when enable CI

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent e3bc0e21
......@@ -751,13 +751,9 @@ class Project < ActiveRecord::Base
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 @@ class GitPushService
# 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 @@ module SharedProject
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 Project do
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