Commit fcb37542 authored by Robert Speicher's avatar Robert Speicher
Browse files

Use `:empty_project` where possible in model specs

parent f27721e8
......@@ -3,7 +3,7 @@
describe Ability, lib: true do
describe '.can_edit_note?' do
let(:project) { create(:empty_project) }
let!(:note) { create(:note_on_issue, project: project) }
let(:note) { create(:note_on_issue, project: project) }
context 'using an anonymous user' do
it 'returns false' do
......@@ -60,7 +60,7 @@
describe '.users_that_can_read_project' do
context 'using a public project' do
it 'returns all the users' do
project = create(:project, :public)
project = create(:empty_project, :public)
user = build(:user)
expect(described_class.users_that_can_read_project([user], project)).
......@@ -69,7 +69,7 @@
end
context 'using an internal project' do
let(:project) { create(:project, :internal) }
let(:project) { create(:empty_project, :internal) }
it 'returns users that are administrators' do
user = build(:user, admin: true)
......@@ -120,7 +120,7 @@
end
context 'using a private project' do
let(:project) { create(:project, :private) }
let(:project) { create(:empty_project, :private) }
it 'returns users that are administrators' do
user = build(:user, admin: true)
......@@ -247,7 +247,7 @@ def users_for_snippet(snippet)
end
describe '.project_disabled_features_rules' do
let(:project) { create(:project, wiki_access_level: ProjectFeature::DISABLED) }
let(:project) { create(:empty_project, wiki_access_level: ProjectFeature::DISABLED) }
subject { described_class.allowed(project.owner, project) }
......
require 'spec_helper'
describe Ci::Build, :models do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:test_trace) { 'This is a test' }
......
......@@ -284,7 +284,7 @@ def create_build(name, status)
end
describe 'merge request metrics' do
let(:project) { FactoryGirl.create :project }
let(:project) { create(:project, :repository) }
let(:pipeline) { FactoryGirl.create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master', sha: project.repository.commit('master').id) }
let!(:merge_request) { create(:merge_request, source_project: project, source_branch: pipeline.ref) }
......@@ -339,7 +339,7 @@ def create_build(name, queued_at = current, started_from = 0)
end
context 'with non-empty project' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline,
......@@ -890,7 +890,7 @@ def create_build(name, stage_idx)
end
describe "#merge_requests" do
let(:project) { FactoryGirl.create :project }
let(:project) { create(:project, :repository) }
let(:pipeline) { FactoryGirl.create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master', sha: project.repository.commit('master').id) }
it "returns merge requests whose `diff_head_sha` matches the pipeline's SHA" do
......@@ -956,7 +956,7 @@ def create_build(name, stage_idx)
end
describe 'notifications when pipeline success or failed' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline,
......
......@@ -91,8 +91,7 @@
end
describe '#can_pick?' do
let(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:pipeline) { create(:ci_pipeline) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:runner) { create(:ci_runner) }
......@@ -321,8 +320,8 @@ def expect_value_in_redis
describe '.assignable_for' do
let(:runner) { create(:ci_runner) }
let(:project) { create(:project) }
let(:another_project) { create(:project) }
let(:project) { create(:empty_project) }
let(:another_project) { create(:empty_project) }
before do
project.runners << runner
......
......@@ -7,7 +7,7 @@
it { is_expected.to include_module(Referable) }
end
let!(:project) { create(:project, :public) }
let!(:project) { create(:project, :public, :repository) }
let!(:commit1) { project.commit("HEAD~2") }
let!(:commit2) { project.commit }
......
require 'spec_helper'
describe Commit, models: true do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:commit) { project.commit }
describe 'modules' do
......@@ -34,7 +34,7 @@
end
describe '#to_reference' do
let(:project) { create(:project, path: 'sample-project') }
let(:project) { create(:project, :repository, path: 'sample-project') }
let(:commit) { project.commit }
it 'returns a String reference to the object' do
......@@ -42,13 +42,13 @@
end
it 'supports a cross-project reference' do
another_project = build(:project, name: 'another-project', namespace: project.namespace)
another_project = build(:project, :repository, name: 'another-project', namespace: project.namespace)
expect(commit.to_reference(another_project)).to eq "sample-project@#{commit.id}"
end
end
describe '#reference_link_text' do
let(:project) { create(:project, path: 'sample-project') }
let(:project) { create(:project, :repository, path: 'sample-project') }
let(:commit) { project.commit }
it 'returns a String reference to the object' do
......@@ -56,7 +56,7 @@
end
it 'supports a cross-project reference' do
another_project = build(:project, name: 'another-project', namespace: project.namespace)
another_project = build(:project, :repository, name: 'another-project', namespace: project.namespace)
expect(commit.reference_link_text(another_project)).to eq "sample-project@#{commit.short_id}"
end
end
......@@ -131,7 +131,7 @@
describe '#closes_issues' do
let(:issue) { create :issue, project: project }
let(:other_project) { create :project, :public }
let(:other_project) { create(:empty_project, :public) }
let(:other_issue) { create :issue, project: other_project }
let(:commiter) { create :user }
......@@ -154,7 +154,7 @@
end
it_behaves_like 'a mentionable' do
subject { create(:project).commit }
subject { create(:project, :repository).commit }
let(:author) { create(:user, email: subject.author_email) }
let(:backref_text) { "commit #{subject.id}" }
......
require 'spec_helper'
describe CommitStatus, models: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline, project: project, sha: project.commit.id)
......
......@@ -3,7 +3,7 @@
describe Compare, models: true do
include RepoHelpers
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:commit) { project.commit }
let(:start_commit) { sample_image_commit }
......
......@@ -301,7 +301,7 @@
end
describe '#labels_array' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:bug) { create(:label, project: project, title: 'bug') }
let(:issue) { create(:issue, project: project) }
......@@ -315,7 +315,7 @@
end
describe '#user_notes_count' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:issue1) { create(:issue, project: project) }
let(:issue2) { create(:issue, project: project) }
......@@ -359,7 +359,7 @@
end
describe ".with_label" do
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:bug) { create(:label, project: project, title: 'bug') }
let(:feature) { create(:label, project: project, title: 'feature') }
let(:enhancement) { create(:label, project: project, title: 'enhancement') }
......
......@@ -13,7 +13,7 @@ def author
end
describe 'references' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:mentionable) { Example.new }
it 'excludes JIRA references' do
......@@ -83,13 +83,13 @@ def referenced_issues(current_user)
end
describe '#create_cross_references!' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:author) { build(:user) }
let(:commit) { project.commit }
let(:commit2) { project.commit }
let!(:issue) do
create(:issue, project: project, description: commit.to_reference)
create(:issue, project: project, description: "See #{commit.to_reference}")
end
it 'correctly removes already-mentioned Commits' do
......@@ -100,7 +100,7 @@ def referenced_issues(current_user)
end
describe '#create_new_cross_references!' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:author) { create(:author) }
let(:issues) { create_list(:issue, 2, project: project, author: author) }
......
......@@ -7,7 +7,7 @@
let(:member) { create(:user) }
let(:guest) { create(:user) }
let(:admin) { create(:admin) }
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:milestone) { create(:milestone, project: project) }
let!(:issue) { create(:issue, project: project, milestone: milestone) }
let!(:security_issue_1) { create(:issue, :confidential, project: project, author: author, milestone: milestone) }
......
require 'spec_helper'
describe ProjectFeaturesCompatibility do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:features) { %w(issues wiki builds merge_requests snippets) }
# We had issues_enabled, snippets_enabled, builds_enabled, merge_requests_enabled and issues_enabled fields on projects table
......
......@@ -3,7 +3,7 @@
describe 'CycleAnalytics#code', feature: true do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:from_date) { 10.days.ago }
let(:user) { create(:user, :admin) }
subject { CycleAnalytics.new(project, from: from_date) }
......
......@@ -3,7 +3,7 @@
describe 'CycleAnalytics#issue', models: true do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:from_date) { 10.days.ago }
let(:user) { create(:user, :admin) }
subject { CycleAnalytics.new(project, from: from_date) }
......
......@@ -3,7 +3,7 @@
describe 'CycleAnalytics#plan', feature: true do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:from_date) { 10.days.ago }
let(:user) { create(:user, :admin) }
subject { CycleAnalytics.new(project, from: from_date) }
......
......@@ -3,7 +3,7 @@
describe 'CycleAnalytics#production', feature: true do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:from_date) { 10.days.ago }
let(:user) { create(:user, :admin) }
subject { CycleAnalytics.new(project, from: from_date) }
......
......@@ -3,7 +3,7 @@
describe 'CycleAnalytics#review', feature: true do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:from_date) { 10.days.ago }
let(:user) { create(:user, :admin) }
subject { CycleAnalytics.new(project, from: from_date) }
......
......@@ -3,9 +3,10 @@
describe 'CycleAnalytics#staging', feature: true do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:from_date) { 10.days.ago }
let(:user) { create(:user, :admin) }
subject { CycleAnalytics.new(project, from: from_date) }
generate_cycle_analytics_spec(
......
......@@ -3,7 +3,7 @@
describe 'CycleAnalytics#test', feature: true do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:from_date) { 10.days.ago }
let(:user) { create(:user, :admin) }
subject { CycleAnalytics.new(project, from: from_date) }
......
......@@ -12,7 +12,7 @@
end
describe "Destroying" do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
subject { create(:deploy_keys_project, project: project) }
let(:deploy_key) { subject.deploy_key }
......@@ -39,7 +39,7 @@
end
context "when the deploy key is used by more than one project" do
let!(:other_project) { create(:project) }
let!(:other_project) { create(:empty_project) }
before do
other_project.deploy_keys << deploy_key
......
......@@ -17,7 +17,7 @@
it { is_expected.to validate_presence_of(:sha) }
describe '#includes_commit?' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:environment) { create(:environment, project: project) }
let(:deployment) do
create(:deployment, environment: environment, sha: project.commit.id)
......
......@@ -3,8 +3,8 @@
describe DiffNote, models: true do
include RepoHelpers
let(:project) { create(:project) }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.project }
let(:commit) { project.commit(sample_commit.id) }
let(:path) { "files/ruby/popen.rb" }
......
......@@ -32,7 +32,7 @@
end
describe '#includes_commit?' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
context 'without a last deployment' do
it "returns false" do
......@@ -81,7 +81,7 @@
end
describe '#first_deployment_for' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let!(:deployment) { create(:deployment, environment: environment, ref: commit.parent.id) }
let!(:deployment1) { create(:deployment, environment: environment, ref: commit.id) }
let(:head_commit) { project.commit }
......
......@@ -27,7 +27,7 @@
end
describe "Push event" do
let(:project) { create(:project, :private) }
let(:project) { create(:empty_project, :private) }
let(:user) { project.owner }
let(:event) { create_event(project, user) }
......@@ -187,7 +187,7 @@
end
context 'merge request diff note event' do
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:merge_request) { create(:merge_request, source_project: project, author: author, assignee: assignee) }
let(:note_on_merge_request) { create(:legacy_diff_note_on_merge_request, noteable: merge_request, project: project) }
let(:target) { note_on_merge_request }
......@@ -202,7 +202,7 @@
end
context 'private project' do
let(:project) { create(:project, :private) }
let(:project) { create(:empty_project, :private) }
it do
expect(event.visible_to_user?(non_member)).to eq false
......
require 'spec_helper'
describe ForkedProjectLink, "add link on fork" do
let(:project_from) { create(:project) }
let(:project_from) { create(:project, :repository) }
let(:namespace) { create(:namespace) }
let(:user) { create(:user, namespace: namespace) }
......@@ -21,7 +21,7 @@
describe '#forked?' do
let(:forked_project_link) { build(:forked_project_link) }
let(:project_from) { create(:project) }
let(:project_from) { create(:project, :repository) }
let(:project_to) { create(:project, forked_project_link: forked_project_link) }
before :each do
......
......@@ -4,9 +4,9 @@
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:group) { create(:group) }
let(:project1) { create(:project, group: group) }
let(:project2) { create(:project, path: 'gitlab-ci', group: group) }
let(:project3) { create(:project, path: 'cookbook-gitlab', group: group) }
let(:project1) { create(:empty_project, group: group) }
let(:project2) { create(:empty_project, path: 'gitlab-ci', group: group) }
let(:project3) { create(:empty_project, path: 'cookbook-gitlab', group: group) }
describe '.build_collection' do
let(:milestone1_due_date) { 2.weeks.from_now.to_date }
......
......@@ -2,7 +2,7 @@
describe GroupMilestone, models: true do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let(:project) { create(:empty_project, group: group) }
let(:project_milestone) do
create(:milestone, title: "Milestone v1.2", project: project)
end
......
require 'spec_helper'
describe Guest, lib: true do
let(:public_project) { create(:project, :public) }
let(:private_project) { create(:project, :private) }
let(:internal_project) { create(:project, :internal) }
let(:public_project) { build_stubbed(:empty_project, :public) }
let(:private_project) { build_stubbed(:empty_project, :private) }
let(:internal_project) { build_stubbed(:empty_project, :internal) }
describe '.can_pull?' do
context 'when project is private' do
......
......@@ -4,7 +4,7 @@
describe "execute" do
let(:system_hook) { create(:system_hook) }
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
let(:project) { create(:empty_project, namespace: user.namespace) }
let(:group) { create(:group) }
before do
......
......@@ -25,7 +25,7 @@
end
describe "execute" do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:project_hook) { create(:project_hook) }
before(:each) do
......
require 'spec_helper'
describe Issue::Metrics, models: true do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
subject { create(:issue, project: project) }
......
......@@ -2,7 +2,7 @@
describe IssueCollection do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:issue1) { create(:issue, project: project) }
let(:issue2) { create(:issue, project: project) }
let(:collection) { described_class.new([issue1, issue2]) }
......
......@@ -35,7 +35,7 @@
end
it 'supports a cross-project reference' do
another_project = build(:project, name: 'another-project', namespace: project.namespace)
another_project = build(:empty_project, name: 'another-project', namespace: project.namespace)
expect(issue.to_reference(another_project)).to eq "sample-project#1"
end
end
......@@ -60,9 +60,9 @@
end
describe '#closed_by_merge_requests' do
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project, state: "opened")}
let(:closed_issue) { build(:issue, project: project, state: "closed")}
let(:project) { create(:project, :repository) }
let(:issue) { create(:issue, project: project)}
let(:closed_issue) { build(:issue, :closed, project: project)}
let(:mr) do
opts = {
......@@ -104,7 +104,7 @@
describe '#referenced_merge_requests' do
it 'returns the referenced merge requests' do
project = create(:project, :public)
project = create(:empty_project, :public)
mr1 = create(:merge_request,
source_project: project,
......@@ -137,7 +137,7 @@
end
context 'user is reporter in project issue belongs to' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:issue) { create(:issue, project: project) }
before { project.team << [user, :reporter] }
......@@ -151,7 +151,7 @@
context 'checking destination project also' do
subject { issue.can_move?(user, to_project) }
let(:to_project) { create(:project) }
let(:to_project) { create(:empty_project) }