summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/ci/projects.rb12
-rw-r--r--spec/models/project_spec.rb9
-rw-r--r--spec/requests/api/projects_spec.rb7
-rw-r--r--spec/requests/api/services_spec.rb1
-rw-r--r--spec/services/projects/create_service_spec.rb22
-rw-r--r--spec/services/projects/fork_service_spec.rb2
6 files changed, 43 insertions, 10 deletions
diff --git a/spec/factories/ci/projects.rb b/spec/factories/ci/projects.rb
index 1183a190353..11cb8c9eeaa 100644
--- a/spec/factories/ci/projects.rb
+++ b/spec/factories/ci/projects.rb
@@ -31,16 +31,20 @@ FactoryGirl.define do
factory :ci_project_without_token, class: Ci::Project do
default_ref 'master'
- gl_project factory: :empty_project
-
shared_runners_enabled false
factory :ci_project do
token 'iPWx6WM4lhHNedGfBpPJNP'
end
- factory :ci_public_project do
- public true
+ initialize_with do
+ # TODO:
+ # this is required, because builds_enabled is initialized when Project is created
+ # and this create gitlab_ci_project if builds is set to true
+ # here we take created gitlab_ci_project and update it's attributes
+ ci_project = create(:empty_project).ensure_gitlab_ci_project
+ ci_project.update_attributes(attributes)
+ ci_project
end
end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index f93935ebe3b..8d7e6e76766 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -415,12 +415,15 @@ describe Project do
it { expect(project.ci_commit(commit.sha)).to eq(commit) }
end
- describe :enable_ci do
+ describe :builds_enabled do
let(:project) { create :project }
- before { project.enable_ci }
+ before { project.builds_enabled = true }
- it { expect(project.gitlab_ci?).to be_truthy }
+ subject { project.builds_enabled }
+
+ it { is_expected.to eq(project.gitlab_ci_service.active) }
+ it { expect(project.builds_enabled?).to be_truthy }
it { expect(project.gitlab_ci_project).to be_a(Ci::Project) }
end
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index e9de9e0826d..9fc294118ae 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -88,8 +88,11 @@ describe API::API, api: true do
end
it 'returns projects in the correct order when ci_enabled_first parameter is passed' do
- [project, project2, project3].each{ |project| project.build_missing_services }
- project2.gitlab_ci_service.update(active: true)
+ [project, project2, project3].each do |project|
+ project.builds_enabled = false
+ project.build_missing_services
+ end
+ project2.builds_enabled = true
get api('/projects', user), { ci_enabled_first: 'true' }
expect(response.status).to eq(200)
expect(json_response).to be_an Array
diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb
index c0226605a23..b180d2fec77 100644
--- a/spec/requests/api/services_spec.rb
+++ b/spec/requests/api/services_spec.rb
@@ -46,6 +46,7 @@ describe API::API, api: true do
delete api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response.status).to eq(200)
+ project.send(service_method).reload
expect(project.send(service_method).activated?).to be_falsey
end
end
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index 25277f07482..e81c4edb7d8 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -70,6 +70,28 @@ describe Projects::CreateService do
end
end
+ context 'builds_enabled global setting' do
+ let(:project) { create_project(@user, @opts) }
+
+ subject { project.builds_enabled? }
+
+ context 'global builds_enabled false does not enable CI by default' do
+ before do
+ @opts.merge!(builds_enabled: false)
+ end
+
+ it { is_expected.to be_falsey }
+ end
+
+ context 'global builds_enabled true does enable CI by default' do
+ before do
+ @opts.merge!(builds_enabled: true)
+ end
+
+ it { is_expected.to be_truthy }
+ end
+ end
+
context 'restricted visibility level' do
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index 65a8c81204d..e397b2b9b4a 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -46,7 +46,7 @@ describe Projects::ForkService do
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
+ expect(@to_project.builds_enabled?).to be_truthy
end
end
end