Commit f15e7642 authored by Rémy Coutable's avatar Rémy Coutable

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

Empty project factory by default

See merge request !13260
parents 43c01547 72a7b30c
......@@ -426,8 +426,6 @@ Here are some things to keep in mind regarding test performance:
- `FactoryGirl.build(...)` and `.build_stubbed` are faster than `.create`.
- Don't `create` an object when `build`, `build_stubbed`, `attributes_for`,
`spy`, or `double` will do. Database persistence is slow!
- Use `create(:empty_project)` instead of `create(:project)` when you don't need
the underlying Git repository. Filesystem operations are slow!
- Don't mark a feature as requiring JavaScript (through `@javascript` in
Spinach or `:js` in RSpec) unless it's _actually_ required for the test
to be valid. Headless browser testing is slow!
......
......@@ -100,7 +100,7 @@ class Spinach::Features::GroupMilestones < Spinach::FeatureSteps
group = owned_group
%w(gitlabhq gitlab-ci cookbook-gitlab).each do |path|
project = create(:empty_project, path: path, group: group)
project = create(:project, path: path, group: group)
milestone = create :milestone, title: "Version 7.2", project: project
create(:label, project: project, title: 'bug')
......
......@@ -15,7 +15,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
step 'Group "Owned" has a public project "Public-project"' do
group = owned_group
@project = create :empty_project, :public,
@project = create :project, :public,
group: group,
name: "Public-project"
end
......@@ -109,7 +109,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
step 'Group "Owned" has archived project' do
group = Group.find_by(name: 'Owned')
@archived_project = create(:empty_project, :archived, namespace: group, path: "archived-project")
@archived_project = create(:project, :archived, namespace: group, path: "archived-project")
end
step 'I should see "archived" label' do
......
......@@ -47,11 +47,11 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
end
step 'other projects have deploy keys' do
@second_project = create(:empty_project, namespace: create(:group))
@second_project = create(:project, namespace: create(:group))
@second_project.team << [current_user, :master]
create(:deploy_keys_project, project: @second_project)
@third_project = create(:empty_project, namespace: create(:group))
@third_project = create(:project, namespace: create(:group))
@third_project.team << [current_user, :master]
create(:deploy_keys_project, project: @third_project, deploy_key: @second_project.deploy_keys.first)
end
......
......@@ -4,11 +4,11 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
include SharedProject
step 'public project "Community"' do
create(:empty_project, :public, name: 'Community')
create(:project, :public, name: 'Community')
end
step 'private project "Enterprise"' do
create(:empty_project, :private, name: 'Enterprise')
create(:project, :private, name: 'Enterprise')
end
step 'I visit project "Community" page' do
......
......@@ -34,7 +34,7 @@ class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
end
step 'I own project "Website"' do
@project = create(:empty_project, name: "Website", namespace: @user.namespace)
@project = create(:project, name: "Website", namespace: @user.namespace)
@project.team << [@user, :master]
end
......@@ -68,7 +68,7 @@ class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
step 'I share project with group "OpenSource"' do
project = Project.find_by(name: 'Shop')
os_group = create(:group, name: 'OpenSource')
create(:empty_project, group: os_group)
create(:project, group: os_group)
@os_user1 = create(:user)
@os_user2 = create(:user)
os_group.add_owner(@os_user1)
......
......@@ -54,7 +54,7 @@ module SharedProject
# Create an empty project without caring about the name
step 'I own an empty project' do
@project = create(:empty_project,
@project = create(:project,
name: 'Empty Project', namespace: @user.namespace)
@project.team << [@user, :master]
end
......@@ -276,7 +276,7 @@ module SharedProject
def user_owns_project(user_name:, project_name:, visibility: :private)
user = user_exists(user_name, username: user_name.gsub(/\s/, '').underscore)
project = Project.find_by(name: project_name)
project ||= create(:empty_project, visibility, name: project_name, namespace: user.namespace)
project ||= create(:project, visibility, name: project_name, namespace: user.namespace)
project.team << [user, :master]
end
end
......@@ -38,6 +38,6 @@ class Spinach::Features::User < Spinach::FeatureSteps
end
def contributed_project
@contributed_project ||= create(:empty_project, :public)
@contributed_project ||= create(:project, :public)
end
end
......@@ -4,7 +4,7 @@ describe Admin::ApplicationSettingsController do
include StubENV
let(:group) { create(:group) }
let(:project) { create(:empty_project, namespace: group) }
let(:project) { create(: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(:empty_project)
pending_delete_project = create(:empty_project, pending_delete: true)
project = create(:project)
pending_delete_project = create(:project, pending_delete: true)
get :index
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Admin::GroupsController do
let(:group) { create(:group) }
let(:project) { create(:empty_project, namespace: group) }
let(:project) { create(:project, namespace: group) }
let(:admin) { create(:admin) }
before do
......
require 'spec_helper'
describe Admin::ProjectsController do
let!(:project) { create(:empty_project, :public) }
let!(:project) { create(:project, :public) }
before do
sign_in(create(:admin))
......
......@@ -8,7 +8,7 @@ describe Admin::ServicesController do
end
describe 'GET #edit' do
let!(:project) { create(:empty_project) }
let!(:project) { create(:project) }
Service.available_services_names.each do |service_name|
context "#{service_name}" do
......@@ -27,7 +27,7 @@ describe Admin::ServicesController do
end
describe "#update" do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let!(:service) do
RedmineService.create(
project: project,
......
......@@ -9,7 +9,7 @@ describe Admin::UsersController do
end
describe 'DELETE #user with projects' do
let(:project) { create(:empty_project, namespace: user.namespace) }
let(:project) { create(:project, namespace: user.namespace) }
let!(:issue) { create(:issue, author: user) }
before do
......
require 'spec_helper'
describe AutocompleteController do
let!(:project) { create(:empty_project) }
let!(:project) { create(:project) }
let!(:user) { create(:user) }
context 'GET users' do
......@@ -65,7 +65,7 @@ describe AutocompleteController do
end
context 'non-member login for public project' do
let!(:project) { create(:empty_project, :public) }
let!(:project) { create(:project, :public) }
before do
sign_in(non_member)
......@@ -127,7 +127,7 @@ describe AutocompleteController do
end
context 'unauthenticated user' do
let(:public_project) { create(:empty_project, :public) }
let(:public_project) { create(: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(:empty_project) }
let(:authorized_search_project) { create(:empty_project, name: 'rugged') }
let(:authorized_project) { create(:project) }
let(:authorized_search_project) { create(: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(:empty_project)
authorized_project3 = create(:empty_project)
authorized_project2 = create(:project)
authorized_project3 = create(: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(:empty_project)
authorized_project3 = create(:empty_project)
authorized_project2 = create(:project)
authorized_project3 = create(:project)
authorized_project.add_master(user)
authorized_project2.add_master(user)
......
require 'spec_helper'
describe Dashboard::LabelsController do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:user) { create(:user) }
let!(:label) { create(:label, project: project) }
......@@ -11,7 +11,7 @@ describe Dashboard::LabelsController do
end
describe "#index" do
let!(:unrelated_label) { create(:label, project: create(:empty_project, :public)) }
let!(:unrelated_label) { create(:label, project: create(:project, :public)) }
it 'returns global labels for projects the user has a relationship with' do
get :index, format: :json
......
require 'spec_helper'
describe Dashboard::MilestonesController do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:project_milestone) { create(:milestone, project: project) }
let(:milestone) do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Dashboard::TodosController do
let(:user) { create(:user) }
let(:author) { create(:user) }
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:todo_service) { TodoService.new }
before do
......@@ -14,7 +14,7 @@ describe Dashboard::TodosController do
describe 'GET #index' do
context 'project authorization' do
it 'renders 404 when user does not have read access on given project' do
unauthorized_project = create(:empty_project, :private)
unauthorized_project = create(:project, :private)
get :index, project_id: unauthorized_project.id
......@@ -34,7 +34,7 @@ describe Dashboard::TodosController do
end
it 'renders 200 when user has access on given project' do
authorized_project = create(:empty_project, :public)
authorized_project = create(:project, :public)
get :index, project_id: authorized_project.id
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe DashboardController do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
before do
project.team << [user, :master]
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe Explore::ProjectsController do
describe 'GET #trending' do
context 'sorting by update date' do
let(:project1) { create(:empty_project, :public, updated_at: 3.days.ago) }
let(:project2) { create(:empty_project, :public, updated_at: 1.day.ago) }
let(:project1) { create(:project, :public, updated_at: 3.days.ago) }
let(:project2) { create(:project, :public, updated_at: 1.day.ago) }
before do
create(:trending_project, project: project1)
......
......@@ -2,8 +2,8 @@ require 'spec_helper'
describe Groups::MilestonesController do
let(:group) { create(:group) }
let!(:project) { create(:empty_project, group: group) }
let!(:project2) { create(:empty_project, group: group) }
let!(:project) { create(:project, group: group) }
let!(:project2) { create(:project, group: group) }
let(:user) { create(:user) }
let(:title) { '肯定不是中文的问题' }
let(:milestone) do
......
......@@ -3,7 +3,7 @@ require 'rails_helper'
describe GroupsController do
let(:user) { create(:user) }
let(:group) { create(:group, :public) }
let(:project) { create(:empty_project, namespace: group) }
let(:project) { create(:project, namespace: group) }
let!(:group_member) { create(:group_member, group: group, user: user) }
describe 'GET #index' do
......
......@@ -52,7 +52,7 @@ describe Import::BitbucketController do
end
it "assigns variables" do
@project = create(:empty_project, import_type: 'bitbucket', creator_id: user.id)
@project = create(:project, import_type: 'bitbucket', creator_id: user.id)
allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo])
get :status
......@@ -63,7 +63,7 @@ describe Import::BitbucketController do
end
it "does not show already added project" do
@project = create(:empty_project, import_type: 'bitbucket', creator_id: user.id, import_source: 'asd/vim')
@project = create(:project, import_type: 'bitbucket', creator_id: user.id, import_source: 'asd/vim')
allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo])
get :status
......
......@@ -16,7 +16,7 @@ describe Import::FogbugzController do
end
it 'assigns variables' do
@project = create(:empty_project, import_type: 'fogbugz', creator_id: user.id)
@project = create(:project, import_type: 'fogbugz', creator_id: user.id)
stub_client(repos: [@repo])
get :status
......@@ -26,7 +26,7 @@ describe Import::FogbugzController do
end
it 'does not show already added project' do
@project = create(:empty_project, import_type: 'fogbugz', creator_id: user.id, import_source: 'vim')
@project = create(:project, import_type: 'fogbugz', creator_id: user.id, import_source: 'vim')
stub_client(repos: [@repo])
get :status
......
......@@ -36,7 +36,7 @@ describe Import::GitlabController do
end
it "assigns variables" do
@project = create(:empty_project, import_type: 'gitlab', creator_id: user.id)
@project = create(:project, import_type: 'gitlab', creator_id: user.id)
stub_client(projects: [@repo])
get :status
......@@ -46,7 +46,7 @@ describe Import::GitlabController do
end
it "does not show already added project" do
@project = create(:empty_project, import_type: 'gitlab', creator_id: user.id, import_source: 'asd/vim')
@project = create(:project, import_type: 'gitlab', creator_id: user.id, import_source: 'asd/vim')
stub_client(projects: [@repo])
get :status
......
......@@ -27,7 +27,7 @@ describe Import::GoogleCodeController do
end
it "assigns variables" do
@project = create(:empty_project, import_type: 'google_code', creator_id: user.id)
@project = create(:project, import_type: 'google_code', creator_id: user.id)
stub_client(repos: [@repo], incompatible_repos: [])
get :status
......@@ -38,7 +38,7 @@ describe Import::GoogleCodeController do
end
it "does not show already added project" do
@project = create(:empty_project, import_type: 'google_code', creator_id: user.id, import_source: 'vim')
@project = create(:project, import_type: 'google_code', creator_id: user.id, import_source: 'vim')
stub_client(repos: [@repo], incompatible_repos: [])
get :status
......
require 'spec_helper'
describe NotificationSettingsController do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:group) { create(:group, :internal) }
let(:user) { create(:user) }
......@@ -99,7 +99,7 @@ describe NotificationSettingsController do
end
context 'not authorized' do
let(:private_project) { create(:empty_project, :private) }
let(:private_project) { create(:project, :private) }
before do
sign_in(user)
......
require 'spec_helper'
describe Projects::AvatarsController do
let(:project) { create(:empty_project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) }
let(:project) { create(:project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) }
let(:user) { create(:user) }
before do
......
......@@ -193,7 +193,7 @@ describe Projects::BlobController do
context "when user doesn't have access" do
before do
other_project = create(:empty_project)
other_project = create(:project, :repository)
merge_request.update!(source_project: other_project, target_project: other_project)
end
......
require 'spec_helper'
describe Projects::Boards::IssuesController do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:board) { create(:board, project: project) }
let(:user) { create(:user) }
let(:guest) { create(:user) }
......
require 'spec_helper'
describe Projects::Boards::ListsController do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:board) { create(:board, project: project) }
let(:user) { create(:user) }
let(:guest) { create(:user) }
......
require 'spec_helper'
describe Projects::BoardsController do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:user) { create(:user) }
before do
......
......@@ -96,7 +96,7 @@ describe Projects::BranchesController do
end
context 'repository-less project' do
let(:project) { create :empty_project }
let(:project) { create :project }
it 'redirects to newly created branch' do
result = { status: :success, branch: double(name: branch) }
......
......@@ -24,8 +24,8 @@ describe Projects::DeployKeysController do
end
context 'when json requested' do
let(:project2) { create(:empty_project, :internal)}
let(:project_private) { create(:empty_project, :private)}
let(:project2) { create(:project, :internal)}
let(:project_private) { create(:project, :private)}
let(:deploy_key_internal) do
create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCdMHEHyhRjbhEZVddFn6lTWdgEy5Q6Bz4nwGB76xWZI5YT/1WJOMEW+sL5zYd31kk7sd3FJ5L9ft8zWMWrr/iWXQikC2cqZK24H1xy+ZUmrRuJD4qGAaIVoyyzBL+avL+lF8J5lg6YSw8gwJY/lX64/vnJHUlWw2n5BF8IFOWhiw== dummy@gitlab.com')
......
......@@ -4,7 +4,7 @@ describe Projects::DeploymentsController do
include ApiHelpers
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:environment) { create(:environment, name: 'production', project: project) }
before do
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::EnvironmentsController do
set(:user) { create(:user) }
set(:project) { create(:empty_project) }
set(:project) { create(:project) }
set(:environment) do
create(:environment, name: 'production', project: project)
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::GroupLinksController do
let(:group) { create(:group, :private) }
let(:group2) { create(:group, :private) }
let(:project) { create(:empty_project, :private, group: group2) }
let(:project) { create(:project, :private, group: group2) }
let(:user) { create(:user) }
before do
......
require 'spec_helper'
describe Projects::HooksController do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:user) { create(:user) }
before do
......
......@@ -5,7 +5,7 @@ describe Projects::ImportsController do
describe 'GET #show' do
context 'when repository does not exists' do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
before do
sign_in(user)
......
......@@ -234,7 +234,7 @@ describe Projects::IssuesController do
end
context 'when moving issue to another private project' do
let(:another_project) { create(:empty_project, :private) }
let(:another_project) { create(:project, :private) }
context 'when user has access to move issue' do
before do
......@@ -594,7 +594,7 @@ describe Projects::IssuesController do
describe 'POST #create' do
def post_new_issue(issue_attrs = {}, additional_params = {})
sign_in(user)
project = create(:empty_project, :public)
project = create(:project, :public)
project.team << [user, :developer]
post :create, {
......@@ -817,7 +817,7 @@ describe Projects::IssuesController do
context "when the user is owner" do
let(:owner) { create(:user) }
let(:namespace) { create(:namespace, owner: owner) }
let(:project) { create(:empty_project, namespace: namespace) }
let(:project) { create(:project, namespace: namespace) }
before do
sign_in(owner)
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::JobsController do
include ApiHelpers
let(:project) { create(:empty_project, :public) }
let(:project) { create(:project, :public) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:user) { create(:user) }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::LabelsController do
let(:group) { create(:group) }
let(:project) { create(:empty_project, namespace: group) }
let(:project) { create(:project, namespace: group) }
let(:user) { create(:user) }
before do
......@@ -73,7 +73,7 @@ describe Projects::LabelsController do
describe 'POST #generate' do
context 'personal project' do
let(:personal_project) { create(:empty_project, namespace: user.namespace) }
let(:personal_project) { create(:project, namespace: user.namespace) }
it 'creates labels' do
post :generate, namespace_id: personal_project.namespace.to_param, project_id: personal_project
......
require 'spec_helper'
describe Projects::MattermostsController do
let!(:project) { create(:empty_project) }
let!(:project) { create(:project) }
let!(:user) { create(:user) }
before do
......
......@@ -145,7 +145,7 @@ describe Projects::MergeRequests::DiffsController do
end
context 'when the merge request belongs to a different project' do
let(:other_project) { create(:empty_project) }
let(:other_project) { create(:project) }
before do
other_project.team << [user, :master]
......
require 'spec_helper'
describe Projects::MilestonesController do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
let(:issue) { create(:issue, project: project, milestone: milestone) }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::NotesController do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
let(:note) { create(:note, noteable: issue, project: project) }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::PagesController do
let(:user) { create(:user) }
let(:project) { create(:empty_project, :public, :access_requestable) }
let(:project) { create(:project, :public, :access_requestable) }
let(:request_params) do
{
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::PagesDomainsController do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let!(:pages_domain) { create(:pages_domain, project: project) }
let(:request_params) do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::PipelineSchedulesController do
include AccessMatchersForController
set(:project) { create(:empty_project, :public) }
set(:project) { create(:project, :public) }
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project) }
describe 'GET #index' do
......
......@@ -4,7 +4,7 @@ describe Projects::PipelinesController do
include ApiHelpers
let(:user) { create(:user) }
let(:project) { create(:empty_project, :public) }
let(:project) { create(:project, :public) }
let(:feature) { ProjectFeature::DISABLED }
before do
......
......@@ -2,7 +2,7 @@ require('spec_helper')
describe Projects::ProjectMembersController do
let(:user) { create(:user) }
let(:project) { create(:empty_project, :public, :access_requestable) }
let(:project) { create(:project, :public, :access_requestable) }
describe 'GET index' do
it 'should have the project_members address with a 200 status code' do
......@@ -158,7 +158,7 @@ describe Projects::ProjectMembersController do
end
context 'and is an owner' do
let(:project) { create(:empty_project, namespace: user.namespace) }
let(:project) { create(:project, namespace: user.namespace) }
before do
project.team << [user, :master]
......@@ -261,7 +261,7 @@ describe Projects::ProjectMembersController do
end
describe 'POST apply_import' do
let(:another_project) { create(:empty_project, :private) }
let(:another_project) { create(:project, :private) }
let(:member) { create(:user) }
before do
......
......@@ -2,7 +2,7 @@ require('spec_helper')
describe Projects::PrometheusController do
let(:user) { create(:user) }
let!(:project) { create(:empty_project) }
let!(:project) { create(:project) }
let(:prometheus_service) { double('prometheus_service') }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::Registry::RepositoriesController do
let(:user) { create(:user) }
let(:project) { create(:empty_project, :private) }
let(:project) { create(:project, :private) }
before do
sign_in(user)
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::Registry::TagsController do
let(:user) { create(:user) }
let(:project) { create(:empty_project, :private) }
let(:project) { create(:project, :private) }
before do
sign_in(user)
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::RunnersController do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:runner) { create(:ci_runner) }
let(:params) do
......
......@@ -28,7 +28,7 @@ describe Projects::ServicesController do
context 'success' do
context 'with empty project' do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
context 'with chat notification service' do
let(:service) { project.create_microsoft_teams_service(webhook: 'http://webhook.com') }
......
require('spec_helper')
describe Projects::Settings::CiCdController do
let(:project) { create(:empty_project, :public, :access_requestable) }
let(:project) { create(:project, :public, :access_requestable) }
let(:user) { create(:user) }
before do
......
require 'spec_helper'
describe Projects::Settings::IntegrationsController do
let(:project) { create(:empty_project, :public) }
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
before do
......
......@@ -156,7 +156,7 @@ describe Projects::SnippetsController do
end
describe 'PUT #update' do
let(:project) { create :empty_project, :public }
let(:project) { create :project, :public }
let(:snippet) { create :project_snippet, author: user, project: project, visibility_level: visibility_level }
def update_snippet(snippet_params = {}, additional_params = {})
......
......@@ -2,7 +2,7 @@ require('spec_helper')
describe Projects::TodosController do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project) }
......
require('spec_helper')
describe Projects::UploadsController do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') }
let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') }
......
require 'spec_helper'
describe Projects::VariablesController do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:user) { create(:user) }
before do
......
require('spec_helper')
describe ProjectsController do
let(:project) { create(:empty_project) }
let(:public_project) { create(:empty_project, :public) }
let(:project) { create(:project) }
let(:public_project) { create(:project, :public) }
let(:user) { create(:user) }
let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') }
let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') }
......@@ -34,7 +34,7 @@ describe ProjectsController do
end
context "user does not have access to project" do
let(:private_project) { create(:empty_project, :private) }
let(:private_project) { create(:project, :private) }
it "does not initialize notification setting" do
get :show, namespace_id: private_project.namespace, id: private_project
......@@ -176,7 +176,7 @@ describe ProjectsController do
end
context "when the url contains .atom" do
let(:public_project_with_dot_atom) { build(:empty_project, :public, name: 'my.atom', path: 'my.atom') }
let(:public_project_with_dot_atom) { build(:project, :public, name: 'my.atom', path: 'my.atom') }
it 'expects an error creating the project' do
expect(public_project_with_dot_atom).not_to be_valid
......@@ -185,7 +185,7 @@ describe ProjectsController do
context 'when the project is pending deletions' do
it 'renders a 404 error' do
project = create(:empty_project, pending_delete: true)
project = create(:project, pending_delete: true)
sign_in(user)
get :show, namespace_id: project.namespace, id: project
......@@ -196,7 +196,7 @@ describe ProjectsController do
context "redirection from http://someproject.git" do
it 'redirects to project page (format.html)' do
project = create(:empty_project, :public)
project = create(:project, :public)
get :show, namespace_id: project.namespace, id: project, format: :git
......@@ -408,7 +408,7 @@ describe ProjectsController do
end
context 'when project not forked' do
let(:unforked_project) { create(:empty_project, namespace: user.namespace) }
let(:unforked_project) { create(:project, namespace: user.namespace) }
it 'does nothing if project was not forked' do
delete(:remove_fork,
......
......@@ -8,7 +8,7 @@ describe SearchController do
end
it 'finds issue comments' do
project = create(:empty_project, :public)
project = create(:project, :public)
note = create(:note_on_issue, project: project)
get :show, project_id: project.id, scope: 'notes', search: note.note
......@@ -23,7 +23,7 @@ describe SearchController do
end
it "doesn't expose comments on issues" do
project = create(:empty_project, :public, :issues_private)
project = create(:project, :public, :issues_private)
note = create(:note_on_issue, project: project)
get :show, project_id: project.id, scope: 'notes', search: note.note
......@@ -33,7 +33,7 @@ describe SearchController do
end
it "doesn't expose comments on merge_requests" do
project = create(:empty_project, :public, :merge_requests_private)
project = create(:project, :public, :merge_requests_private)
note = create(:note_on_merge_request, project: project)
get :show, project_id: project.id, scope: 'notes', search: note.note
......@@ -42,7 +42,7 @@ describe SearchController do
end
it "doesn't expose comments on snippets" do
project = create(:empty_project, :public, :snippets_private)
project = create(:project, :public, :snippets_private)
note = create(:note_on_project_snippet, project: project)
get :show, project_id: project.id, scope: 'notes', search: note.note
......
......@@ -2,7 +2,7 @@ require 'rails_helper'
describe SentNotificationsController do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:sent_notification) { create(:sent_notification, project: project, noteable: issue, recipient: user) }
let(:issue) do
......
......@@ -273,7 +273,7 @@ describe SnippetsController do
end
describe 'PUT #update' do
let(:project) { create :empty_project }
let(:project) { create :project }
let(:snippet) { create :personal_snippet, author: user, project: project, visibility_level: visibility_level }
def update_snippet(snippet_params = {}, additional_params = {})
......
......@@ -131,7 +131,7 @@ describe UploadsController do
describe "GET show" do
context 'Content-Disposition security measures' do
let(:project) { create(:empty_project, :public) }
let(:project) { create(:project, :public) }
context 'for PNG files' do
it 'returns Content-Disposition: inline' do
......@@ -203,7 +203,7 @@ describe UploadsController do
end
context "when viewing a project avatar" do
let!(:project) { create(:empty_project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) }
let!(:project) { create(:project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) }
context "when the project is public" do
before do
......
......@@ -86,7 +86,7 @@ describe UsersController do
end
context 'forked project' do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:forked_project) { Projects::ForkService.new(project, user).execute }
before do
......@@ -104,7 +104,7 @@ describe UsersController do
end
describe 'GET #calendar_activities' do
let!(:project) { create(:empty_project) }
let!(:project) { create(:project) }
let(:user) { create(:user) }
before do
......
FactoryGirl.define do
factory :board do
project factory: :empty_project
project
after(:create) do |board|
board.lists.create(list_type: :closed)
......
......@@ -5,7 +5,7 @@ FactoryGirl.define do
ref 'master'
active true
description "pipeline schedule"
project factory: :empty_project
project
trait :nightly do
cron '0 1 * * *'
......
......@@ -5,7 +5,7 @@ FactoryGirl.define do
sha '97de212e80737a608d939f648d959671fb0a0142'
status 'pending'
project factory: :empty_project
project
factory :ci_pipeline_without_jobs do
after(:build) do |pipeline|
......
FactoryGirl.define do
factory :ci_runner_project, class: Ci::RunnerProject do
runner factory: :ci_runner
project factory: :empty_project
project
end
end
......@@ -7,6 +7,6 @@ FactoryGirl.define do
protected true
end
project factory: :empty_project
project
end
end
......@@ -3,7 +3,7 @@ require_relative '../support/repo_helpers'
FactoryGirl.define do
factory :commit do
git_commit RepoHelpers.sample_commit
project factory: :empty_project
project
initialize_with do
new(git_commit, project)
......
FactoryGirl.define do
factory :deploy_keys_project do
deploy_key
project factory: :empty_project
project
end
end
......@@ -2,12 +2,10 @@ FactoryGirl.define do
factory :environment, class: Environment do
sequence(:name) { |n| "environment#{n}" }
project factory: :empty_project
association :project, :repository
sequence(:external_url) { |n| "https://env#{n}.example.gitlab.com" }
trait :with_review_app do |environment|
project
transient do
ref 'master'
end
......
FactoryGirl.define do
factory :event do
project factory: :empty_project
project
author factory: :user
trait(:created) { action Event::CREATED }
......
......@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :file_uploader do
skip_create
project factory: :empty_project
project
secret nil
transient do
......
FactoryGirl.define do
factory :forked_project_link do
association :forked_to_project, factory: :project
association :forked_from_project, factory: :project
association :forked_to_project, factory: [:project, :repository]
association :forked_from_project, factory: [:project, :repository]
after(:create) do |link|
link.forked_from_project.reload
......@@ -9,7 +9,7 @@ FactoryGirl.define do
end
trait :forked_to_empty_project do
association :forked_to_project, factory: :empty_project
association :forked_to_project, factory: [:project, :repository]
end
end
end
......@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :issue do
title { generate(:title) }
author
project factory: :empty_project
project
trait :confidential do
confidential true
......
FactoryGirl.define do
factory :label_priority do
project factory: :empty_project
project
label
sequence(:priority)
end
......
......@@ -5,7 +5,7 @@ FactoryGirl.define do
end
factory :label, traits: [:base_label], class: ProjectLabel do
project factory: :empty_project
project
transient do
priority nil
......
......@@ -27,7 +27,7 @@ FactoryGirl.define do
elsif evaluator.project_id
milestone.project_id = evaluator.project_id
else
milestone.project = create(:empty_project)
milestone.project = create(:project)
end
end
......
......@@ -4,7 +4,7 @@ include ActionDispatch::TestProcess
FactoryGirl.define do
factory :note do
project factory: :empty_project
project
note { generate(:title) }
author
on_issue
......
FactoryGirl.define do
factory :notification_setting do
source factory: :empty_project
source factory: :project
user
level 3
end
......
FactoryGirl.define do
factory :project_group_link do
project factory: :empty_project
project
group
end
end
......@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :project_hook do
url { generate(:url) }
enable_ssl_verification false
project factory: :empty_project
project
trait :token do
token { SecureRandom.hex(10) }
......
FactoryGirl.define do
factory :project_member do
user
project factory: :empty_project
project
master
trait(:guest) { access_level ProjectMember::GUEST }
......
......@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :project_wiki do
skip_create
project factory: :empty_project
project
user factory: :user
initialize_with { new(project, user) }
end
......
......@@ -5,7 +5,7 @@ FactoryGirl.define do
#
# Project does not have bare repository.
# Use this factory if you don't need repository in tests
factory :empty_project, class: 'Project' do
factory :project, class: 'Project' do
sequence(:name) { |n| "project#{n}" }
path { name.downcase.gsub(/\s/, '_') }
namespace
......@@ -54,8 +54,42 @@ FactoryGirl.define do
avatar { File.open(Rails.root.join('spec/fixtures/dk.png')) }
end
# Test repository - https://gitlab.com/gitlab-org/gitlab-test
trait :repository do
# no-op... for now!
path { 'gitlabhq' }
test_repo
transient do
create_template nil
end
after :create do |project, evaluator|
if evaluator.create_template
args = evaluator.create_template
project.add_user(args[:user], args[:access])
project.repository.create_file(
args[:user],
".gitlab/#{args[:path]}/bug.md",
'something valid',
message: 'test 3',
branch_name: 'master')
project.repository.create_file(
args[:user],
".gitlab/#{args[:path]}/template_test.md",
'template_test',
message: 'test 1',
branch_name: 'master')
project.repository.create_file(
args[:user],
".gitlab/#{args[:path]}/feature_proposal.md",
'feature_proposal',
message: 'test 2',
branch_name: 'master')
end
end
end
trait :empty_repo do
......@@ -146,59 +180,18 @@ FactoryGirl.define do
#
# This is a case when you just created a project
# but not pushed any code there yet
factory :project_empty_repo, parent: :empty_project do
factory :project_empty_repo, parent: :project do
empty_repo
end
# Project with broken repository
#
# Project with an invalid repository state
factory :project_broken_repo, parent: :empty_project do
factory :project_broken_repo, parent: :project do
broken_repo
end
# Project with test repository
#
# Test repository source can be found at
# https://gitlab.com/gitlab-org/gitlab-test
factory :project, parent: :empty_project do
path { 'gitlabhq' }
test_repo
transient do
create_template nil
end
after :create do |project, evaluator|
if evaluator.create_template
args = evaluator.create_template
project.add_user(args[:user], args[:access])
project.repository.create_file(
args[:user],
".gitlab/#{args[:path]}/bug.md",
'something valid',
message: 'test 3',
branch_name: 'master')
project.repository.create_file(
args[:user],
".gitlab/#{args[:path]}/template_test.md",
'template_test',
message: 'test 1',
branch_name: 'master')
project.repository.create_file(
args[:user],
".gitlab/#{args[:path]}/feature_proposal.md",
'feature_proposal',
message: 'test 2',
branch_name: 'master')
end
end
end
factory :forked_project_with_submodules, parent: :empty_project do
factory :forked_project_with_submodules, parent: :project do
path { 'forked-gitlabhq' }
after :create do |project|
......@@ -228,11 +221,11 @@ FactoryGirl.define do
jira_service
end
factory :kubernetes_project, parent: :empty_project do
factory :kubernetes_project, parent: :project do
kubernetes_service
end
factory :prometheus_project, parent: :empty_project do
factory :prometheus_project, parent: :project do
after :create do |project|
project.create_prometheus_service(
active: true,
......
......@@ -2,6 +2,6 @@ FactoryGirl.define do
factory :release do
tag "v1.1.0"
description "Awesome release"
project factory: :empty_project
project
end
end
FactoryGirl.define do
factory :sent_notification do
project factory: :empty_project
project
recipient factory: :user
noteable { create(:issue, project: project) }
reply_key { SentNotification.reply_key }
......
FactoryGirl.define do
factory :service do
project factory: :empty_project
project
type 'Service'
end
factory :custom_issue_tracker_service, class: CustomIssueTrackerService do
project factory: :empty_project
project
type 'CustomIssueTrackerService'
category 'issue_tracker'
active true
......@@ -17,7 +17,7 @@ FactoryGirl.define do
end
factory :kubernetes_service do
project factory: :empty_project
project
active true
properties({
api_url: 'https://kubernetes.example.com',
......@@ -26,7 +26,7 @@ FactoryGirl.define do
end
factory :prometheus_service do
project factory: :empty_project
project
active true
properties({
api_url: 'https://prometheus.example.com/'
......@@ -34,7 +34,7 @@ FactoryGirl.define do
end
factory :jira_service do
project factory: :empty_project
project
active true
properties(
url: 'https://jira.example.com',
......@@ -43,7 +43,7 @@ FactoryGirl.define do
end
factory :hipchat_service do
project factory: :empty_project
project
type 'HipchatService'
token 'test_token'
end
......
......@@ -20,7 +20,7 @@ FactoryGirl.define do
end
factory :project_snippet, parent: :snippet, class: :ProjectSnippet do
project factory: :empty_project
project
end
factory :personal_snippet, parent: :snippet, class: :PersonalSnippet do
......
FactoryGirl.define do
factory :subscription do
user
project factory: :empty_project
project
subscribable factory: :issue
end
end
FactoryGirl.define do
factory :todo do
project factory: :empty_project
project
author
user
target factory: :issue
......@@ -45,7 +45,7 @@ FactoryGirl.define do
end
factory :on_commit_todo, class: Todo do
project factory: :empty_project
project
author
user
action { Todo::ASSIGNED }
......
FactoryGirl.define do
factory :upload do
model { build(:empty_project) }
model { build(:project) }
path { "uploads/-/system/project/avatar/avatar.jpg" }
size 100.kilobytes
uploader "AvatarUploader"
......
......@@ -3,7 +3,7 @@ require 'rails_helper'
feature 'Admin disables Git access protocol' do
include StubENV
let(:project) { create(:empty_project, :empty_repo) }
let(:project) { create(:project, :empty_repo) }
let(:admin) { create(:admin) }
background do
......
......@@ -165,7 +165,7 @@ feature 'Admin Groups' do
describe 'shared projects' do
it 'renders shared project' do
empty_project = create(:empty_project)
empty_project = create(:project)
empty_project.project_group_links.create!(
group_access: Gitlab::Access::MASTER,
group: group
......
require 'spec_helper'
feature 'Admin::HookLogs' do
let(:project) { create(:empty_project) }
let(:project) { create(:project) }
let(:system_hook) { create(:system_hook) }
let(:hook_log) { create(:web_hook_log, web_hook: system_hook, internal_error_message: 'some error') }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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