summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-10-02 10:39:31 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-10-02 10:39:31 +0000
commitc7e323438e97bee1ed9171897f6ff2b3d44e08cb (patch)
treeeee3836e72403b9f0a7612bf8ee9eeb500e0a205 /spec
parent2fa89a3dc6a7580969203e43808048b79f172c0c (diff)
parent3515cb9b2de4b6c1018fec35b0513eb7dc33dc66 (diff)
downloadgitlab-ce-c7e323438e97bee1ed9171897f6ff2b3d44e08cb.tar.gz
Merge branch 'ensure-ci-project' into 'master'
Ensure GitLab CI project exists when CI service is activated manually When I check activeated checkbox in project services for GitLab CI it cause half-working state when gitlab_ci_project is missing. This patch fixes it until we have proper behaviour implemented later This fix also bring us to the point when fork of project is a bit broken and have unnecessary code so I made cleanup. Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> cc @ayufan See merge request !1491
Diffstat (limited to 'spec')
-rw-r--r--spec/models/project_services/gitlab_ci_service_spec.rb21
-rw-r--r--spec/models/project_spec.rb3
-rw-r--r--spec/services/ci/create_project_service_spec.rb37
-rw-r--r--spec/services/projects/fork_service_spec.rb12
4 files changed, 5 insertions, 68 deletions
diff --git a/spec/models/project_services/gitlab_ci_service_spec.rb b/spec/models/project_services/gitlab_ci_service_spec.rb
index 8cdd551a0ca..989cfe09167 100644
--- a/spec/models/project_services/gitlab_ci_service_spec.rb
+++ b/spec/models/project_services/gitlab_ci_service_spec.rb
@@ -56,25 +56,4 @@ describe GitlabCiService do
end
end
end
-
- describe "Fork registration" do
- before do
- @old_project = create(:ci_project).gl_project
- @project = create(:empty_project)
- @user = create(:user)
-
- @service = GitlabCiService.new
- allow(@service).to receive_messages(
- service_hook: true,
- project_url: 'http://ci.gitlab.org/projects/2',
- token: 'verySecret',
- project: @old_project
- )
- end
-
- it "creates fork on CI" do
- expect_any_instance_of(Ci::CreateProjectService).to receive(:execute)
- @service.fork_registration(@project, @user)
- end
- end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index fe7bb2cc13f..1c3f5374a24 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -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) }
diff --git a/spec/services/ci/create_project_service_spec.rb b/spec/services/ci/create_project_service_spec.rb
deleted file mode 100644
index 2de7b0deca7..00000000000
--- a/spec/services/ci/create_project_service_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require 'spec_helper'
-
-describe Ci::CreateProjectService do
- let(:service) { Ci::CreateProjectService.new }
- let(:current_user) { double.as_null_object }
- let(:project) { FactoryGirl.create :project }
-
- describe :execute do
- context 'valid params' do
- subject { service.execute(current_user, project) }
-
- it { is_expected.to be_kind_of(Ci::Project) }
- it { is_expected.to be_persisted }
- end
-
- context 'without project dump' do
- it 'should raise exception' do
- expect { service.execute(current_user, '', '') }.
- to raise_error(NoMethodError)
- end
- end
-
- context "forking" do
- let(:ci_origin_project) do
- FactoryGirl.create(:ci_project, shared_runners_enabled: true, public: true, allow_git_fetch: true)
- end
-
- subject { service.execute(current_user, project, ci_origin_project) }
-
- it "uses project as a template for settings and jobs" do
- expect(subject.shared_runners_enabled).to be_truthy
- expect(subject.public).to be_truthy
- expect(subject.allow_git_fetch).to be_truthy
- end
- end
- end
-end
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index 18ab333c1d1..65a8c81204d 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -43,14 +43,10 @@ describe Projects::ForkService do
end
context 'GitLab CI is enabled' do
- it "calls fork registrator for CI" do
- create(:ci_project, gl_project: @from_project)
- @from_project.build_missing_services
- @from_project.gitlab_ci_service.update_attributes(active: true)
-
- expect_any_instance_of(Ci::CreateProjectService).to receive(:execute)
-
- fork_project(@from_project, @to_user)
+ it "fork and enable CI for fork" do
+ @from_project.enable_ci
+ @to_project = fork_project(@from_project, @to_user)
+ expect(@to_project.gitlab_ci?).to be_truthy
end
end
end