Commit 0bc1dfb6 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-empty_project-cleanup' into 'master'

Ensure all project factories use `:repository` trait or `:empty_project`

See merge request !13238
parents c73f0c48 9513bd18
......@@ -4,7 +4,7 @@ describe Admin::ApplicationSettingsController do
include StubENV
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:project) { create(:empty_project, namespace: group) }
let(:admin) { create(:admin) }
let(:user) { create(:user)}
......
......@@ -8,8 +8,8 @@ describe Admin::DashboardController do
it 'does not retrieve projects that are pending deletion' do
sign_in(create(:admin))
project = create(:project)
pending_delete_project = create(:project, pending_delete: true)
project = create(:empty_project)
pending_delete_project = create(:empty_project, pending_delete: true)
get :index
......
......@@ -65,7 +65,7 @@ describe AutocompleteController do
end
context 'non-member login for public project' do
let!(:project) { create(:project, :public) }
let!(:project) { create(:empty_project, :public) }
before do
sign_in(non_member)
......@@ -127,7 +127,7 @@ describe AutocompleteController do
end
context 'unauthenticated user' do
let(:public_project) { create(:project, :public) }
let(:public_project) { create(:empty_project, :public) }
let(:body) { JSON.parse(response.body) }
describe 'GET #users with public project' do
......@@ -231,8 +231,8 @@ describe AutocompleteController do
end
context 'GET projects' do
let(:authorized_project) { create(:project) }
let(:authorized_search_project) { create(:project, name: 'rugged') }
let(:authorized_project) { create(:empty_project) }
let(:authorized_search_project) { create(:empty_project, name: 'rugged') }
before do
sign_in(user)
......@@ -289,8 +289,8 @@ describe AutocompleteController do
context 'authorized projects apply limit' do
before do
authorized_project2 = create(:project)
authorized_project3 = create(:project)
authorized_project2 = create(:empty_project)
authorized_project3 = create(:empty_project)
authorized_project.add_master(user)
authorized_project2.add_master(user)
......@@ -315,8 +315,8 @@ describe AutocompleteController do
context 'authorized projects with offset' do
before do
authorized_project2 = create(:project)
authorized_project3 = create(:project)
authorized_project2 = create(:empty_project)
authorized_project3 = create(:empty_project)
authorized_project.add_master(user)
authorized_project2.add_master(user)
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe DashboardController do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
before do
project.team << [user, :master]
......
require 'spec_helper'
describe Projects::MergeRequests::ConflictsController do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
let(:merge_request_with_conflicts) do
......
require 'spec_helper'
describe Projects::MergeRequests::CreationsController do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
let(:fork_project) { create(:forked_project_with_submodules) }
......@@ -83,7 +83,7 @@ describe Projects::MergeRequests::CreationsController do
end
context 'when the source branch is in a different project to the target' do
let(:other_project) { create(:project) }
let(:other_project) { create(:project, :repository) }
before do
other_project.team << [user, :master]
......
require 'spec_helper'
describe Projects::MergeRequests::DiffsController do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
......@@ -36,7 +36,7 @@ describe Projects::MergeRequests::DiffsController do
context 'with forked projects with submodules' do
render_views
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:fork_project) { create(:forked_project_with_submodules) }
let(:merge_request) { create(:merge_request_with_diffs, source_project: fork_project, source_branch: 'add-submodule-version-bump', target_branch: 'master', target_project: project) }
......
require 'spec_helper'
describe Projects::MergeRequestsController do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
let(:merge_request_with_conflicts) do
......@@ -191,7 +191,7 @@ describe Projects::MergeRequestsController do
end
context 'there is no source project' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:fork_project) { create(:forked_project_with_submodules) }
let(:merge_request) { create(:merge_request, source_project: fork_project, source_branch: 'add-submodule-version-bump', target_branch: 'master', target_project: project) }
......@@ -429,7 +429,7 @@ describe Projects::MergeRequestsController do
context "when the user is owner" do
let(:owner) { create(:user) }
let(:namespace) { create(:namespace, owner: owner) }
let(:project) { create(:project, namespace: namespace) }
let(:project) { create(:project, :repository, namespace: namespace) }
before do
sign_in owner
......@@ -587,7 +587,7 @@ describe Projects::MergeRequestsController do
describe 'GET ci_environments_status' do
context 'the environment is from a forked project' do
let!(:forked) { create(:project) }
let!(:forked) { create(:project, :repository) }
let!(:environment) { create(:environment, project: forked) }
let!(:deployment) { create(:deployment, environment: environment, sha: forked.commit.id, ref: 'master') }
let(:admin) { create(:admin) }
......
......@@ -167,10 +167,10 @@ describe Projects::NotesController do
end
context 'when creating a commit comment from an MR fork' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:fork_project) do
create(:project).tap do |fork|
create(:project, :repository).tap do |fork|
create(:forked_project_link, forked_to_project: fork, forked_from_project: project)
end
end
......
......@@ -61,7 +61,7 @@ describe Projects::PipelinesController do
create_build('post deploy', 3, 'pages 0')
end
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_empty_pipeline, project: project, user: user, sha: project.commit.id)
end
......
......@@ -156,7 +156,7 @@ describe Projects::SnippetsController do
end
describe 'PUT #update' do
let(:project) { create :project, :public }
let(:project) { create :empty_project, :public }
let(:snippet) { create :project_snippet, author: user, project: project, visibility_level: visibility_level }
def update_snippet(snippet_params = {}, additional_params = {})
......
......@@ -196,7 +196,7 @@ describe ProjectsController do
context "redirection from http://someproject.git" do
it 'redirects to project page (format.html)' do
project = create(:project, :public)
project = create(:empty_project, :public)
get :show, namespace_id: project.namespace, id: project, format: :git
......@@ -254,7 +254,7 @@ describe ProjectsController do
describe '#transfer' do
render_views
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:admin) { create(:admin) }
let(:new_namespace) { create(:namespace) }
......@@ -311,8 +311,8 @@ describe ProjectsController do
end
context "when the project is forked" do
let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) }
let(:project) { create(:project, :repository) }
let(:fork_project) { create(:project, :repository, forked_from_project: project) }
let(:merge_request) do
create(:merge_request,
source_project: fork_project,
......@@ -390,7 +390,7 @@ describe ProjectsController do
end
context 'with forked project' do
let(:project_fork) { create(:project, namespace: user.namespace) }
let(:project_fork) { create(:project, :repository, namespace: user.namespace) }
before do
create(:forked_project_link, forked_to_project: project_fork)
......@@ -408,7 +408,7 @@ describe ProjectsController do
end
context 'when project not forked' do
let(:unforked_project) { create(:project, namespace: user.namespace) }
let(:unforked_project) { create(:empty_project, namespace: user.namespace) }
it 'does nothing if project was not forked' do
delete(:remove_fork,
......@@ -430,7 +430,7 @@ describe ProjectsController do
end
describe "GET refs" do
let(:public_project) { create(:project, :public) }
let(:public_project) { create(:project, :public, :repository) }
it "gets a list of branches and tags" do
get :refs, namespace_id: public_project.namespace, id: public_project
......
......@@ -273,7 +273,7 @@ describe SnippetsController do
end
describe 'PUT #update' do
let(:project) { create :project }
let(:project) { create :empty_project }
let(:snippet) { create :personal_snippet, author: user, project: project, visibility_level: visibility_level }
def update_snippet(snippet_params = {}, additional_params = {})
......
FactoryGirl.define do
factory :upload do
model { build(:project) }
model { build(:empty_project) }
path { "uploads/-/system/project/avatar/avatar.jpg" }
size 100.kilobytes
uploader "AvatarUploader"
......
......@@ -2,8 +2,8 @@ require 'spec_helper'
feature 'Dashboard Projects' do
let(:user) { create(:user) }
let(:project) { create(:project, name: 'awesome stuff') }
let(:project2) { create(:project, :public, name: 'Community project') }
let(:project) { create(:project, :repository, name: 'awesome stuff') }
let(:project2) { create(:empty_project, :public, name: 'Community project') }
before do
project.team << [user, :developer]
......
......@@ -4,7 +4,7 @@ describe 'Discussion Comments Merge Request', :js do
include RepoHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
before do
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'Discussion Comments Merge Request', :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
before do
......
......@@ -2,7 +2,7 @@ require 'rails_helper'
describe 'Markdown References', :js do
let(:user) { create(:user) }
let(:actual_project) { create(:project, :public) }
let(:actual_project) { create(:project, :public, :repository) }
let(:merge_request) { create(:merge_request, target_project: actual_project, source_project: actual_project)}
let(:issue_actual_project) { create(:issue, project: actual_project) }
let!(:other_project) { create(:empty_project, :public) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
feature 'Editing file blob', js: true do
include TreeHelper
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'feature', target_branch: 'master') }
let(:branch) { 'master' }
let(:file_path) { project.repository.ls_files(project.repository.root_ref)[1] }
......
......@@ -4,7 +4,7 @@ describe 'Reportable note on commit', :js do
include RepoHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
before do
project.add_master(user)
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'Reportable note on merge request', :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
before do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe MembersFinder, '#execute' do
let(:group) { create(:group) }
let(:nested_group) { create(:group, :access_requestable, parent: group) }
let(:project) { create(:project, namespace: nested_group) }
let(:project) { create(:empty_project, namespace: nested_group) }
let(:user1) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe ButtonHelper do
describe 'http_clone_button' do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { build_stubbed(:empty_project) }
let(:has_tooltip_class) { 'has-tooltip' }
def element
......
......@@ -48,7 +48,7 @@ describe CiStatusHelper do
describe "#pipeline_status_cache_key" do
it "builds a cache key for pipeline status" do
pipeline_status = Gitlab::Cache::Ci::ProjectPipelineStatus.new(
build(:project),
build_stubbed(:empty_project),
pipeline_info: {
sha: "123abc",
status: "success"
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe DiffHelper do
include RepoHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:commit) { project.commit(sample_commit.id) }
let(:diffs) { commit.raw_diffs }
......
......@@ -180,7 +180,7 @@ describe IssuablesHelper do
context 'when show_full_reference falsey' do
context 'when @group present' do
it 'display issuable reference to @group' do
project = build_stubbed(:project)
project = build_stubbed(:empty_project)
assign(:show_full_reference, nil)
assign(:group, project.namespace)
......@@ -193,7 +193,7 @@ describe IssuablesHelper do
context 'when @project present' do
it 'display issuable reference to @project' do
project = build_stubbed(:project)
project = build_stubbed(:empty_project)
assign(:show_full_reference, nil)
assign(:group, nil)
......
......@@ -42,7 +42,7 @@ describe MarkupHelper do
describe "override default project" do
let(:actual) { issue.to_reference }
let(:second_project) { create(:project, :public) }
let(:second_project) { create(:empty_project, :public) }
let(:second_issue) { create(:issue, project: second_project) }
it 'links to the issue' do
......
......@@ -40,7 +40,7 @@ describe NotesHelper do
end
describe '#discussion_path' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
context 'for a merge request discusion' do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, importing: true) }
......
......@@ -46,7 +46,7 @@ describe ProjectsHelper do
end
describe "readme_cache_key" do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
before do
helper.instance_variable_set(:@project, project)
......@@ -64,7 +64,7 @@ describe ProjectsHelper do
end
describe "#project_list_cache_key", clean_gitlab_redis_shared_state: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
it "includes the route" do
expect(helper.project_list_cache_key(project)).to include(project.route.cache_key)
......@@ -251,7 +251,7 @@ describe ProjectsHelper do
end
describe '#sanitized_import_error' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
before do
allow(project).to receive(:repository_storage_path).and_return('/base/repo/path')
......
......@@ -4,7 +4,7 @@ describe 'Balsamiq file', '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, namespace: namespace, path: 'balsamiq-project') }
let(:project) { create(:project, :repository, namespace: namespace, path: 'balsamiq-project') }
before(:all) do
clean_frontend_fixtures('blob/balsamiq/')
......
......@@ -5,7 +5,7 @@ describe Dashboard::ProjectsController, '(JavaScript fixtures)', type: :controll
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, namespace: namespace, path: 'builds-project') }
let(:project) { create(:empty_project, namespace: namespace, path: 'builds-project') }
render_views
......
......@@ -5,7 +5,7 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, namespace: namespace, path: 'merge-requests-project') }
let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') }
let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') }
let(:merged_merge_request) { create(:merge_request, :merged, source_project: project, target_project: project) }
let(:pipeline) do
......
......@@ -6,7 +6,7 @@ describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, namespace: namespace, path: 'merge-requests-project') }
let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') }
let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') }
let(:path) { "files/ruby/popen.rb" }
let(:position) do
......
......@@ -4,7 +4,7 @@ describe 'PDF file', '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, namespace: namespace, path: 'pdf-project') }
let(:project) { create(:project, :repository, namespace: namespace, path: 'pdf-project') }
before(:all) do
clean_frontend_fixtures('blob/pdf/')
......
......@@ -5,7 +5,7 @@ describe ProjectsController, '(JavaScript fixtures)', type: :controller do
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, namespace: namespace, path: 'builds-project') }
let(:project) { create(:empty_project, namespace: namespace, path: 'builds-project') }
render_views
......
......@@ -4,7 +4,7 @@ describe 'Raw files', '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, namespace: namespace, path: 'raw-project') }
let(:project) { create(:project, :repository, namespace: namespace, path: 'raw-project') }
before(:all) do
clean_frontend_fixtures('blob/notebook/')
......
require 'spec_helper'
describe Banzai::Filter::ReferenceFilter do
let(:project) { build(:project) }
let(:project) { build_stubbed(:empty_project) }
describe '#each_node' do
it 'iterates over the nodes in a document' do
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe ContainerRegistry::Tag do
let(:group) { create(:group, name: 'group') }
let(:project) { create(:project, path: 'test', group: group) }
let(:project) { create(:project, :repository, path: 'test', group: group) }
let(:repository) do
create(:container_repository, name: '', project: project)
......
require 'spec_helper'
describe Gitlab::Badge::Coverage::Report do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:job_name) { nil }
let(:badge) do
......
require 'spec_helper'
describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
let!(:project) { create(:project) }
let!(:project) { create(:project, :repository) }
let(:pipeline_status) { described_class.new(project) }
let(:cache_key) { "projects/#{project.id}/pipeline_status" }
......@@ -18,7 +18,7 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
let(:sha) { '424d1b73bc0d3cb726eb7dc4ce17a4d48552f8c6' }
let(:ref) { 'master' }
let(:pipeline_info) { { sha: sha, status: status, ref: ref } }
let!(:project_without_status) { create(:project) }
let!(:project_without_status) { create(:project, :repository) }
describe '.load_in_batch_for_projects' do
it 'preloads pipeline_status on projects' do
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::CycleAnalytics::BaseEventFetcher do
let(:max_events) { 2 }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user, :admin) }
let(:start_time_attrs) { Issue.arel_table[:created_at] }
let(:end_time_attrs) { [Issue::Metrics.arel_table[:first_associated_with_milestone_at]] }
......
require 'spec_helper'
describe 'cycle analytics events' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:from_date) { 10.days.ago }
let(:user) { create(:user, :admin) }
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
......
......@@ -94,7 +94,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :trunca
end
it "renames the route for projects of the namespace" do
project = create(:project, path: "project-path", namespace: namespace)
project = create(:project, :repository, path: "project-path", namespace: namespace)
subject.rename_path_for_routable(migration_namespace(namespace))
......@@ -120,7 +120,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :trunca
context "the-path namespace -> subgroup -> the-path0 project" do
it "updates the route of the project correctly" do
subgroup = create(:group, path: "subgroup", parent: namespace)
project = create(:project, path: "the-path0", namespace: subgroup)
project = create(:project, :repository, path: "the-path0", namespace: subgroup)
subject.rename_path_for_routable(migration_namespace(namespace))
......@@ -165,7 +165,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :trunca
it 'renames all the routes for the namespace' do
child = create(:group, path: 'child', parent: namespace)
project = create(:project, namespace: child, path: 'the-project')
project = create(:project, :repository, namespace: child, path: 'the-project')
other_one = create(:namespace, path: 'the-path-is-similar')
subject.perform_rename(migration_namespace(namespace), 'the-path', 'renamed')
......
......@@ -94,7 +94,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
describe '#move_repositories' do
let(:namespace) { create(:group, name: 'hello-group') }
it 'moves a project for a namespace' do
create(:project, namespace: namespace, path: 'hello-project')
create(:project, :repository, namespace: namespace, path: 'hello-project')
expected_path = File.join(TestEnv.repos_path, 'bye-group', 'hello-project.git')
subject.move_repositories(namespace, 'hello-group', 'bye-group')
......@@ -104,7 +104,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
it 'moves a namespace in a subdirectory correctly' do
child_namespace = create(:group, name: 'sub-group', parent: namespace)
create(:project, namespace: child_namespace, path: 'hello-project')
create(:project, :repository, namespace: child_namespace, path: 'hello-project')
expected_path = File.join(TestEnv.repos_path, 'hello-group', 'renamed-sub-group', 'hello-project.git')
......@@ -115,7 +115,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
it 'moves a parent namespace with subdirectories' do
child_namespace = create(:group, name: 'sub-group', parent: namespace)
create(:project, namespace: child_namespace, path: 'hello-project')
create(:project, :repository, namespace: child_namespace, path: 'hello-project')
expected_path = File.join(TestEnv.repos_path, 'renamed-group', 'sub-group', 'hello-project.git')
subject.move_repositories(child_namespace, 'hello-group', 'renamed-group')
......@@ -166,7 +166,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
describe '#rename_namespace_dependencies' do
it "moves the the repository for a project in the namespace" do
create(:project, namespace: namespace, path: "the-path-project")
create(:project, :repository, namespace: namespace, path: "the-path-project")
expected_repo = File.join(TestEnv.repos_path, "the-path0", "the-path-project.git")
subject.rename_namespace_dependencies(namespace, 'the-path', 'the-path0')
......@@ -243,7 +243,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
describe '#revert_renames', redis: true do
it 'renames the routes back to the previous values' do
project = create(:project, path: 'a-project', namespace: namespace)
project = create(:project, :repository, path: 'a-project', namespace: namespace)
subject.rename_namespace(namespace)
expect(subject).to receive(:perform_rename)
......@@ -261,7 +261,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
end
it 'moves the repositories back to their original place' do
project = create(:project, path: 'a-project', namespace: namespace)
project = create(:project, :repository, path: 'a-project', namespace: namespace)
project.create_repository
subject.rename_namespace(namespace)
......
......@@ -104,7 +104,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :tr
describe '#move_repository' do
let(:known_parent) { create(:namespace, path: 'known-parent') }
let(:project) { create(:project, path: 'the-path', namespace: known_parent) }
let(:project) { create(:project, :repository, path: 'the-path', namespace: known_parent) }
it 'moves the repository for a project' do
expected_path = File.join(TestEnv.repos_path, 'known-parent', 'new-repo.git')
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Diff::Parser do
include RepoHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:commit) { project.commit(sample_commit.id) }
let(:diff) { commit.raw_diffs.first }
let(:parser) { described_class.new }
......
......@@ -2,7 +2,7 @@ require "spec_helper"
describe Gitlab::Email::AttachmentUploader do
describe "#execute" do
let(:project) { build(:project) }
let(:project) { build(:empty_project) }
let(:message_raw) { fixture_file("emails/attachment.eml") }
let(:message) { Mail::Message.new(message_raw) }
......
......@@ -69,7 +69,7 @@ describe Gitlab::Email::Handler::CreateIssueHandler do
end
context "when project is private" do
let(:project) { create(:project, :private, namespace: namespace) }
let(:project) { create(:empty_project, :private, namespace: namespace) }
it "raises a ProjectNotFound if the user is not a member" do
expect { receiver.execute }.to raise_error(Gitlab::Email::ProjectNotFound)
......
......@@ -207,7 +207,7 @@ describe Gitlab::GithubImport::Importer do
end
end
let(:project) { create(:project, :wiki_disabled, import_url: "#{repo_root}/octocat/Hello-World.git") }
let(:project) { create(:project, :repository, :wiki_disabled, import_url: "#{repo_root}/octocat/Hello-World.git") }
let(:octocat) { double(id: 123456, login: 'octocat', email: 'octocat@example.com') }
let(:credentials) { { user: 'joe' } }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::GithubImport::WikiFormatter do
let(:project) do
create(:project,
create(:empty_project,
namespace: create(:namespace, path: 'gitlabhq'),
import_url: 'https://xxx@github.com/gitlabhq/sample.gitlabhq.git')
end
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe ::Gitlab::GlRepository do
describe '.parse' do
set(:project) { create(:project) }
set(:project) { create(:project, :repository) }
it 'parses a project gl_repository' do
expect(described_class.parse("project-#{project.id}")).to eq([project, false])
......
......@@ -2,11 +2,11 @@ require 'spec_helper'
describe 'forked project import' do
let(:user) { create(:user) }
let!(:project_with_repo) { create(:project, name: 'test-repo-restorer', path: 'test-repo-restorer') }
let!(:project_with_repo) { create(:project, :repository, name: 'test-repo-restorer', path: 'test-repo-restorer') }
let!(:project) { create(:empty_project, name: 'test-repo-restorer-no-repo', path: 'test-repo-restorer-no-repo') }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.full_path) }
let(:forked_from_project) { create(:project) }
let(:forked_from_project) { create(:project, :repository) }
let(:fork_link) { create(:forked_project_link, forked_from_project: project_with_repo) }
let(:repo_saver) { Gitlab::ImportExport::RepoSaver.new(project: project_with_repo, shared: shared) }
let(:bundle_path) { File.join(shared.export_path, Gitlab::ImportExport.project_bundle_filename) }
......
......@@ -2,8 +2,8 @@ require 'spec_helper'
describe Gitlab::ImportExport::MergeRequestParser do
let(:user) { create(:user) }
let!(:project) { create(:project, name: 'test-repo-restorer', path: 'test-repo-restorer') }
let(:forked_from_project) { create(:project) }
let!(:project) { create(:project, :repository, name: 'test-repo-restorer', path: 'test-repo-restorer') }
let(:forked_from_project) { create(:project, :repository) }
let(:fork_link) { create(:forked_project_link, forked_from_project: project) }
let!(:merge_request) do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::ImportExport::RepoRestorer do
describe 'bundle a project Git repo' do
let(:user) { create(:user) }
let!(:project_with_repo) { create(:project, name: 'test-repo-restorer', path: 'test-repo-restorer') }
let!(:project_with_repo) { create(:project, :repository, name: 'test-repo-restorer', path: 'test-repo-restorer') }
let!(:project) { create(:empty_project) }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.full_path) }
......
require 'spec_helper'
describe Gitlab::IssuableSorter do
let(:namespace1) { build(:namespace, id: 1) }
let(:project1) { build(:project, id: 1, namespace: namespace1) }
let(:namespace1) { build_stubbed(:namespace, id: 1) }
let(:project1) { build_stubbed(:empty_project, id: 1, namespace: namespace1) }
let(:project2) { build(:project, id: 2, path: "a", namespace: project1.namespace) }
let(:project3) { build(:project, id: 3, path: "b", namespace: project1.namespace) }
let(:project2) { build_stubbed(:empty_project, id: 2, path: "a", namespace: project1.namespace) }
let(:project3) { build_stubbed(:empty_project, id: 3, path: "b", namespace: project1.namespace) }
let(:namespace2) { build(:namespace, id: 2, path: "a") }
let(:namespace3) { build(:namespace, id: 3, path: "b") }
let(:project4) { build(:project, id: 4, path: "a", namespace: namespace2) }
let(:project5) { build(:project, id: 5, path: "b", namespace: namespace2) }
let(:project6) { build(:project, id: 6, path: "a", namespace: namespace3) }
let(:namespace2) { build_stubbed(:namespace, id: 2, path: "a") }
let(:namespace3) { build_stubbed(:namespace, id: 3, path: "b") }
let(:project4) { build_stubbed(:empty_project, id: 4, path: "a", namespace: namespace2) }
let(:project5) { build_stubbed(:empty_project, id: 5, path: "b", namespace: namespace2) }
let(:project6) { build_stubbed(:empty_project, id: 6, path: "a", namespace: namespace3) }
let(:unsorted) { [sorted[2], sorted[3], sorted[0], sorted[1]] }
let(:sorted) do
[build(:issue, iid: 1, project: project1),
build(:issue, iid: 2, project: project1),
build(:issue, iid: 10, project: project1),
build(:issue, iid: 20, project: project1)]
[build_stubbed(:issue, iid: 1, project: project1),
build_stubbed(:issue, iid: 2, project: project1),
build_stubbed(:issue, iid: 10, project: project1),
build_stubbed(:issue, iid: 20, project: project1)]
end
it 'sorts references by a given key' do
......@@ -41,14 +41,14 @@ describe Gitlab::IssuableSorter do
context 'for references from multiple projects and namespaces' do
let(:sorted) do
[build(:issue, iid: 1, project: project1),
build(:issue, iid: 2, project: project1),
build(:issue, iid: 10, project: project1),
build(:issue, iid: 1, project: project2),
build(:issue, iid: 1, project: project3),
build(:issue, iid: 1, project: project4),
build(:issue, iid: 1, project: project5),
build(:issue, iid: 1, project: project6)]
[build_stubbed(:issue, iid: 1, project: project1),
build_stubbed(:issue, iid: 2, project: project1),
build_stubbed(:issue, iid: 10, project: project1),
build_stubbed(:issue, iid: 1, project: project2),
build_stubbed(:issue, iid: 1, project: project3),
build_stubbed(:issue, iid: 1, project: project4),
build_stubbed(:issue, iid: 1, project: project5),
build_stubbed(:issue, iid: 1, project: project6)]
end
let(:unsorted) do
[sorted[3], sorted[1], sorted[4], sorted[2],
......
......@@ -18,7 +18,7 @@ describe Gitlab::Middleware::Go do
let(:current_user) { nil }
context 'with simple 2-segment project path' do
let!(:project) { create(:project, :private) }
let!(:project) { create(:empty_project, :private) }
context 'with subpackages' do
let(:path) { "#{project.full_path}/subpackage" }
......@@ -39,7 +39,7 @@ describe Gitlab::Middleware::Go do
context 'with a nested project path' do
let(:group) { create(:group, :nested) }
let!(:project) { create(:project, :public, namespace: group) }
let!(:project) { create(:empty_project, :public, namespace: group) }
shared_examples 'a nested project' do
context 'when the project is public' do
......
......@@ -100,14 +100,14 @@ describe Gitlab::ProjectSearchResults do
end
describe 'wiki search' do
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:wiki) { build(:project_wiki, project: project) }
let!(:wiki_page) { wiki.create_page('Title', 'Content') }
subject(:results) { described_class.new(user, project, 'Content').objects('wiki_blobs') }
context 'when wiki is disabled' do
let(:project) { create(:project, :public, :wiki_disabled) }
let(:project) { create(:empty_project, :public, :wiki_disabled) }
it 'hides wiki blobs from members' do
project.add_reporter(user)
......@@ -121,7 +121,7 @@ describe Gitlab::ProjectSearchResults do
end
context 'when wiki is internal' do
let(:project) { create(:project, :public, :wiki_private) }
let(:project) { create(:empty_project, :public, :wiki_private) }
it 'finds wiki blobs for guest' do
project.add_guest(user)
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe ::Gitlab::RepoPath do
describe '.parse' do
set(:project) { create(:project) }
set(:project) { create(:project, :repository) }
context 'a repository storage path' do
it 'parses a full repository path' do
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::UserAccess do
let(:access) { described_class.new(user, project: project) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
describe '#can_push_to_branch?' do
......
......@@ -58,7 +58,7 @@ describe RenameSystemNamespaces, truncate: true do
end
it "renames the route for projects of the namespace" do
project = build(:project, path: "project-path", namespace: system_namespace)
project = build(:project, :repository, path: "project-path", namespace: system_namespace)
save_invalid_routable(project)
migration.up
......@@ -68,7 +68,7 @@ describe RenameSystemNamespaces, truncate: true do
it "doesn't touch routes of namespaces that look like system" do
namespace = create(:group, path: 'systemlookalike')
project = create(:project, namespace: namespace, path: 'the-project')
project = create(:project, :repository, namespace: namespace, path: 'the-project')
migration.up
......@@ -77,7 +77,7 @@ describe RenameSystemNamespaces, truncate: true do
end
it "moves the the repository for a project in the namespace" do
project = build(:project, namespace: system_namespace, path: "system-project")
project = build(:project, :repository, namespace: system_namespace, path: "system-project")
save_invalid_routable(project)
TestEnv.copy_repo(project,
bare_repo: TestEnv.factory_repo_path_bare,
......@@ -105,7 +105,7 @@ describe RenameSystemNamespaces, truncate: true do
describe "clears the markdown cache for projects in the system namespace" do
let!(:project) do
project = build(:project, namespace: system_namespace)
project = build(:project, :repository, namespace: system_namespace)
save_invalid_routable(project)
project
end
......@@ -161,7 +161,7 @@ describe RenameSystemNamespaces, truncate: true do
it "updates the route of the project correctly" do
subgroup = build(:group, path: "subgroup", parent: system_namespace)
save_invalid_routable(subgroup)
project = build(:project, path: "system0", namespace: subgroup)
project = build(:project, :repository, path: "system0", namespace: subgroup)
save_invalid_routable(project)
migration.up
......@@ -174,7 +174,7 @@ describe RenameSystemNamespaces, truncate: true do
describe "#move_repositories" do
let(:namespace) { create(:group, name: "hello-group") }
it "moves a project for a namespace" do
create(:project, namespace: namespace, path: "hello-project")
create(:project, :repository, namespace: namespace, path: "hello-project")
expected_path = File.join(TestEnv.repos_path, "bye-group", "hello-project.git")
migration.move_repositories(namespace, "hello-group", "bye-group")
......@@ -184,7 +184,7 @@ describe RenameSystemNamespaces, truncate: true do
it "moves a namespace in a subdirectory correctly" do
child_namespace = create(:group, name: "sub-group", parent: namespace)
create(:project, namespace: child_namespace, path: "hello-project")
create(:project, :repository, namespace: child_namespace, path: "hello-project")
expected_path = File.join(TestEnv.repos_path, "hello-group", "renamed-sub-group", "hello-project.git")
......@@ -195,7 +195,7 @@ describe RenameSystemNamespaces, truncate: true do
it "moves a parent namespace with subdirectories" do
child_namespace = create(:group, name: "sub-group", parent: namespace)
create(:project, namespace: child_namespace, path: "hello-project")
create(:project, :repository, namespace: child_namespace, path: "hello-project")
expected_path = File.join(TestEnv.repos_path, "renamed-group", "sub-group", "hello-project.git")
migration.move_repositories(child_namespace, "hello-group", "renamed-group")
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe BlobViewer::ComposerJson do
include FakeBlobHelpers
let(:project) { build(:project) }
let(:project) { build_stubbed(:empty_project) }
let(:data) do
<<-SPEC.strip_heredoc
{
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe BlobViewer::Gemspec do
include FakeBlobHelpers
let(:project) { build(:project) }
let(:project) { build_stubbed(:empty_project) }
let(:data) do
<<-SPEC.strip_heredoc
Gem::Specification.new do |s|
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe BlobViewer::GitlabCiYml do
include FakeBlobHelpers
let(:project) { build(:project) }
let(:project) { build_stubbed(:empty_project) }
let(:data) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
let(:blob) { fake_blob(path: '.gitlab-ci.yml', data: data) }
subject { described_class.new(blob) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe BlobViewer::PackageJson do
include FakeBlobHelpers
let(:project) { build(:project) }
let(:project) { build_stubbed(:empty_project) }
let(:data) do
<<-SPEC.strip_heredoc
{
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe BlobViewer::PodspecJson do
include FakeBlobHelpers
let(:project) { build(:project) }
let(:project) { build_stubbed(:empty_project) }
let(:data) do
<<-SPEC.strip_heredoc
{
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe BlobViewer::Podspec do
include FakeBlobHelpers
let(:project) { build(:project) }
let(:project) { build_stubbed(:empty_project) }
let(:data) do
<<-SPEC.strip_heredoc
Pod::Spec.new do |spec|
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe BlobViewer::RouteMap do
include FakeBlobHelpers
let(:project) { build(:project) }
let(:project) { build_stubbed(:empty_project) }
let(:data) do
<<-MAP.strip_heredoc
# Team data
......
......@@ -24,7 +24,7 @@ describe Participable do
user1 = build(:user)
user2 = build(:user)
user3 = build(:user)
project = build(:project, :public)
project = build(:empty_project, :public)
instance = model.new
expect(instance).to receive(:foo).and_return(user2)
......@@ -57,7 +57,7 @@ describe Participable do
other = other_model.new
user1 = build(:user)
user2 = build(:user)
project = build(:project, :public)
project = build(:empty_project, :public)
expect(instance).to receive(:foo).and_return(other)
expect(other).to receive(:bar).and_return(user2)
......@@ -69,7 +69,7 @@ describe Participable do
context 'when using a Proc as an attribute' do
it 'calls the supplied Proc' do
user1 = build(:user)
project = build(:project, :public)
project = build(:empty_project, :public)
user_arg = nil
ext_arg = nil
......
require 'spec_helper'
describe Note, ResolvableNote do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
subject { create(:discussion_note_on_merge_request, noteable: merge_request, project: project) }
......
......@@ -27,7 +27,7 @@ describe Group, 'Routable' do
it 'ensure route path uniqueness across different objects' do
create(:group, parent: group, path: 'xyz')
duplicate = build(:project, namespace: group, path: 'xyz')
duplicate = build(:empty_project, namespace: group, path: 'xyz')
expect { duplicate.save! }.to raise_error(ActiveRecord::RecordInvalid, 'Validation failed: Route path has already been taken, Route is invalid')
end
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe ContainerRepository do
let(:group) { create(:group, name: 'group') }
let(:project) { create(:project, path: 'test', group: group) }
let(:project) { create(:project, :repository, path: 'test', group: group) }
let(:repository) do
create(:container_repository, name: 'my_image', project: project)
......@@ -41,7 +41,7 @@ describe ContainerRepository do
end
context 'when path contains uppercase letters' do
let(:project) { create(:project, path: 'MY_PROJECT', group: group) }
let(:project) { create(:project, :repository, path: 'MY_PROJECT', group: group) }
it 'returns a full path without capital letters' do
expect(repository.path).to eq('group/my_project/my_image')
......
......@@ -91,7 +91,7 @@ describe Deployment do
end
describe '#additional_metrics' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:deployment) { create(:deployment, project: project) }
subject { deployment.additional_metrics }
......
......@@ -5,7 +5,7 @@ describe DiffDiscussion do
subject { described_class.new([diff_note]) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:diff_note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
......
......@@ -21,7 +21,7 @@ describe Environment do
it { is_expected.to validate_uniqueness_of(:external_url).scoped_to(:project_id) }
describe '.order_by_last_deployed_at' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let!(:environment1) { create(:environment, project: project) }
let!(:environment2) { create(:environment, project: project) }
let!(:environment3) { create(:environment, project: project) }
......
......@@ -41,7 +41,7 @@ describe ForkedProjectLink, "add link on fork" do
end
describe '#forked?' do
let(:project_to) { create(:project, forked_project_link: forked_project_link) }
let(:project_to) { create(:project, :repository, forked_project_link: forked_project_link) }
let(:forked_project_link) { create(:forked_project_link) }
before do
......
......@@ -16,7 +16,7 @@ RSpec.describe GpgSignature do
describe '#commit' do
it 'fetches the commit through the project' do
commit_sha = '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33'
project = create :project
project = create :project, :repository
commit = create :commit, project: project
gpg_signature = create :gpg_signature, commit_sha: commit_sha
......
......@@ -724,7 +724,7 @@ describe Issue do
end
describe '#check_for_spam' do
let(:project) { create :project, visibility_level: visibility_level }
let(:project) { create :empty_project, visibility_level: visibility_level }
let(:issue) { create :issue, project: project }
subject do
......
......@@ -9,7 +9,7 @@ describe ProjectGroupLink do
describe "Validation" do
let(:parent_group) { create(:group) }
let(:group) { create(:group, parent: parent_group) }
let(:project) { create(:project, group: group) }
let(:project) { create(:empty_project, group: group) }
let!(:project_group_link) { create(:project_group_link, project: project) }
it { is_expected.to validate_presence_of(:project_id) }
......
......@@ -20,7 +20,7 @@ describe ChatNotificationService do
context 'with repository' do
it 'returns true' do
subject.project = create(:project)
subject.project = create(:project, :repository)
expect(subject.can_test?).to be true
end
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe IssueTrackerService do
describe 'Validations' do
let(:project) { create :project }
let(:project) { create :empty_project }
describe 'only one issue tracker per project' do
let(:service) { RedmineService.new(project: project, active: true) }
......
......@@ -190,7 +190,7 @@ describe JiraService do
describe '#test_settings' do
let(:jira_service) do
described_class.new(
project: create(:project),
project: create(:empty_project),
url: 'http://jira.example.com',
username: 'jira_username',
password: 'jira_password'
......
......@@ -261,27 +261,27 @@ describe Project do
describe 'path validation' do
it 'allows paths reserved on the root namespace' do
project = build(:project, path: 'api')
project = build(:empty_project, path: 'api')
expect(project).to be_valid
end
it 'rejects paths reserved on another level' do
project = build(:project, path: 'tree')
project = build(:empty_project, path: 'tree')
expect(project).not_to be_valid
end
it 'rejects nested paths' do
parent = create(:group, :nested, path: 'environments')
project = build(:project, path: 'folders', namespace: parent)
project = build(:empty_project, path: 'folders', namespace: parent)
expect(project).not_to be_valid
end
it 'allows a reserved group name' do
parent = create(:group)
project = build(:project, path: 'avatar', namespace: parent)
project = build(:empty_project, path: 'avatar', namespace: parent)
expect(project).to be_valid
end
......@@ -2045,7 +2045,7 @@ describe Project do
end
describe '#route_map_for' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:route_map) do
<<-MAP.strip_heredoc
- source: /source/(.*)/
......@@ -2082,7 +2082,7 @@ describe Project do
end
describe '#public_path_for_source_path' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:route_map) do
Gitlab::RouteMap.new(<<-MAP.strip_heredoc)
- source: /source/(.*)/
......@@ -2196,7 +2196,7 @@ describe Project do
end
describe '#pipeline_status' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
it 'builds a pipeline status' do
expect(project.pipeline_status).to be_a(Gitlab::Cache::Ci::ProjectPipelineStatus)
end
......@@ -2207,7 +2207,7 @@ describe Project do
end
describe '#append_or_update_attribute' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
it 'shows full error updating an invalid MR' do
error_message = 'Failed to replace merge_requests because one or more of the new records could not be saved.'\
......
......@@ -330,7 +330,7 @@ describe ProjectTeam do
end
shared_examples 'max member access for users' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:group) { create(:group) }
let(:second_group) { create(:group) }
......
......@@ -300,7 +300,7 @@ describe Repository do
end
context "when committing to another project" do
let(:forked_project) { create(:project) }
let(:forked_project) { create(:project, :repository) }
it "creates a fork and commit to the forked project" do
expect do
......
......@@ -21,7 +21,7 @@ describe SentNotification do
end
context "when the noteable project and discussion project match" do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:issue) { create(:issue, project: project) }
let(:discussion_id) { create(:note, project: project, noteable: issue).discussion_id }
subject { build(:sent_notification, project: project, noteable: issue, in_reply_to_discussion_id: discussion_id) }
......@@ -128,7 +128,7 @@ describe SentNotification do
end
context 'for commit' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
subject { described_class.record(commit, project.creator.id) }
......
......@@ -97,7 +97,7 @@ describe Ci::BuildPolicy do
end
describe 'rules for protected ref' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:build) { create(:ci_build, ref: 'some-ref', pipeline: pipeline) }
before do
......
......@@ -10,7 +10,7 @@ describe Ci::PipelinePolicy, :models do
describe 'rules' do
describe 'rules for protected ref' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
before do
project.add_developer(user)
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe EnvironmentPolicy do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:environment) do
create(:environment, :with_review_app, project: project)
......@@ -14,7 +14,7 @@ describe EnvironmentPolicy do
describe '#rules' do
context 'when user does not have access to the project' do
let(:project) { create(:project, :private) }
let(:project) { create(:project, :private, :repository) }
it 'does not include ability to stop environment' do
expect(policy).to be_disallowed :stop_environment
......@@ -22,7 +22,7 @@ describe EnvironmentPolicy do
end
context 'when anonymous user has access to the project' do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
it 'does not include ability to stop environment' do
expect(policy).to be_disallowed :stop_environment
......@@ -30,7 +30,7 @@ describe EnvironmentPolicy do
end
context 'when team member has access to the project' do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
before do
project.add_developer(user)
......
......@@ -105,7 +105,7 @@ describe MergeRequestPresenter do
end
context 'issues links' do
let(:project) { create(:project, :private, creator: user, namespace: user.namespace) }
let(:project) { create(:project, :private, :repository, creator: user, namespace: user.namespace) }
let(:issue_a) { create(:issue, project: project) }
let(:issue_b) { create(:issue, project: project) }
......
......@@ -80,7 +80,7 @@ describe API::Files do
context 'when unauthenticated', 'and project is public' do
it_behaves_like 'repository files' do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
......@@ -153,7 +153,7 @@ describe API::Files do
context 'when unauthenticated', 'and project is public' do
it_behaves_like 'repository raw files' do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe API::PipelineSchedules do
set(:developer) { create(:user) }
set(:user) { create(:user) }
set(:project) { create(:project) }
set(:project) { create(:project, :repository) }
before do
project.add_developer(developer)
......
require 'spec_helper'
describe API::Todos do
let(:project_1) { create(:project) }
let(:project_1) { create(:project, :repository) }
let(:project_2) { create(:empty_project) }
let(:author_1) { create(:user) }
let(:author_2) { create(:user) }
......
......@@ -13,7 +13,7 @@ describe API::Triggers do
let!(:trigger_request) { create(:ci_trigger_request, trigger: trigger, created_at: '2015-01-01 12:13:14') }
describe 'POST /projects/:project_id/trigger/pipeline' do
let!(:project2) { create(:project) }
let!(:project2) { create(:project, :repository) }
let(:options) do
{
token: trigger_token
......
......@@ -74,7 +74,7 @@ describe API::V3::Files do
context 'when unauthenticated', 'and project is public' do
it_behaves_like 'repository files' do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe API::ProjectHooks, 'ProjectHooks' do
let(:user) { create(:user) }
let(:user3) { create(:user) }
let!(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let!(:project) { create(:empty_project, creator_id: user.id, namespace: user.namespace) }
let!(:hook) do
create(:project_hook,
:all_events_enabled,
......@@ -204,7 +204,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns a 404 if a user attempts to delete project hooks he/she does not own" do
test_user = create(:user)
other_project = create(:project)
other_project = create(:empty_project)
other_project.team << [test_user, :master]
delete v3_api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user)
......
......@@ -10,7 +10,7 @@ describe API::V3::Triggers do
let!(:trigger) { create(:ci_trigger, project: project, token: trigger_token) }
describe 'POST /projects/:project_id/trigger' do
let!(:project2) { create(:project) }
let!(:project2) { create(:empty_project) }
let(:options) do
{
token: trigger_token
......
......@@ -600,7 +600,7 @@ describe 'Git LFS API and storage' do
context 'when user is not authenticated' do
describe 'is accessing public project' do
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:update_lfs_permissions) do
project.lfs_objects << lfs_object
......@@ -642,7 +642,7 @@ describe 'Git LFS API and storage' do
end
describe 'upload' do
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:body) do
{
'operation' => 'upload',
......@@ -1019,7 +1019,7 @@ describe 'Git LFS API and storage' do
end
describe 'to a forked project' do
let(:upstream_project) { create(:project, :public) }
let(:upstream_project) { create(:empty_project, :public) }
let(:project_owner) { create(:user) }
let(:project) { fork_project(upstream_project, project_owner) }
......
......@@ -13,7 +13,7 @@ describe 'Request Profiler' do
end
it 'creates a profile of the request' do
project = create(:project, namespace: user.namespace)
project = create(:empty_project, namespace: user.namespace)
time = Time.now
path = "/#{project.full_path}"
......
......@@ -75,7 +75,7 @@ describe Ci::CreatePipelineService do
end
context 'when merge request target project is different from source project' do
let!(:target_project) { create(:project) }
let!(:target_project) { create(:project, :repository) }
let!(:forked_project_link) { create(:forked_project_link, forked_to_project: project, forked_from_project: target_project) }
it 'updates head pipeline for merge request' do
......
......@@ -33,7 +33,7 @@ describe Ci::PlayBuildService, '#execute' do
end
context 'when project has repository' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
it 'allows user with developer role to play a build' do
project.add_developer(user)
......
......@@ -2,9 +2,9 @@ require 'spec_helper'
describe Labels::CreateService do
describe '#execute' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:group) { create(:group) }
let(:hex_color) { '#FF0000' }
let(:named_color) { 'red' }
let(:upcase_color) { 'RED' }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Labels::UpdateService do
describe '#execute' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:hex_color) { '#FF0000' }
let(:named_color) { 'red' }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Milestones::DestroyService do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:milestone) { create(:milestone, title: 'Milestone v1.0', project: project) }
let(:issue) { create(:issue, project: project, milestone: milestone) }
let(:merge_request) { create(:merge_request, source_project: project, milestone: milestone) }
......
......@@ -40,7 +40,7 @@ describe Users::DestroyService do
end
context "a deleted user's issues" do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
before do
project.add_developer(user)
......@@ -66,7 +66,7 @@ describe Users::DestroyService do
end
context "a deleted user's merge_requests" do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
before do
project.add_developer(user)
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Users::MigrateToGhostUserService do
let!(:user) { create(:user) }
let!(:project) { create(:project) }
let!(:project) { create(:project, :repository) }
let(:service) { described_class.new(user) }
context "migrating a user's associated records to the ghost user" do
......
......@@ -5,7 +5,14 @@ shared_examples 'issuable record that supports quick actions in its description
include QuickActionsHelpers
let(:master) { create(:user) }
let(:project) { create(:project, :public) }
let(:project) do
case issuable_type
when :merge_request
create(:project, :public, :repository)
when :issue
create(:empty_project, :public)
end
end
let!(:milestone) { create(:milestone, project: project, title: 'ASAP') }
let!(:label_bug) { create(:label, project: project, title: 'bug') }
let!(:label_feature) { create(:label, project: project, title: 'feature') }
......
......@@ -6,7 +6,7 @@ module ExportFileHelper
ObjectWithParent = Struct.new(:object, :parent, :key_found)
def setup_project
project = create(:project, :public)
project = create(:project, :public, :repository)
create(:release, project: project)
......
......@@ -3,7 +3,14 @@ require "spec_helper"
shared_examples "migrating a deleted user's associated records to the ghost user" do |record_class, fields|
record_class_name = record_class.to_s.titleize.downcase
let(:project) { create(:project) }
let(:project) do
case record_class
when MergeRequest
create(:project, :repository)
else
create(:empty_project)
end
end
before do
project.add_developer(user)
......
......@@ -5,7 +5,7 @@ describe FileUploader do
describe '.absolute_path' do
it 'returns the correct absolute path by building it dynamically' do
project = build_stubbed(:project)
project = build_stubbed(:empty_project)
upload = double(model: project, path: 'secret/foo.jpg')
dynamic_segment = project.path_with_namespace
......
......@@ -28,7 +28,7 @@ describe DynamicPathValidator do
describe '#path_valid_for_record?' do
context 'for project' do
it 'calls valid_project_path?' do
project = build(:project, path: 'activity')
project = build(:empty_project, path: 'activity')
expect(described_class).to receive(:valid_project_path?).with(project.full_path).and_call_original
......
......@@ -5,7 +5,7 @@ describe 'layouts/nav/_project' do
before do
stub_container_registry_config(enabled: true)
assign(:project, create(:project))
assign(:project, create(:project, :repository))
allow(view).to receive(:current_ref).and_return('master')
allow(view).to receive(:can?).and_return(true)
......
......@@ -4,7 +4,7 @@ describe 'notify/pipeline_failed_email.html.haml' do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, :simple, source_project: project) }
let(:pipeline) do
......
......@@ -4,7 +4,7 @@ describe 'notify/pipeline_success_email.html.haml' do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, :simple, source_project: project) }
let(:pipeline) do
......
......@@ -4,7 +4,7 @@ describe CreateGpgSignatureWorker do
context 'when GpgKey is found' do
it 'calls Commit#signature' do
commit_sha = '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33'
project = create :project
project = create :empty_project
commit = instance_double(Commit)
allow(Project).to receive(:find_by).with(id: project.id).and_return(project)
......@@ -18,7 +18,7 @@ describe CreateGpgSignatureWorker do
context 'when Commit is not found' do
let(:nonexisting_commit_sha) { 'bogus' }
let(:project) { create :project }
let(:project) { create :empty_project }
it 'does not raise errors' do
expect { described_class.new.perform(nonexisting_commit_sha, project.id) }.not_to raise_error
......
......@@ -33,7 +33,7 @@ describe ProcessCommitWorker do
end
context 'when commit already exists in upstream project' do
let(:forked) { create(:project, :public) }
let(:forked) { create(:project, :public, :repository) }
it 'does not process commit message' do
create(:forked_project_link, forked_to_project: forked, forked_from_project: project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment