summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMathieu Parent <math.parent@gmail.com>2019-05-15 16:27:54 +0200
committerMathieu Parent <math.parent@gmail.com>2019-07-03 16:18:05 +0200
commite44167004dd44cf727829d0fc9df59fe3404bb49 (patch)
treecdc94639756dc8cfbb996bd84c26540205a75ae9 /spec
parent5028f5d73d8fa69f72ac8d2b1cc493d82cf6f3e4 (diff)
downloadgitlab-ce-e44167004dd44cf727829d0fc9df59fe3404bb49.tar.gz
Add auto_devops_* to project API
The auto_devops object sometimes doesn't exists. We may need to create it.
Diffstat (limited to 'spec')
-rw-r--r--spec/models/concerns/project_api_compatibility_spec.rb25
-rw-r--r--spec/requests/api/projects_spec.rb20
2 files changed, 43 insertions, 2 deletions
diff --git a/spec/models/concerns/project_api_compatibility_spec.rb b/spec/models/concerns/project_api_compatibility_spec.rb
index a999f60a1f3..8cecd4fe7bc 100644
--- a/spec/models/concerns/project_api_compatibility_spec.rb
+++ b/spec/models/concerns/project_api_compatibility_spec.rb
@@ -5,13 +5,34 @@ require 'spec_helper'
describe ProjectAPICompatibility do
let(:project) { create(:project) }
+ # git_strategy
it "converts build_git_strategy=fetch to build_allow_git_fetch=true" do
- project.update!(:build_git_strategy, 'fetch')
+ project.update!(build_git_strategy: 'fetch')
expect(project.build_allow_git_fetch).to eq(true)
end
it "converts build_git_strategy=clone to build_allow_git_fetch=false" do
- project.update!(:build_git_strategy, 'clone')
+ project.update!(build_git_strategy: 'clone')
expect(project.build_allow_git_fetch).to eq(false)
end
+
+ # auto_devops_enabled
+ it "converts auto_devops_enabled=false to auto_devops_enabled?=false" do
+ expect(project.auto_devops_enabled?).to eq(true)
+ project.update!(auto_devops_enabled: false)
+ expect(project.auto_devops_enabled?).to eq(false)
+ end
+
+ it "converts auto_devops_enabled=true to auto_devops_enabled?=true" do
+ expect(project.auto_devops_enabled?).to eq(true)
+ project.update!(auto_devops_enabled: true)
+ expect(project.auto_devops_enabled?).to eq(true)
+ end
+
+ # auto_devops_deploy_strategy
+ it "converts auto_devops_deploy_strategy=timed_incremental to auto_devops.deploy_strategy=timed_incremental" do
+ expect(project.auto_devops).to be_nil
+ project.update!(auto_devops_deploy_strategy: 'timed_incremental')
+ expect(project.auto_devops.deploy_strategy).to eq('timed_incremental')
+ end
end
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 2fc257a1a06..df4758f362b 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -1980,6 +1980,26 @@ describe API::Projects do
'-/system/project/avatar/'\
"#{project3.id}/banana_sample.gif")
end
+
+ it 'updates auto_devops_deploy_strategy' do
+ project_param = { auto_devops_deploy_strategy: 'timed_incremental' }
+
+ put api("/projects/#{project3.id}", user), params: project_param
+
+ expect(response).to have_gitlab_http_status(200)
+
+ expect(json_response['auto_devops_deploy_strategy']).to eq('timed_incremental')
+ end
+
+ it 'updates auto_devops_enabled' do
+ project_param = { auto_devops_enabled: false }
+
+ put api("/projects/#{project3.id}", user), params: project_param
+
+ expect(response).to have_gitlab_http_status(200)
+
+ expect(json_response['auto_devops_enabled']).to eq(false)
+ end
end
context 'when authenticated as project maintainer' do