diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-17 03:06:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-17 03:06:11 +0300 |
commit | 48c77599ca5d833ce01ca310af4887200875174f (patch) | |
tree | aade7cdac1b3f5ee266f5df1caf3b745dcd14a8d /spec | |
parent | 274ea604fcd43ecccfba04756a9475a3efa47de0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/projects_spec.rb | 31 | ||||
-rw-r--r-- | spec/services/projects/create_from_template_service_spec.rb | 4 |
2 files changed, 31 insertions, 4 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 550c7d135a6..f52e36e6bcd 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -631,6 +631,33 @@ describe API::Projects do expect(project.project_feature.wiki_access_level).to eq(ProjectFeature::DISABLED) end + it 'creates a project using a template' do + expect { post api('/projects', user), params: { template_name: 'rails', name: 'rails-test' } } + .to change { Project.count }.by(1) + + expect(response).to have_gitlab_http_status(201) + + project = Project.find(json_response['id']) + expect(project).to be_saved + expect(project.import_type).to eq('gitlab_project') + end + + it 'returns 400 for an invalid template' do + expect { post api('/projects', user), params: { template_name: 'unknown', name: 'rails-test' } } + .not_to change { Project.count } + + expect(response).to have_gitlab_http_status(400) + expect(json_response['message']['template_name']).to eq(["'unknown' is unknown or invalid"]) + end + + it 'disallows creating a project with an import_url and template' do + project_params = { import_url: 'http://example.com', template_name: 'rails', name: 'rails-test' } + expect { post api('/projects', user), params: project_params } + .not_to change { Project.count } + + expect(response).to have_gitlab_http_status(400) + end + it 'sets a project as public' do project = attributes_for(:project, visibility: 'public') @@ -867,7 +894,7 @@ describe API::Projects do expect { post api("/projects/user/#{user.id}", admin), params: { name: 'Foo Project' } }.to change { Project.count }.by(1) expect(response).to have_gitlab_http_status(201) - project = Project.last + project = Project.find(json_response['id']) expect(project.name).to eq('Foo Project') expect(project.path).to eq('foo-project') @@ -878,7 +905,7 @@ describe API::Projects do .to change { Project.count }.by(1) expect(response).to have_gitlab_http_status(201) - project = Project.last + project = Project.find(json_response['id']) expect(project.name).to eq('Foo Project') expect(project.path).to eq('path-project-Foo') diff --git a/spec/services/projects/create_from_template_service_spec.rb b/spec/services/projects/create_from_template_service_spec.rb index 6c244d23877..0b4772e8f02 100644 --- a/spec/services/projects/create_from_template_service_spec.rb +++ b/spec/services/projects/create_from_template_service_spec.rb @@ -25,7 +25,7 @@ describe Projects::CreateFromTemplateService do subject.execute end - it 'returns the project thats created' do + it 'returns the project that is created' do project = subject.execute expect(project).to be_saved @@ -37,7 +37,7 @@ describe Projects::CreateFromTemplateService do let(:project) { subject.execute } before do - expect(project).to be_saved + expect(project).not_to be_saved end it 'does not set import set import type' do |