Commit 694f84e1 authored by Robert Speicher's avatar Robert Speicher

EE-specific changes for `:empty_project` and `:repository`

parent a15efe37
...@@ -5,7 +5,7 @@ describe Groups::AnalyticsController do ...@@ -5,7 +5,7 @@ describe Groups::AnalyticsController do
let(:user2) { create(:user) } let(:user2) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:project) { create(:project, group: group) } let(:project) { create(:project, :repository, group: group) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, :simple, source_project: project) } let(:merge_request) { create(:merge_request, :simple, source_project: project) }
let(:push_data) { Gitlab::DataBuilder::Push.build_sample(project, user) } let(:push_data) { Gitlab::DataBuilder::Push.build_sample(project, user) }
......
...@@ -78,7 +78,7 @@ describe Projects::IssuesController do ...@@ -78,7 +78,7 @@ describe Projects::IssuesController do
end end
describe 'issue weights' do describe 'issue weights' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:issue) { create(:issue, project: project, weight: 5) } let(:issue) { create(:issue, project: project, weight: 5) }
let(:issue2) { create(:issue, project: project, weight: 1) } let(:issue2) { create(:issue, project: project, weight: 1) }
......
require 'spec_helper' require 'spec_helper'
describe Projects::MergeRequests::CreationsController do describe Projects::MergeRequests::CreationsController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) } let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
let(:user) { project.owner } let(:user) { project.owner }
let(:viewer) { user } let(:viewer) { user }
......
require 'spec_helper' require 'spec_helper'
describe Projects::MergeRequestsController do describe Projects::MergeRequestsController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) } let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
let(:user) { project.owner } let(:user) { project.owner }
let(:viewer) { user } let(:viewer) { user }
...@@ -326,7 +326,7 @@ describe Projects::MergeRequestsController do ...@@ -326,7 +326,7 @@ describe Projects::MergeRequestsController do
end end
context 'approvals pending' do context 'approvals pending' do
let(:project) { create(:project, approvals_before_merge: 1) } let(:project) { create(:project, :repository, approvals_before_merge: 1) }
it 'returns 200' do it 'returns 200' do
expect_rebase_worker_for(viewer) expect_rebase_worker_for(viewer)
...@@ -338,7 +338,7 @@ describe Projects::MergeRequestsController do ...@@ -338,7 +338,7 @@ describe Projects::MergeRequestsController do
end end
context 'with a forked project' do context 'with a forked project' do
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:project, :repository, forked_from_project: project) }
let(:fork_owner) { fork_project.owner } let(:fork_owner) { fork_project.owner }
before do before do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::MirrorsController do describe Projects::MirrorsController do
describe 'setting up a remote mirror' do describe 'setting up a remote mirror' do
context 'when the current project is a mirror' do context 'when the current project is a mirror' do
let(:project) { create(:project, :mirror) } let(:project) { create(:project, :repository, :mirror) }
before do before do
sign_in(project.owner) sign_in(project.owner)
...@@ -36,7 +36,7 @@ describe Projects::MirrorsController do ...@@ -36,7 +36,7 @@ describe Projects::MirrorsController do
context 'when the current project is not a mirror' do context 'when the current project is not a mirror' do
it 'allows to create a remote mirror' do it 'allows to create a remote mirror' do
project = create(:project) project = create(:project, :repository)
sign_in(project.owner) sign_in(project.owner)
expect do expect do
...@@ -46,7 +46,7 @@ describe Projects::MirrorsController do ...@@ -46,7 +46,7 @@ describe Projects::MirrorsController do
end end
context 'when the current project has a remote mirror' do context 'when the current project has a remote mirror' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:remote_mirror) { project.remote_mirrors.create!(enabled: 1, url: 'http://local.dev') } let(:remote_mirror) { project.remote_mirrors.create!(enabled: 1, url: 'http://local.dev') }
before do before do
...@@ -95,7 +95,7 @@ describe Projects::MirrorsController do ...@@ -95,7 +95,7 @@ describe Projects::MirrorsController do
end end
context 'when project does not have a mirror' do context 'when project does not have a mirror' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
it 'allows to create a mirror' do it 'allows to create a mirror' do
expect_any_instance_of(EE::Project).to receive(:force_import_job!) expect_any_instance_of(EE::Project).to receive(:force_import_job!)
...@@ -107,7 +107,7 @@ describe Projects::MirrorsController do ...@@ -107,7 +107,7 @@ describe Projects::MirrorsController do
end end
context 'when project has a mirror' do context 'when project has a mirror' do
let(:project) { create(:project, :mirror, :import_finished) } let(:project) { create(:empty_project, :mirror, :import_finished) }
it 'is able to disable the mirror' do it 'is able to disable the mirror' do
expect { do_put(project, mirror: false) }.to change { Project.mirror.count }.to(0) expect { do_put(project, mirror: false) }.to change { Project.mirror.count }.to(0)
...@@ -119,7 +119,7 @@ describe Projects::MirrorsController do ...@@ -119,7 +119,7 @@ describe Projects::MirrorsController do
it 'forces update' do it 'forces update' do
expect_any_instance_of(EE::Project).to receive(:force_import_job!) expect_any_instance_of(EE::Project).to receive(:force_import_job!)
project = create(:project, :mirror) project = create(:empty_project, :mirror)
sign_in(project.owner) sign_in(project.owner)
put :update_now, { namespace_id: project.namespace.to_param, project_id: project.to_param } put :update_now, { namespace_id: project.namespace.to_param, project_id: project.to_param }
......
...@@ -26,7 +26,7 @@ describe 'GlobalSearch' do ...@@ -26,7 +26,7 @@ describe 'GlobalSearch' do
context "Respect feature visibility levels" do context "Respect feature visibility levels" do
context "Private projects" do context "Private projects" do
let(:project) { create(:project, :private) } let(:project) { create(:project, :private, :repository) }
# The feature can be disabled but the data may actually exist # The feature can be disabled but the data may actually exist
it "does not find items if features are disabled" do it "does not find items if features are disabled" do
...@@ -57,7 +57,7 @@ describe 'GlobalSearch' do ...@@ -57,7 +57,7 @@ describe 'GlobalSearch' do
end end
context "Internal projects" do context "Internal projects" do
let(:project) { create(:project, :internal) } let(:project) { create(:project, :internal, :repository) }
# The feature can be disabled but the data may actually exist # The feature can be disabled but the data may actually exist
it "does not find items if features are disabled" do it "does not find items if features are disabled" do
...@@ -101,7 +101,7 @@ describe 'GlobalSearch' do ...@@ -101,7 +101,7 @@ describe 'GlobalSearch' do
end end
context "Public projects" do context "Public projects" do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
# The feature can be disabled but the data may actually exist # The feature can be disabled but the data may actually exist
it "does not find items if features are disabled" do it "does not find items if features are disabled" do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe "Admin::Emails", :js do describe "Admin::Emails", :js do
let!(:current_user) { create(:admin) } let!(:current_user) { create(:admin) }
let!(:group) { create(:group) } let!(:group) { create(:group) }
let!(:project) { create(:project, namespace: group) } let!(:project) { create(:empty_project, namespace: group) }
describe "GET /admin/email" do describe "GET /admin/email" do
before do before do
......
...@@ -5,7 +5,7 @@ feature 'CI shared runner settings' do ...@@ -5,7 +5,7 @@ feature 'CI shared runner settings' do
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:group) { create(:group, :with_build_minutes) } let(:group) { create(:group, :with_build_minutes) }
let!(:project) { create(:project, namespace: group, shared_runners_enabled: true) } let!(:project) { create(:empty_project, namespace: group, shared_runners_enabled: true) }
before do before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
feature 'CI shared runner limits' do feature 'CI shared runner limits' do
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) { create(:project, namespace: group, shared_runners_enabled: true) } let!(:project) { create(:project, :repository, namespace: group, shared_runners_enabled: true) }
let(:group) { create(:group) } let(:group) { create(:group) }
before do before do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
feature 'Global elastic search' do feature 'Global elastic search' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, :repository, namespace: user.namespace) }
before do before do
stub_application_setting(elasticsearch_search: true, elasticsearch_indexing: true) stub_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
feature 'Group elastic search', :js do feature 'Group elastic search', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) } let(:project) { create(:project, :repository, namespace: group) }
def choose_group(group) def choose_group(group)
find('.js-search-group-dropdown').trigger('click') find('.js-search-group-dropdown').trigger('click')
......
...@@ -5,7 +5,7 @@ describe 'New/edit issue', :js do ...@@ -5,7 +5,7 @@ describe 'New/edit issue', :js do
include ActionView::Helpers::JavaScriptHelper include ActionView::Helpers::JavaScriptHelper
include FormHelper include FormHelper
let!(:project) { create(:project) } let!(:project) { create(:empty_project) }
let!(:user) { create(:user)} let!(:user) { create(:user)}
let!(:user2) { create(:user)} let!(:user2) { create(:user)}
let!(:milestone) { create(:milestone, project: project) } let!(:milestone) { create(:milestone, project: project) }
......
...@@ -2,7 +2,7 @@ require 'rails_helper' ...@@ -2,7 +2,7 @@ require 'rails_helper'
feature 'Merge request approvals', :js do feature 'Merge request approvals', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public, approvals_before_merge: 1) } let(:project) { create(:project, :public, :repository, approvals_before_merge: 1) }
context 'when editing an MR with a different author' do context 'when editing an MR with a different author' do
let(:author) { create(:user) } let(:author) { create(:user) }
...@@ -30,7 +30,7 @@ feature 'Merge request approvals', :js do ...@@ -30,7 +30,7 @@ feature 'Merge request approvals', :js do
context 'when creating an MR from a fork' do context 'when creating an MR from a fork' do
let(:other_user) { create(:user) } let(:other_user) { create(:user) }
let(:non_member) { create(:user) } let(:non_member) { create(:user) }
let(:forked_project) { create(:project, :public, creator: user) } let(:forked_project) { create(:project, :public, :repository, creator: user) }
before do before do
create(:forked_project_link, forked_to_project: forked_project, forked_from_project: project) create(:forked_project_link, forked_to_project: forked_project, forked_from_project: project)
...@@ -269,7 +269,7 @@ feature 'Merge request approvals', :js do ...@@ -269,7 +269,7 @@ feature 'Merge request approvals', :js do
context 'when merge when discussions resolved is active', :js do context 'when merge when discussions resolved is active', :js do
let(:project) do let(:project) do
create(:project, create(:project, :repository,
approvals_before_merge: 1, approvals_before_merge: 1,
only_allow_merge_if_all_discussions_are_resolved: true) only_allow_merge_if_all_discussions_are_resolved: true)
end end
......
...@@ -87,7 +87,7 @@ feature 'Merge Request closing issues message', js: true do ...@@ -87,7 +87,7 @@ feature 'Merge Request closing issues message', js: true do
project.team << [user, :developer] project.team << [user, :developer]
end end
let(:project) { create(:project, :public, approvals_before_merge: 1) } let(:project) { create(:project, :public, :repository, approvals_before_merge: 1) }
let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" } let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" }
it 'displays closing issue message exactly one time' do it 'displays closing issue message exactly one time' do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
feature 'Merge With Push Rules Validation', :js do feature 'Merge With Push Rules Validation', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public, push_rule: push_rule) } let(:project) { create(:project, :public, :repository, push_rule: push_rule) }
let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: 'Bug NS-04') } let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: 'Bug NS-04') }
before do before do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
feature 'Squashing merge requests', :js do feature 'Squashing merge requests', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:source_branch) { 'csv' } let(:source_branch) { 'csv' }
let!(:original_head) { project.repository.commit('master') } let!(:original_head) { project.repository.commit('master') }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
feature 'Projects > Audit Events', :js do feature 'Projects > Audit Events', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:pete) { create(:user, name: 'Pete') } let(:pete) { create(:user, name: 'Pete') }
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, :repository, namespace: user.namespace) }
before do before do
project.team << [user, :master] project.team << [user, :master]
......
...@@ -354,7 +354,7 @@ feature 'Jobs' do ...@@ -354,7 +354,7 @@ feature 'Jobs' do
context 'job project is over shared runners limit' do context 'job project is over shared runners limit' do
let(:group) { create(:group, :with_used_build_minutes_limit) } let(:group) { create(:group, :with_used_build_minutes_limit) }
let(:project) { create(:project, namespace: group, shared_runners_enabled: true) } let(:project) { create(:project, :repository, namespace: group, shared_runners_enabled: true) }
it 'displays a warning message' do it 'displays a warning message' do
visit project_job_path(project, job) visit project_job_path(project, job)
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
feature 'Projects > Members > Member is removed from project' do feature 'Projects > Members > Member is removed from project' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:empty_project) }
background do background do
project.team << [user, :master] project.team << [user, :master]
......
require 'spec_helper' require 'spec_helper'
feature 'Project mirror' do feature 'Project mirror' do
let(:project) { create(:project, :mirror, :import_finished, creator: user, name: 'Victorialand') } let(:project) { create(:project, :mirror, :import_finished, :repository, creator: user, name: 'Victorialand') }
let(:user) { create(:user) } let(:user) { create(:user) }
describe 'On a project', js: true do describe 'On a project', js: true do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
feature 'Path Locks', :js do feature 'Path Locks', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, :repository, namespace: user.namespace) }
let(:tree_path) { project_tree_path(project, project.repository.root_ref) } let(:tree_path) { project_tree_path(project, project.repository.root_ref) }
before do before do
......
require 'spec_helper' require 'spec_helper'
feature 'Project remote mirror', feature: true do feature 'Project remote mirror', feature: true do
let(:project) { create(:project, :remote_mirror) } let(:project) { create(:project, :repository, :remote_mirror) }
let(:remote_mirror) { project.remote_mirrors.first } let(:remote_mirror) { project.remote_mirrors.first }
let(:user) { create(:user) } let(:user) { create(:user) }
......
...@@ -18,7 +18,7 @@ describe SearchHelper do ...@@ -18,7 +18,7 @@ describe SearchHelper do
end end
it "returns parsed result" do it "returns parsed result" do
project = create :project project = create :project, :repository
project.repository.index_blobs project.repository.index_blobs
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::AuthorityAnalyzer do describe Gitlab::AuthorityAnalyzer do
describe '#calculate' do describe '#calculate' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:author) { create(:user) } let(:author) { create(:user) }
let(:user_a) { create(:user) } let(:user_a) { create(:user) }
let(:user_b) { create(:user) } let(:user_b) { create(:user) }
......
...@@ -173,7 +173,7 @@ describe Gitlab::Checks::ChangeAccess do ...@@ -173,7 +173,7 @@ describe Gitlab::Checks::ChangeAccess do
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
end end
let(:project) { create(:project, :public, push_rule: push_rule) } let(:project) { create(:project, :public, :repository, push_rule: push_rule) }
before do before do
allow(project.repository).to receive(:new_commits).and_return( allow(project.repository).to receive(:new_commits).and_return(
......
...@@ -8,7 +8,7 @@ describe Gitlab::Elastic::Indexer do ...@@ -8,7 +8,7 @@ describe Gitlab::Elastic::Indexer do
stub_application_setting(elasticsearch_url: ['http://localhost:9200']) stub_application_setting(elasticsearch_url: ['http://localhost:9200'])
end end
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:from_sha) { Gitlab::Git::BLANK_SHA } let(:from_sha) { Gitlab::Git::BLANK_SHA }
let(:to_sha) { project.commit.try(:sha) } let(:to_sha) { project.commit.try(:sha) }
let(:indexer) { described_class.new(project) } let(:indexer) { described_class.new(project) }
...@@ -40,7 +40,7 @@ describe Gitlab::Elastic::Indexer do ...@@ -40,7 +40,7 @@ describe Gitlab::Elastic::Indexer do
end end
context 'test project' do context 'test project' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
it 'runs the indexing command' do it 'runs the indexing command' do
expect_popen.with( expect_popen.with(
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::Elastic::ProjectSearchResults do describe Gitlab::Elastic::ProjectSearchResults do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:query) { 'hello world' } let(:query) { 'hello world' }
before do before do
...@@ -34,8 +34,8 @@ describe Gitlab::Elastic::ProjectSearchResults do ...@@ -34,8 +34,8 @@ describe Gitlab::Elastic::ProjectSearchResults do
describe "search" do describe "search" do
it "returns correct amounts" do it "returns correct amounts" do
project = create :project, :public project = create :project, :public, :repository
project1 = create :project, :public project1 = create :project, :public, :repository
project.repository.index_blobs project.repository.index_blobs
project.repository.index_commits project.repository.index_commits
...@@ -81,7 +81,7 @@ describe Gitlab::Elastic::ProjectSearchResults do ...@@ -81,7 +81,7 @@ describe Gitlab::Elastic::ProjectSearchResults do
end end
describe "search for commits in non-default branch" do describe "search for commits in non-default branch" do
let(:project) { create(:project, :public, visibility) } let(:project) { create(:project, :public, :repository, visibility) }
let(:visibility) { :repository_enabled } let(:visibility) { :repository_enabled }
let(:result) { described_class.new(user, 'initial', project.id, 'test') } let(:result) { described_class.new(user, 'initial', project.id, 'test') }
......
...@@ -12,8 +12,8 @@ describe Gitlab::Elastic::SearchResults do ...@@ -12,8 +12,8 @@ describe Gitlab::Elastic::SearchResults do
end end
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project_1) { create(:project) } let(:project_1) { create(:project, :repository) }
let(:project_2) { create(:project) } let(:project_2) { create(:project, :repository) }
let(:limit_project_ids) { [project_1.id] } let(:limit_project_ids) { [project_1.id] }
describe 'issues' do describe 'issues' do
...@@ -334,7 +334,7 @@ describe Gitlab::Elastic::SearchResults do ...@@ -334,7 +334,7 @@ describe Gitlab::Elastic::SearchResults do
describe 'project scoping' do describe 'project scoping' do
it "returns items for project" do it "returns items for project" do
project = create :project, name: "term" project = create :project, :repository, name: "term"
# Create issue # Create issue
create :issue, title: 'bla-bla term', project: project create :issue, title: 'bla-bla term', project: project
...@@ -383,7 +383,7 @@ describe Gitlab::Elastic::SearchResults do ...@@ -383,7 +383,7 @@ describe Gitlab::Elastic::SearchResults do
end end
it 'finds blobs from public projects only' do it 'finds blobs from public projects only' do
project_2 = create :project, :private project_2 = create :project, :repository, :private
project_2.repository.index_blobs project_2.repository.index_blobs
Gitlab::Elastic::Helper.refresh_index Gitlab::Elastic::Helper.refresh_index
...@@ -468,7 +468,7 @@ describe Gitlab::Elastic::SearchResults do ...@@ -468,7 +468,7 @@ describe Gitlab::Elastic::SearchResults do
end end
it 'finds wiki blobs from public projects only' do it 'finds wiki blobs from public projects only' do
project_2 = create :project, :private project_2 = create :project, :repository, :private
project_2.wiki.create_page('index_page', 'term') project_2.wiki.create_page('index_page', 'term')
project_2.wiki.index_blobs project_2.wiki.index_blobs
Gitlab::Elastic::Helper.refresh_index Gitlab::Elastic::Helper.refresh_index
...@@ -486,7 +486,7 @@ describe Gitlab::Elastic::SearchResults do ...@@ -486,7 +486,7 @@ describe Gitlab::Elastic::SearchResults do
end end
context 'when wiki is disabled' do context 'when wiki is disabled' do
let(:project_1) { create(:project, :public, :wiki_disabled) } let(:project_1) { create(:project, :public, :repository, :wiki_disabled) }
context 'search by member' do context 'search by member' do
let(:limit_project_ids) { [project_1.id] } let(:limit_project_ids) { [project_1.id] }
...@@ -502,7 +502,7 @@ describe Gitlab::Elastic::SearchResults do ...@@ -502,7 +502,7 @@ describe Gitlab::Elastic::SearchResults do
end end
context 'when wiki is internal' do context 'when wiki is internal' do
let(:project_1) { create(:project, :public, :wiki_private) } let(:project_1) { create(:project, :public, :repository, :wiki_private) }
context 'search by member' do context 'search by member' do
let(:limit_project_ids) { [project_1.id] } let(:limit_project_ids) { [project_1.id] }
...@@ -534,7 +534,7 @@ describe Gitlab::Elastic::SearchResults do ...@@ -534,7 +534,7 @@ describe Gitlab::Elastic::SearchResults do
end end
it 'finds commits from public projects only' do it 'finds commits from public projects only' do
project_2 = create :project, :private project_2 = create :project, :private, :repository
project_2.repository.index_commits project_2.repository.index_commits
Gitlab::Elastic::Helper.refresh_index Gitlab::Elastic::Helper.refresh_index
...@@ -553,10 +553,10 @@ describe Gitlab::Elastic::SearchResults do ...@@ -553,10 +553,10 @@ describe Gitlab::Elastic::SearchResults do
end end
describe 'Visibility levels' do describe 'Visibility levels' do
let(:internal_project) { create(:project, :internal, description: "Internal project") } let(:internal_project) { create(:project, :internal, :repository, description: "Internal project") }
let(:private_project1) { create(:project, :private, description: "Private project") } let(:private_project1) { create(:project, :private, :repository, description: "Private project") }
let(:private_project2) { create(:project, :private, description: "Private project where I'm a member") } let(:private_project2) { create(:project, :private, :repository, description: "Private project where I'm a member") }
let(:public_project) { create(:project, :public, description: "Public project") } let(:public_project) { create(:project, :public, :repository, description: "Public project") }
let(:limit_project_ids) { [private_project2.id] } let(:limit_project_ids) { [private_project2.id] }
before do before do
......
...@@ -928,7 +928,7 @@ describe Gitlab::GitAccess do ...@@ -928,7 +928,7 @@ describe Gitlab::GitAccess do
end end
context 'when the repository is read only' do context 'when the repository is read only' do
let(:project) { create(:project, :read_only_repository) } let(:project) { create(:project, :repository, :read_only_repository) }
it 'denies push access' do it 'denies push access' do
project.team << [user, :master] project.team << [user, :master]
......
...@@ -12,7 +12,7 @@ describe MergeRequest, elastic: true do ...@@ -12,7 +12,7 @@ describe MergeRequest, elastic: true do
end end
it "searches merge requests" do it "searches merge requests" do
project = create :project project = create :project, :repository
Sidekiq::Testing.inline! do Sidekiq::Testing.inline! do
create :merge_request, title: 'bla-bla term1', source_project: project create :merge_request, title: 'bla-bla term1', source_project: project
......
...@@ -65,7 +65,7 @@ describe Note, elastic: true do ...@@ -65,7 +65,7 @@ describe Note, elastic: true do
end end
it "does not create ElasticIndexerWorker job for system messages" do it "does not create ElasticIndexerWorker job for system messages" do
project = create :project project = create :project, :repository
issue = create :issue, project: project issue = create :issue, project: project
# Only issue should be updated # Only issue should be updated
......
...@@ -12,7 +12,7 @@ describe Repository, elastic: true do ...@@ -12,7 +12,7 @@ describe Repository, elastic: true do
end end
it "searches blobs and commits" do it "searches blobs and commits" do
project = create :project project = create :project, :repository
Sidekiq::Testing.inline! do Sidekiq::Testing.inline! do
project.repository.index_blobs project.repository.index_blobs
...@@ -28,8 +28,8 @@ describe Repository, elastic: true do ...@@ -28,8 +28,8 @@ describe Repository, elastic: true do
describe "class method find_commits_by_message_with_elastic" do describe "class method find_commits_by_message_with_elastic" do
it "returns commits" do it "returns commits" do
project = create :project project = create :project, :repository
project1 = create :project project1 = create :project, :repository
project.repository.index_commits project.repository.index_commits
project1.repository.index_commits project1.repository.index_commits
...@@ -44,7 +44,7 @@ describe Repository, elastic: true do ...@@ -44,7 +44,7 @@ describe Repository, elastic: true do
describe "find_commits_by_message_with_elastic" do describe "find_commits_by_message_with_elastic" do
it "returns commits" do it "returns commits" do
project = create :project project = create :project, :repository
project.repository.index_commits project.repository.index_commits
......
...@@ -13,7 +13,7 @@ describe Snippet, elastic: true do ...@@ -13,7 +13,7 @@ describe Snippet, elastic: true do
context 'searching snippets by code' do context 'searching snippets by code' do
let!(:author) { create(:user) } let!(:author) { create(:user) }
let!(:project) { create(:project) } let!(:project) { create(:empty_project) }
let!(:public_snippet) { create(:snippet, :public, content: 'password: XXX') } let!(:public_snippet) { create(:snippet, :public, content: 'password: XXX') }
let!(:internal_snippet) { create(:snippet, :internal, content: 'password: XXX') } let!(:internal_snippet) { create(:snippet, :internal, content: 'password: XXX') }
......
require 'spec_helper' require 'spec_helper'
describe Ci::Build do describe Ci::Build do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:pipeline) do let(:pipeline) do
create(:ci_pipeline, project: project, create(:ci_pipeline, project: project,
......
require 'spec_helper' require 'spec_helper'
describe MergeRequest do describe MergeRequest do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
subject(:merge_request) { create(:merge_request, source_project: project, target_project: project) } subject(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
...@@ -19,7 +19,7 @@ describe MergeRequest do ...@@ -19,7 +19,7 @@ describe MergeRequest do
end end
context 'project allows rebase' do context 'project allows rebase' do
let(:project) { create(:project, merge_requests_rebase_enabled: true) } let(:project) { create(:project, :repository, merge_requests_rebase_enabled: true) }
it 'returns false when the project feature is unavailable' do it 'returns false when the project feature is unavailable' do
expect(merge_request.target_project).to receive(:feature_available?).with(:merge_request_rebase).at_least(:once).and_return(false) expect(merge_request.target_project).to receive(:feature_available?).with(:merge_request_rebase).at_least(:once).and_return(false)
......
...@@ -17,7 +17,7 @@ describe Project do ...@@ -17,7 +17,7 @@ describe Project do
end end
describe '#push_rule' do describe '#push_rule' do
let(:project) { create(:project, push_rule: create(:push_rule)) } let(:project) { create(:empty_project, push_rule: create(:push_rule)) }
subject(:push_rule) { project.push_rule(true) } subject(:push_rule) { project.push_rule(true) }
...@@ -63,7 +63,7 @@ describe Project do ...@@ -63,7 +63,7 @@ describe Project do
describe '#execute_hooks' do describe '#execute_hooks' do
it "triggers project and group hooks" do it "triggers project and group hooks" do
group = create :group, name: 'gitlab' group = create :group, name: 'gitlab'
project = create(:project, name: 'gitlabhq', namespace: group) project = create(:empty_project, name: 'gitlabhq', namespace: group)
project_hook = create(:project_hook, push_events: true, project: project) project_hook = create(:project_hook, push_events: true, project: project)
group_hook = create(:group_hook, push_events: true, group: group) group_hook = create(:group_hook, push_events: true, group: group)
...@@ -78,7 +78,7 @@ describe Project do ...@@ -78,7 +78,7 @@ describe Project do
end end
describe '#allowed_to_share_with_group?' do describe '#allowed_to_share_with_group?' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
it "returns true" do it "returns true" do
expect(project.allowed_to_share_with_group?).to be_truthy expect(project.allowed_to_share_with_group?).to be_truthy
...@@ -92,7 +92,7 @@ describe Project do ...@@ -92,7 +92,7 @@ describe Project do
describe '#feature_available?' do describe '#feature_available?' do
let(:namespace) { build_stubbed(:namespace) } let(:namespace) { build_stubbed(:namespace) }
let(:project) { build_stubbed(:project, namespace: namespace) } let(:project) { build_stubbed(:empty_project, namespace: namespace) }
let(:user) { build_stubbed(:user) } let(:user) { build_stubbed(:user) }
subject { project.feature_available?(feature, user) } subject { project.feature_available?(feature, user) }
...@@ -647,7 +647,7 @@ describe Project do ...@@ -647,7 +647,7 @@ describe Project do
].each do |spec| ].each do |spec|
context spec.inspect do context spec.inspect do
let(:spec) { spec } let(:spec) { spec }
let(:project) { build(:project, approvals_before_merge: spec[:database]) } let(:project) { build(:empty_project, approvals_before_merge: spec[:database]) }
subject { project.approvals_before_merge } subject { project.approvals_before_merge }
...@@ -669,7 +669,7 @@ describe Project do ...@@ -669,7 +669,7 @@ describe Project do
].each do |spec| ].each do |spec|
context spec.inspect do context spec.inspect do
let(:spec) { spec } let(:spec) { spec }
let(:project) { build(:project, reset_approvals_on_push: spec[:database]) } let(:project) { build(:empty_project, reset_approvals_on_push: spec[:database]) }
subject { project.reset_approvals_on_push? } subject { project.reset_approvals_on_push? }
...@@ -691,7 +691,7 @@ describe Project do ...@@ -691,7 +691,7 @@ describe Project do
].each do |spec| ].each do |spec|
context spec.inspect do context spec.inspect do
let(:spec) { spec } let(:spec) { spec }
let(:project) { build(:project, approvals_before_merge: spec[:database]) } let(:project) { build(:empty_project, approvals_before_merge: spec[:database]) }
subject { project.approvals_before_merge } subject { project.approvals_before_merge }
...@@ -785,7 +785,7 @@ describe Project do ...@@ -785,7 +785,7 @@ describe Project do
describe '#disabled_services' do describe '#disabled_services' do
let(:namespace) { create(:group, :private) } let(:namespace) { create(:group, :private) }
let(:project) { create(:project, :private, namespace: namespace) } let(:project) { create(:empty_project, :private, namespace: namespace) }
let(:disabled_services) { %w(jenkins jenkins_deprecated) } let(:disabled_services) { %w(jenkins jenkins_deprecated) }
context 'without a license key' do context 'without a license key' do
......
...@@ -28,7 +28,7 @@ describe ProjectMirrorData, type: :model do ...@@ -28,7 +28,7 @@ describe ProjectMirrorData, type: :model do
end end
describe '#reset_retry_count!' do describe '#reset_retry_count!' do
let(:mirror_data) { create(:project, :mirror, :import_finished).mirror_data } let(:mirror_data) { create(:empty_project, :mirror, :import_finished).mirror_data }
it 'resets retry_count to 0' do it 'resets retry_count to 0' do
mirror_data.retry_count = 3 mirror_data.retry_count = 3
...@@ -38,7 +38,7 @@ describe ProjectMirrorData, type: :model do ...@@ -38,7 +38,7 @@ describe ProjectMirrorData, type: :model do
end end
describe '#increment_retry_count!' do describe '#increment_retry_count!' do
let(:mirror_data) { create(:project, :mirror, :import_finished).mirror_data } let(:mirror_data) { create(:empty_project, :mirror, :import_finished).mirror_data }
it 'increments retry_count' do it 'increments retry_count' do
expect { mirror_data.increment_retry_count! }.to change { mirror_data.retry_count }.from(0).to(1) expect { mirror_data.increment_retry_count! }.to change { mirror_data.retry_count }.from(0).to(1)
...@@ -46,7 +46,7 @@ describe ProjectMirrorData, type: :model do ...@@ -46,7 +46,7 @@ describe ProjectMirrorData, type: :model do
end end
describe '#set_next_execution_timestamp!' do describe '#set_next_execution_timestamp!' do
let(:mirror_data) { create(:project, :mirror, :import_finished).mirror_data } let(:mirror_data) { create(:empty_project, :mirror, :import_finished).mirror_data }
let!(:timestamp) { Time.now } let!(:timestamp) { Time.now }
let!(:jitter) { 2.seconds } let!(:jitter) { 2.seconds }
let(:interval) { 2.minutes } let(:interval) { 2.minutes }
......
...@@ -62,7 +62,7 @@ eos ...@@ -62,7 +62,7 @@ eos
end end
describe 'multiproject enabled' do describe 'multiproject enabled' do
let!(:project) { create(:project) } let!(:project) { create(:empty_project) }
before do before do
@service = JenkinsDeprecatedService.new @service = JenkinsDeprecatedService.new
allow(@service).to receive_messages( allow(@service).to receive_messages(
...@@ -123,7 +123,7 @@ eos ...@@ -123,7 +123,7 @@ eos
describe '#execute' do describe '#execute' do
let(:user) { create(:user, username: 'username') } let(:user) { create(:user, username: 'username') }
let(:namespace) { create(:group, :private) } let(:namespace) { create(:group, :private) }
let(:project) { create(:project, :private, name: 'project', namespace: namespace) } let(:project) { create(:empty_project, :private, name: 'project', namespace: namespace) }
let(:push_sample_data) { Gitlab::DataBuilder::Push.build_sample(project, user) } let(:push_sample_data) { Gitlab::DataBuilder::Push.build_sample(project, user) }
let(:jenkins_service) { described_class.create(active: true, project: project) } let(:jenkins_service) { described_class.create(active: true, project: project) }
let!(:service_hook) { create(:service_hook, service: jenkins_service) } let!(:service_hook) { create(:service_hook, service: jenkins_service) }
......
...@@ -6,7 +6,7 @@ describe JenkinsService do ...@@ -6,7 +6,7 @@ describe JenkinsService do
it { is_expected.to have_one :service_hook } it { is_expected.to have_one :service_hook }
end end
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:jenkins_url) { 'http://jenkins.example.com/' } let(:jenkins_url) { 'http://jenkins.example.com/' }
let(:jenkins_hook_url) { jenkins_url + 'project/my_project' } let(:jenkins_hook_url) { jenkins_url + 'project/my_project' }
...@@ -125,7 +125,7 @@ describe JenkinsService do ...@@ -125,7 +125,7 @@ describe JenkinsService do
describe '#test' do describe '#test' do
it 'returns the right status' do it 'returns the right status' do
user = create(:user, username: 'username') user = create(:user, username: 'username')
project = create(:project, name: 'project') project = create(:empty_project, name: 'project')
push_sample_data = Gitlab::DataBuilder::Push.build_sample(project, user) push_sample_data = Gitlab::DataBuilder::Push.build_sample(project, user)
jenkins_service = described_class.create(jenkins_params) jenkins_service = described_class.create(jenkins_params)
stub_request(:post, jenkins_hook_url).with(headers: { 'Authorization' => jenkins_authorization }) stub_request(:post, jenkins_hook_url).with(headers: { 'Authorization' => jenkins_authorization })
...@@ -155,7 +155,7 @@ describe JenkinsService do ...@@ -155,7 +155,7 @@ describe JenkinsService do
describe '#execute' do describe '#execute' do
let(:user) { create(:user, username: 'username') } let(:user) { create(:user, username: 'username') }
let(:namespace) { create(:group, :private) } let(:namespace) { create(:group, :private) }
let(:project) { create(:project, :private, name: 'project', namespace: namespace) } let(:project) { create(:empty_project, :private, name: 'project', namespace: namespace) }
let(:push_sample_data) { Gitlab::DataBuilder::Push.build_sample(project, user) } let(:push_sample_data) { Gitlab::DataBuilder::Push.build_sample(project, user) }
let(:jenkins_service) { described_class.create(jenkins_params) } let(:jenkins_service) { described_class.create(jenkins_params) }
...@@ -217,7 +217,7 @@ describe JenkinsService do ...@@ -217,7 +217,7 @@ describe JenkinsService do
end end
describe 'Stored password invalidation' do describe 'Stored password invalidation' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
context 'when a password was previously set' do context 'when a password was previously set' do
before do before do
...@@ -268,7 +268,7 @@ describe JenkinsService do ...@@ -268,7 +268,7 @@ describe JenkinsService do
context 'when no password was previously set' do context 'when no password was previously set' do
before do before do
@jenkins_service = described_class.create( @jenkins_service = described_class.create(
project: create(:project), project: create(:empty_project),
properties: { properties: {
jenkins_url: 'http://jenkins.example.com/', jenkins_url: 'http://jenkins.example.com/',
username: 'jenkins' username: 'jenkins'
......
...@@ -126,7 +126,7 @@ describe Project do ...@@ -126,7 +126,7 @@ describe Project do
context '#with_wiki_enabled' do context '#with_wiki_enabled' do
it 'returns a project' do it 'returns a project' do
project = create(:project_empty_repo, wiki_access_level: ProjectFeature::ENABLED) project = create(:project_empty_repo, wiki_access_level: ProjectFeature::ENABLED)
project1 = create(:project, wiki_access_level: ProjectFeature::DISABLED) project1 = create(:empty_project, wiki_access_level: ProjectFeature::DISABLED)
expect(described_class.with_wiki_enabled).to include(project) expect(described_class.with_wiki_enabled).to include(project)
expect(described_class.with_wiki_enabled).not_to include(project1) expect(described_class.with_wiki_enabled).not_to include(project1)
...@@ -201,7 +201,7 @@ describe Project do ...@@ -201,7 +201,7 @@ describe Project do
context '#mark_stuck_remote_mirrors_as_failed!' do context '#mark_stuck_remote_mirrors_as_failed!' do
it 'fails stuck remote mirrors' do it 'fails stuck remote mirrors' do
project = create(:project, :remote_mirror) project = create(:project, :remote_mirror, :repository)
project.remote_mirrors.first.update_attributes( project.remote_mirrors.first.update_attributes(
update_status: :started, update_status: :started,
...@@ -215,7 +215,7 @@ describe Project do ...@@ -215,7 +215,7 @@ describe Project do
end end
context 'mirror' do context 'mirror' do
subject { build(:project, mirror: true) } subject { build(:empty_project, mirror: true) }
it { is_expected.to validate_presence_of(:import_url) } it { is_expected.to validate_presence_of(:import_url) }
it { is_expected.to validate_presence_of(:mirror_user) } it { is_expected.to validate_presence_of(:mirror_user) }
...@@ -1627,7 +1627,7 @@ describe Project do ...@@ -1627,7 +1627,7 @@ describe Project do
describe 'handling import URL' do describe 'handling import URL' do
context 'when project is a mirror' do context 'when project is a mirror' do
it 'returns the full URL' do it 'returns the full URL' do
project = create(:project, :mirror, import_url: 'http://user:pass@test.com') project = create(:empty_project, :mirror, import_url: 'http://user:pass@test.com')
project.import_finish project.import_finish
...@@ -1637,7 +1637,7 @@ describe Project do ...@@ -1637,7 +1637,7 @@ describe Project do
context 'when project is not a mirror' do context 'when project is not a mirror' do
it 'returns the sanitized URL' do it 'returns the sanitized URL' do
project = create(:project, import_status: 'started', import_url: 'http://user:pass@test.com') project = create(:empty_project, import_status: 'started', import_url: 'http://user:pass@test.com')
project.import_finish project.import_finish
...@@ -1878,7 +1878,7 @@ describe Project do ...@@ -1878,7 +1878,7 @@ describe Project do
end end
context 'elasticsearch indexing enabled' do context 'elasticsearch indexing enabled' do
let(:project) { create(:project, :import_started, import_type: :github) } let(:project) { create(:empty_project, :import_started, import_type: :github) }
before do before do
stub_application_setting(elasticsearch_indexing: true) stub_application_setting(elasticsearch_indexing: true)
...@@ -1988,7 +1988,7 @@ describe Project do ...@@ -1988,7 +1988,7 @@ describe Project do
context 'when mirror is expected to run soon' do context 'when mirror is expected to run soon' do
it 'returns true' do it 'returns true' do
timestamp = Time.now timestamp = Time.now
project = create(:project, :mirror, :import_finished) project = create(:project, :mirror, :import_finished, :repository)
project.mirror_last_update_at = timestamp - 3.minutes project.mirror_last_update_at = timestamp - 3.minutes
project.mirror_data.next_execution_timestamp = timestamp - 2.minutes project.mirror_data.next_execution_timestamp = timestamp - 2.minutes
...@@ -1999,7 +1999,7 @@ describe Project do ...@@ -1999,7 +1999,7 @@ describe Project do
context 'when mirror was scheduled' do context 'when mirror was scheduled' do
it 'returns true' do it 'returns true' do
project = create(:project, :mirror, :import_scheduled) project = create(:project, :mirror, :import_scheduled, :repository)
expect(project.scheduled_mirror?).to be true expect(project.scheduled_mirror?).to be true
end end
...@@ -2017,7 +2017,7 @@ describe Project do ...@@ -2017,7 +2017,7 @@ describe Project do
context 'when project is not a mirror' do context 'when project is not a mirror' do
it 'returns false' do it 'returns false' do
project = create(:project, :import_started) project = create(:empty_project, :import_started)
expect(project.updating_mirror?).to be false expect(project.updating_mirror?).to be false
end end
...@@ -2025,7 +2025,7 @@ describe Project do ...@@ -2025,7 +2025,7 @@ describe Project do
context 'when mirror is in progress' do context 'when mirror is in progress' do
it 'returns true' do it 'returns true' do
project = create(:project, :mirror, :import_started) project = create(:project, :mirror, :import_started, :repository)
expect(project.updating_mirror?).to be true expect(project.updating_mirror?).to be true
end end
...@@ -2035,7 +2035,7 @@ describe Project do ...@@ -2035,7 +2035,7 @@ describe Project do
describe '#force_import_job!' do describe '#force_import_job!' do
it 'sets next execution timestamp to now and schedules UpdateAllMirrorsWorker' do it 'sets next execution timestamp to now and schedules UpdateAllMirrorsWorker' do
timestamp = Time.now timestamp = Time.now
project = create(:project, :mirror) project = create(:empty_project, :mirror)
project.mirror_data.update_attributes(next_execution_timestamp: timestamp - 3.minutes) project.mirror_data.update_attributes(next_execution_timestamp: timestamp - 3.minutes)
...@@ -2062,7 +2062,7 @@ describe Project do ...@@ -2062,7 +2062,7 @@ describe Project do
context 'without mirror' do context 'without mirror' do
it 'returns nil' do it 'returns nil' do
project = create(:project) project = create(:empty_project)
expect(project.add_import_job).to be_nil expect(project.add_import_job).to be_nil
end end
...@@ -2080,7 +2080,7 @@ describe Project do ...@@ -2080,7 +2080,7 @@ describe Project do
context 'with mirror' do context 'with mirror' do
it 'schedules RepositoryUpdateMirrorWorker' do it 'schedules RepositoryUpdateMirrorWorker' do
project = create(:project, :mirror) project = create(:project, :mirror, :repository)
expect(RepositoryUpdateMirrorWorker).to receive(:perform_async).with(project.id) expect(RepositoryUpdateMirrorWorker).to receive(:perform_async).with(project.id)
...@@ -2188,8 +2188,8 @@ describe Project do ...@@ -2188,8 +2188,8 @@ describe Project do
end end
context 'with valid paths' do context 'with valid paths' do
let!(:project1) { create(:project) } let!(:project1) { create(:empty_project) }
let!(:project2) { create(:project) } let!(:project2) { create(:empty_project) }
it 'returns the projects matching the paths' do it 'returns the projects matching the paths' do
projects = described_class.where_full_path_in([project1.full_path, projects = described_class.where_full_path_in([project1.full_path,
...@@ -2222,8 +2222,8 @@ describe Project do ...@@ -2222,8 +2222,8 @@ describe Project do
end end
describe '#change_repository_storage' do describe '#change_repository_storage' do
let(:project) { create(:project, repository_storage: 'a') } let(:project) { create(:project, :repository, repository_storage: 'a') }
let(:read_only_project) { create(:project, repository_storage: 'a', repository_read_only: true) } let(:read_only_project) { create(:project, :repository, repository_storage: 'a', repository_read_only: true) }
before do before do
FileUtils.mkdir('tmp/tests/storage_a') FileUtils.mkdir('tmp/tests/storage_a')
...@@ -2336,7 +2336,7 @@ describe Project do ...@@ -2336,7 +2336,7 @@ describe Project do
end end
describe '#repository_and_lfs_size' do describe '#repository_and_lfs_size' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:size) { 50 } let(:size) { 50 }
before do before do
...@@ -2355,7 +2355,7 @@ describe Project do ...@@ -2355,7 +2355,7 @@ describe Project do
group = create :group group = create :group
group1 = create :group group1 = create :group
project = create :project project = create :empty_project
project.approver_group_ids = "#{group.id}, #{group1.id}" project.approver_group_ids = "#{group.id}, #{group1.id}"
project.save! project.save!
...@@ -2506,7 +2506,7 @@ describe Project do ...@@ -2506,7 +2506,7 @@ describe Project do
describe '#create_mirror_data' do describe '#create_mirror_data' do
it 'it is called after save' do it 'it is called after save' do
project = create(:project) project = create(:empty_project)
expect(project).to receive(:create_mirror_data) expect(project).to receive(:create_mirror_data)
......
...@@ -86,7 +86,7 @@ describe RemoteMirror do ...@@ -86,7 +86,7 @@ describe RemoteMirror do
end end
context '#sync' do context '#sync' do
let(:remote_mirror) { create(:project, :remote_mirror).remote_mirrors.first } let(:remote_mirror) { create(:project, :repository, :remote_mirror).remote_mirrors.first }
before do before do
Timecop.freeze(Time.now) Timecop.freeze(Time.now)
...@@ -142,7 +142,7 @@ describe RemoteMirror do ...@@ -142,7 +142,7 @@ describe RemoteMirror do
end end
context '#updated_since?' do context '#updated_since?' do
let(:remote_mirror) { create(:project, :remote_mirror).remote_mirrors.first } let(:remote_mirror) { create(:project, :repository, :remote_mirror).remote_mirrors.first }
let(:timestamp) { Time.now - 5.minutes } let(:timestamp) { Time.now - 5.minutes }
before do before do
...@@ -192,7 +192,7 @@ describe RemoteMirror do ...@@ -192,7 +192,7 @@ describe RemoteMirror do
end end
def create_mirror(params) def create_mirror(params)
project = FactoryGirl.create(:project) project = FactoryGirl.create(:project, :repository)
project.remote_mirrors.create!(params) project.remote_mirrors.create!(params)
end end
end end
...@@ -1422,8 +1422,8 @@ describe Repository do ...@@ -1422,8 +1422,8 @@ describe Repository do
describe "class method find_commits_by_message_with_elastic" do describe "class method find_commits_by_message_with_elastic" do
it "returns commits" do it "returns commits" do
project = create :project project = create :project, :repository
project1 = create :project project1 = create :project, :repository
project.repository.index_commits project.repository.index_commits
project1.repository.index_commits project1.repository.index_commits
...@@ -1438,7 +1438,7 @@ describe Repository do ...@@ -1438,7 +1438,7 @@ describe Repository do
describe "find_commits_by_message_with_elastic" do describe "find_commits_by_message_with_elastic" do
it "returns commits" do it "returns commits" do
project = create :project project = create :project, :repository
project.repository.index_commits project.repository.index_commits
......
...@@ -185,7 +185,7 @@ describe API::Members do ...@@ -185,7 +185,7 @@ describe API::Members do
context 'project in a group' do context 'project in a group' do
it 'returns a 405 method not allowed error when group membership lock is enabled' do it 'returns a 405 method not allowed error when group membership lock is enabled' do
group_with_membership_locked = create(:group, membership_lock: true) group_with_membership_locked = create(:group, membership_lock: true)
project = create(:project, group: group_with_membership_locked) project = create(:empty_project, group: group_with_membership_locked)
project.group.add_owner(master) project.group.add_owner(master)
post api("/projects/#{project.id}/members", master), post api("/projects/#{project.id}/members", master),
......
...@@ -4,7 +4,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -4,7 +4,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
include ApiHelpers include ApiHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let!(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } let!(:project) { create(:project, :repository, creator_id: user.id, namespace: user.namespace) }
before do before do
project.team << [user, :master] project.team << [user, :master]
......
...@@ -4,7 +4,7 @@ describe API::V3::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -4,7 +4,7 @@ describe API::V3::ProjectPushRule, 'ProjectPushRule', api: true do
include ApiHelpers include ApiHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let!(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } let!(:project) { create(:project, :repository, creator_id: user.id, namespace: user.namespace) }
before do before do
project.team << [user, :master] project.team << [user, :master]
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::MirrorsController do describe Projects::MirrorsController do
let(:project) do let(:project) do
create(:project, create(:project, :repository,
mirror: true, mirror: true,
mirror_user: user, mirror_user: user,
import_url: 'http://user:pass@test.url') import_url: 'http://user:pass@test.url')
......
...@@ -2,7 +2,7 @@ require "spec_helper" ...@@ -2,7 +2,7 @@ require "spec_helper"
describe "routes to the proper webhooks controller", type: :routing do describe "routes to the proper webhooks controller", type: :routing do
context 'with a project context' do context 'with a project context' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:project_hook) { create(:project_hook) } let(:project_hook) { create(:project_hook) }
it "routes the test action" do it "routes the test action" do
......
...@@ -11,7 +11,7 @@ describe Issues::BuildService do # rubocop:disable RSpec/FilePath ...@@ -11,7 +11,7 @@ describe Issues::BuildService do # rubocop:disable RSpec/FilePath
context 'with an issue template' do context 'with an issue template' do
describe '#execute' do describe '#execute' do
it 'fills in the template in the description' do it 'fills in the template in the description' do
project = build(:project, issues_template: 'Work hard, play hard!') project = build(:empty_project, issues_template: 'Work hard, play hard!')
service = described_class.new(project, user) service = described_class.new(project, user)
issue = service.execute issue = service.execute
......
require 'spec_helper' require 'spec_helper'
describe Geo::MoveRepositoryService do describe Geo::MoveRepositoryService do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:new_path) { project.full_path + '+renamed' } let(:new_path) { project.full_path + '+renamed' }
let(:full_new_path) { File.join(project.repository_storage_path, new_path) } let(:full_new_path) { File.join(project.repository_storage_path, new_path) }
subject { described_class.new(project.id, project.name, project.full_path, new_path) } subject { described_class.new(project.id, project.name, project.full_path, new_path) }
......
require 'spec_helper' require 'spec_helper'
describe Geo::RepositoryUpdatedEventStore do describe Geo::RepositoryUpdatedEventStore do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:blankrev) { Gitlab::Git::BLANK_SHA } let(:blankrev) { Gitlab::Git::BLANK_SHA }
let(:refs) { ['refs/heads/tést', 'refs/tags/tag'] } let(:refs) { ['refs/heads/tést', 'refs/tags/tag'] }
......
require 'spec_helper' require 'spec_helper'
describe Geo::ScheduleRepoCreateService do describe Geo::ScheduleRepoCreateService do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
subject { described_class.new(project_id: project.id) } subject { described_class.new(project_id: project.id) }
describe '#execute' do describe '#execute' do
......
...@@ -4,7 +4,7 @@ describe Geo::ScheduleRepoUpdateService do ...@@ -4,7 +4,7 @@ describe Geo::ScheduleRepoUpdateService do
include RepoHelpers include RepoHelpers
let(:user) { create :user } let(:user) { create :user }
let(:project) { create :project } let(:project) { create :project, :repository }
let(:blankrev) { Gitlab::Git::BLANK_SHA } let(:blankrev) { Gitlab::Git::BLANK_SHA }
let(:oldrev) { sample_commit.parent_id } let(:oldrev) { sample_commit.parent_id }
......
...@@ -15,7 +15,7 @@ describe GitPushService do ...@@ -15,7 +15,7 @@ describe GitPushService do
end end
describe 'with remote mirrors' do describe 'with remote mirrors' do
let(:project) { create(:project, :remote_mirror) } let(:project) { create(:project, :repository, :remote_mirror) }
subject do subject do
described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref)
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe MergeRequests::SquashService do describe MergeRequests::SquashService do
let(:service) { described_class.new(project, user, {}) } let(:service) { described_class.new(project, user, {}) }
let(:user) { project.owner } let(:user) { project.owner }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:merge_request_with_one_commit) do let(:merge_request_with_one_commit) do
create(:merge_request, create(:merge_request,
......
...@@ -65,7 +65,7 @@ describe Projects::DestroyService do ...@@ -65,7 +65,7 @@ describe Projects::DestroyService do
context 'when has remote mirrors' do context 'when has remote mirrors' do
let!(:project) do let!(:project) do
create(:project, namespace: user.namespace).tap do |project| create(:project, :repository, namespace: user.namespace).tap do |project|
project.remote_mirrors.create(url: 'http://test.com') project.remote_mirrors.create(url: 'http://test.com')
end end
end end
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::SlackApplicationInstallService do describe Projects::SlackApplicationInstallService do
let!(:user) { create(:user) } let!(:user) { create(:user) }
let!(:project) { create(:project) } let!(:project) { create(:empty_project) }
def service(params = {}) def service(params = {})
Projects::SlackApplicationInstallService.new(project, user, params) Projects::SlackApplicationInstallService.new(project, user, params)
......
require 'spec_helper' require 'spec_helper'
describe Projects::UpdateMirrorService do describe Projects::UpdateMirrorService do
let(:project) { create(:project, :mirror, import_url: Project::UNKNOWN_IMPORT_URL) } let(:project) { create(:project, :repository, :mirror, import_url: Project::UNKNOWN_IMPORT_URL) }
describe "#execute" do describe "#execute" do
context 'unlicensed' do context 'unlicensed' do
...@@ -124,7 +124,7 @@ describe Projects::UpdateMirrorService do ...@@ -124,7 +124,7 @@ describe Projects::UpdateMirrorService do
end end
describe "when is no mirror" do describe "when is no mirror" do
let(:project) { build_stubbed(:project) } let(:project) { build_stubbed(:empty_project) }
it "success" do it "success" do
expect(project.mirror?).to eq(false) expect(project.mirror?).to eq(false)
......
require 'spec_helper' require 'spec_helper'
describe Projects::UpdateRemoteMirrorService do describe Projects::UpdateRemoteMirrorService do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:remote_project) { create(:forked_project_with_submodules) } let(:remote_project) { create(:forked_project_with_submodules) }
let(:repository) { project.repository } let(:repository) { project.repository }
let(:remote_mirror) { project.remote_mirrors.create!(url: remote_project.http_url_to_repo, enabled: true) } let(:remote_mirror) { project.remote_mirrors.create!(url: remote_project.http_url_to_repo, enabled: true) }
......
...@@ -27,7 +27,7 @@ describe Projects::UpdateRepositoryStorageService do ...@@ -27,7 +27,7 @@ describe Projects::UpdateRepositoryStorageService do
end end
context 'without wiki', skip_gitaly_mock: true do context 'without wiki', skip_gitaly_mock: true do
let(:project) { create(:project, repository_storage: 'a', repository_read_only: true, wiki_enabled: false) } let(:project) { create(:project, :repository, repository_storage: 'a', repository_read_only: true, wiki_enabled: false) }
context 'when the move succeeds' do context 'when the move succeeds' do
it 'moves the repository to the new storage and unmarks the repository as read only' do it 'moves the repository to the new storage and unmarks the repository as read only' do
...@@ -63,7 +63,7 @@ describe Projects::UpdateRepositoryStorageService do ...@@ -63,7 +63,7 @@ describe Projects::UpdateRepositoryStorageService do
end end
context 'with wiki', skip_gitaly_mock: true do context 'with wiki', skip_gitaly_mock: true do
let(:project) { create(:project, repository_storage: 'a', repository_read_only: true, wiki_enabled: true) } let(:project) { create(:project, :repository, repository_storage: 'a', repository_read_only: true, wiki_enabled: true) }
before do before do
project.create_wiki project.create_wiki
......
...@@ -137,7 +137,7 @@ describe Projects::UpdateService, '#execute' do ...@@ -137,7 +137,7 @@ describe Projects::UpdateService, '#execute' do
describe 'repository_storage' do describe 'repository_storage' do
let(:admin_user) { create(:user, admin: true) } let(:admin_user) { create(:user, admin: true) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, repository_storage: 'a') } let(:project) { create(:project, :repository, repository_storage: 'a') }
let(:opts) { { repository_storage: 'b' } } let(:opts) { { repository_storage: 'b' } }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe SlashCommands::GlobalSlackHandler do describe SlashCommands::GlobalSlackHandler do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:verification_token) { '123' } let(:verification_token) { '123' }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe AdminEmailsWorker do describe AdminEmailsWorker do
context "recipients" do context "recipients" do
let(:group) { create :group } let(:group) { create :group }
let(:project) { create :project } let(:project) { create :empty_project }
before do before do
2.times do 2.times do
......
require 'spec_helper' require 'spec_helper'
describe ElasticCommitIndexerWorker do describe ElasticCommitIndexerWorker do
let!(:project) { create(:project) } let!(:project) { create(:project, :repository) }
subject { described_class.new } subject { described_class.new }
......
...@@ -174,7 +174,7 @@ describe ElasticIndexerWorker, elastic: true do ...@@ -174,7 +174,7 @@ describe ElasticIndexerWorker, elastic: true do
project, issue, milestone, note, merge_request = nil project, issue, milestone, note, merge_request = nil
Sidekiq::Testing.disable! do Sidekiq::Testing.disable! do
project = create :project project = create :project, :repository
subject.perform("index", "Project", project.id) subject.perform("index", "Project", project.id)
issue = create :issue, project: project issue = create :issue, project: project
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe GeoRepositoryCreateWorker do describe GeoRepositoryCreateWorker do
let(:user) { create :user } let(:user) { create :user }
let(:project) { create :project } let(:project) { create :project, :repository }
let(:perform!) { subject.perform(project.id) } let(:perform!) { subject.perform(project.id) }
before do before do
......
...@@ -4,7 +4,7 @@ describe GeoRepositoryUpdateWorker do ...@@ -4,7 +4,7 @@ describe GeoRepositoryUpdateWorker do
include RepoHelpers include RepoHelpers
let(:user) { create :user } let(:user) { create :user }
let(:project) { create :project } let(:project) { create :project, :repository }
let(:blankrev) { Gitlab::Git::BLANK_SHA } let(:blankrev) { Gitlab::Git::BLANK_SHA }
let(:oldrev) { sample_commit.parent_id } let(:oldrev) { sample_commit.parent_id }
......
require 'spec_helper' require 'spec_helper'
describe ProjectUpdateRepositoryStorageWorker do describe ProjectUpdateRepositoryStorageWorker do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
subject { described_class.new } subject { described_class.new }
......
...@@ -27,7 +27,7 @@ describe RepositoryUpdateMirrorWorker do ...@@ -27,7 +27,7 @@ describe RepositoryUpdateMirrorWorker do
context 'with another worker already running' do context 'with another worker already running' do
it 'raises UpdateAlreadyInProgressError' do it 'raises UpdateAlreadyInProgressError' do
mirror = create(:project, :mirror, :import_started) mirror = create(:project, :repository, :mirror, :import_started)
expect do expect do
subject.perform(mirror.id) subject.perform(mirror.id)
...@@ -37,7 +37,7 @@ describe RepositoryUpdateMirrorWorker do ...@@ -37,7 +37,7 @@ describe RepositoryUpdateMirrorWorker do
context 'with unexpected error' do context 'with unexpected error' do
it 'marks mirror as failed' do it 'marks mirror as failed' do
mirror = create(:project, :mirror, :import_scheduled) mirror = create(:project, :repository, :mirror, :import_scheduled)
allow_any_instance_of(Projects::UpdateMirrorService).to receive(:execute).and_raise(RuntimeError) allow_any_instance_of(Projects::UpdateMirrorService).to receive(:execute).and_raise(RuntimeError)
...@@ -49,7 +49,7 @@ describe RepositoryUpdateMirrorWorker do ...@@ -49,7 +49,7 @@ describe RepositoryUpdateMirrorWorker do
end end
context 'threshold_reached?' do context 'threshold_reached?' do
let(:mirror) { create(:project, :mirror, :import_scheduled) } let(:mirror) { create(:project, :repository, :mirror, :import_scheduled) }
before do before do
expect_any_instance_of(Projects::UpdateMirrorService).to receive(:execute).and_return(status: :success) expect_any_instance_of(Projects::UpdateMirrorService).to receive(:execute).and_return(status: :success)
......
...@@ -3,7 +3,7 @@ require 'rails_helper' ...@@ -3,7 +3,7 @@ require 'rails_helper'
describe RepositoryUpdateRemoteMirrorWorker do describe RepositoryUpdateRemoteMirrorWorker do
subject { described_class.new } subject { described_class.new }
let(:remote_mirror) { create(:project, :remote_mirror).remote_mirrors.first } let(:remote_mirror) { create(:project, :repository, :remote_mirror).remote_mirrors.first }
let(:scheduled_time) { Time.now - 5.minutes } let(:scheduled_time) { Time.now - 5.minutes }
before do before do
......
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