summaryrefslogtreecommitdiff
path: root/spec/services/projects
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2017-03-27 17:14:01 -0400
committerRobert Speicher <rspeicher@gmail.com>2017-03-27 20:44:09 -0400
commitca9a79f62026aa63ab44665aa51a8e88de941b01 (patch)
tree5f98c43b79cdb30c60a75613f0f0e5f457a0e20c /spec/services/projects
parentd4c99f644a2da2aa340aee8bc10c1dcf7c9e0d18 (diff)
downloadgitlab-ce-ca9a79f62026aa63ab44665aa51a8e88de941b01.tar.gz
Use `:empty_project` where possible in service specs
Diffstat (limited to 'spec/services/projects')
-rw-r--r--spec/services/projects/destroy_service_spec.rb2
-rw-r--r--spec/services/projects/download_service_spec.rb4
-rw-r--r--spec/services/projects/fork_service_spec.rb15
-rw-r--r--spec/services/projects/housekeeping_service_spec.rb2
-rw-r--r--spec/services/projects/transfer_service_spec.rb6
-rw-r--r--spec/services/projects/update_pages_service_spec.rb6
-rw-r--r--spec/services/projects/update_service_spec.rb4
-rw-r--r--spec/services/projects/upload_service_spec.rb4
8 files changed, 23 insertions, 20 deletions
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
index 74bfba44dfd..b1e10f4562e 100644
--- a/spec/services/projects/destroy_service_spec.rb
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::DestroyService, services: true do
let!(:user) { create(:user) }
- let!(:project) { create(:project, namespace: user.namespace) }
+ let!(:project) { create(:project, :repository, namespace: user.namespace) }
let!(:path) { project.repository.path_to_repo }
let!(:remove_path) { path.sub(/\.git\Z/, "+#{project.id}+deleted.git") }
let!(:async) { false } # execute or async_execute
diff --git a/spec/services/projects/download_service_spec.rb b/spec/services/projects/download_service_spec.rb
index 122a7cea2a1..33b267c069c 100644
--- a/spec/services/projects/download_service_spec.rb
+++ b/spec/services/projects/download_service_spec.rb
@@ -3,8 +3,8 @@ require 'spec_helper'
describe Projects::DownloadService, services: true do
describe 'File service' do
before do
- @user = create :user
- @project = create :project, creator_id: @user.id, namespace: @user.namespace
+ @user = create(:user)
+ @project = create(:empty_project, creator_id: @user.id, namespace: @user.namespace)
end
context 'for a URL that is not on whitelist' do
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index e3be1989c93..f8eb34f2ef4 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -7,6 +7,7 @@ describe Projects::ForkService, services: true do
@from_user = create(:user, namespace: @from_namespace )
avatar = fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")
@from_project = create(:project,
+ :repository,
creator_id: @from_user.id,
namespace: @from_namespace,
star_count: 107,
@@ -54,7 +55,7 @@ describe Projects::ForkService, services: true do
context 'project already exists' do
it "fails due to validation, not transaction failure" do
- @existing_project = create(:project, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace)
+ @existing_project = create(:project, :repository, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace)
@to_project = fork_project(@from_project, @to_user)
expect(@existing_project).to be_persisted
@@ -104,9 +105,10 @@ describe Projects::ForkService, services: true do
before do
@group_owner = create(:user)
@developer = create(:user)
- @project = create(:project, creator_id: @group_owner.id,
- star_count: 777,
- description: 'Wow, such a cool project!')
+ @project = create(:project, :repository,
+ creator_id: @group_owner.id,
+ star_count: 777,
+ description: 'Wow, such a cool project!')
@group = create(:group)
@group.add_user(@group_owner, GroupMember::OWNER)
@group.add_user(@developer, GroupMember::DEVELOPER)
@@ -139,8 +141,9 @@ describe Projects::ForkService, services: true do
context 'project already exists in group' do
it 'fails due to validation, not transaction failure' do
- existing_project = create(:project, name: @project.name,
- namespace: @group)
+ existing_project = create(:project, :repository,
+ name: @project.name,
+ namespace: @group)
to_project = fork_project(@project, @group_owner, @opts)
expect(existing_project.persisted?).to be_truthy
expect(to_project.errors[:name]).to eq(['has already been taken'])
diff --git a/spec/services/projects/housekeeping_service_spec.rb b/spec/services/projects/housekeeping_service_spec.rb
index 57a5aa5cedc..eaf63457b32 100644
--- a/spec/services/projects/housekeeping_service_spec.rb
+++ b/spec/services/projects/housekeeping_service_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::HousekeepingService do
subject { Projects::HousekeepingService.new(project) }
- let(:project) { create :project }
+ let(:project) { create(:project, :repository) }
before do
project.reset_pushes_since_gc
diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb
index 5c6fbea8d0e..f8187fefc14 100644
--- a/spec/services/projects/transfer_service_spec.rb
+++ b/spec/services/projects/transfer_service_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::TransferService, services: true do
let(:user) { create(:user) }
let(:group) { create(:group) }
- let(:project) { create(:project, namespace: user.namespace) }
+ let(:project) { create(:project, :repository, namespace: user.namespace) }
context 'namespace -> namespace' do
before do
@@ -58,7 +58,7 @@ describe Projects::TransferService, services: true do
before { internal_group.add_owner(user) }
context 'when namespace visibility level < project visibility level' do
- let(:public_project) { create(:project, :public, namespace: user.namespace) }
+ let(:public_project) { create(:project, :public, :repository, namespace: user.namespace) }
before { transfer_project(public_project, user, internal_group) }
@@ -66,7 +66,7 @@ describe Projects::TransferService, services: true do
end
context 'when namespace visibility level > project visibility level' do
- let(:private_project) { create(:project, :private, namespace: user.namespace) }
+ let(:private_project) { create(:project, :private, :repository, namespace: user.namespace) }
before { transfer_project(private_project, user, internal_group) }
diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb
index f75fdd9e03f..fc0a17296f3 100644
--- a/spec/services/projects/update_pages_service_spec.rb
+++ b/spec/services/projects/update_pages_service_spec.rb
@@ -1,9 +1,9 @@
require "spec_helper"
describe Projects::UpdatePagesService do
- let(:project) { create :project }
- let(:pipeline) { create :ci_pipeline, project: project, sha: project.commit('HEAD').sha }
- let(:build) { create :ci_build, pipeline: pipeline, ref: 'HEAD' }
+ let(:project) { create(:project, :repository) }
+ let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) }
+ let(:build) { create(:ci_build, pipeline: pipeline, ref: 'HEAD') }
let(:invalid_file) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png') }
subject { described_class.new(project, build) }
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index caa23962519..05b18fef061 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::UpdateService, services: true do
let(:user) { create(:user) }
let(:admin) { create(:admin) }
- let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
+ let(:project) { create(:empty_project, creator_id: user.id, namespace: user.namespace) }
describe 'update_by_user' do
context 'when visibility_level is INTERNAL' do
@@ -56,7 +56,7 @@ describe Projects::UpdateService, services: true do
end
describe 'visibility_level' do
- let(:project) { create(:project, :internal) }
+ let(:project) { create(:empty_project, :internal) }
let(:forked_project) { create(:forked_project_with_submodules, :internal) }
before do
diff --git a/spec/services/projects/upload_service_spec.rb b/spec/services/projects/upload_service_spec.rb
index 150c8ccaef7..d2cefa46bfa 100644
--- a/spec/services/projects/upload_service_spec.rb
+++ b/spec/services/projects/upload_service_spec.rb
@@ -3,8 +3,8 @@ require 'spec_helper'
describe Projects::UploadService, services: true do
describe 'File service' do
before do
- @user = create :user
- @project = create :project, creator_id: @user.id, namespace: @user.namespace
+ @user = create(:user)
+ @project = create(:empty_project, creator_id: @user.id, namespace: @user.namespace)
end
context 'for valid gif file' do