BigW Consortium Gitlab

Prevent creating 2 Ci::Project entities when enable CI

parent e3bc0e21
...@@ -751,13 +751,9 @@ class Project < ActiveRecord::Base ...@@ -751,13 +751,9 @@ class Project < ActiveRecord::Base
gitlab_ci_project || create_gitlab_ci_project gitlab_ci_project || create_gitlab_ci_project
end end
def enable_ci(user) def enable_ci
# Enable service
service = gitlab_ci_service || create_gitlab_ci_service service = gitlab_ci_service || create_gitlab_ci_service
service.active = true service.active = true
service.save service.save
# Create Ci::Project
Ci::CreateProjectService.new.execute(user, self)
end end
end end
...@@ -58,7 +58,7 @@ class GitPushService ...@@ -58,7 +58,7 @@ class GitPushService
# If CI was disabled but .gitlab-ci.yml file was pushed # If CI was disabled but .gitlab-ci.yml file was pushed
# we enable CI automatically # we enable CI automatically
if !project.gitlab_ci? && gitlab_ci_yaml?(newrev) if !project.gitlab_ci? && gitlab_ci_yaml?(newrev)
project.enable_ci(user) project.enable_ci
end end
EventCreateService.new.push(project, user, @push_data) EventCreateService.new.push(project, user, @push_data)
......
...@@ -103,7 +103,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps ...@@ -103,7 +103,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
end end
step 'commit has ci status' do step 'commit has ci status' do
@project.enable_ci(@user) @project.enable_ci
create :ci_commit, gl_project: @project, sha: sample_commit.id create :ci_commit, gl_project: @project, sha: sample_commit.id
end end
......
...@@ -199,7 +199,7 @@ module SharedProject ...@@ -199,7 +199,7 @@ module SharedProject
step 'project "Shop" has CI enabled' do step 'project "Shop" has CI enabled' do
project = Project.find_by(name: "Shop") project = Project.find_by(name: "Shop")
project.enable_ci(@user) project.enable_ci
end end
step 'project "Shop" has CI build' do step 'project "Shop" has CI build' do
......
...@@ -417,9 +417,8 @@ describe Project do ...@@ -417,9 +417,8 @@ describe Project do
describe :enable_ci do describe :enable_ci do
let(:project) { create :project } 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?).to be_truthy }
it { expect(project.gitlab_ci_project).to be_a(Ci::Project) } 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