Commit 491f1375 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-empty_project' into 'master'

Use `:empty_project` in Project, User, MergeRequest, and MoveToProjectFinder specs

See merge request !8648
parents 34ef6ce3 a3d8c0b2
...@@ -2,13 +2,13 @@ require 'spec_helper' ...@@ -2,13 +2,13 @@ require 'spec_helper'
describe MoveToProjectFinder do describe MoveToProjectFinder do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:no_access_project) { create(:project) } let(:no_access_project) { create(:empty_project) }
let(:guest_project) { create(:project) } let(:guest_project) { create(:empty_project) }
let(:reporter_project) { create(:project) } let(:reporter_project) { create(:empty_project) }
let(:developer_project) { create(:project) } let(:developer_project) { create(:empty_project) }
let(:master_project) { create(:project) } let(:master_project) { create(:empty_project) }
subject { described_class.new(user) } subject { described_class.new(user) }
...@@ -37,7 +37,7 @@ describe MoveToProjectFinder do ...@@ -37,7 +37,7 @@ describe MoveToProjectFinder do
it 'does not return archived projects' do it 'does not return archived projects' do
reporter_project.team << [user, :reporter] reporter_project.team << [user, :reporter]
reporter_project.update_attributes(archived: true) reporter_project.update_attributes(archived: true)
other_reporter_project = create(:project) other_reporter_project = create(:empty_project)
other_reporter_project.team << [user, :reporter] other_reporter_project.team << [user, :reporter]
expect(subject.execute(project).to_a).to eq([other_reporter_project]) expect(subject.execute(project).to_a).to eq([other_reporter_project])
...@@ -46,7 +46,7 @@ describe MoveToProjectFinder do ...@@ -46,7 +46,7 @@ describe MoveToProjectFinder do
it 'does not return projects for which issues are disabled' do it 'does not return projects for which issues are disabled' do
reporter_project.team << [user, :reporter] reporter_project.team << [user, :reporter]
reporter_project.update_attributes(issues_enabled: false) reporter_project.update_attributes(issues_enabled: false)
other_reporter_project = create(:project) other_reporter_project = create(:empty_project)
other_reporter_project.team << [user, :reporter] other_reporter_project.team << [user, :reporter]
expect(subject.execute(project).to_a).to eq([other_reporter_project]) expect(subject.execute(project).to_a).to eq([other_reporter_project])
...@@ -83,10 +83,10 @@ describe MoveToProjectFinder do ...@@ -83,10 +83,10 @@ describe MoveToProjectFinder do
end end
it 'returns projects matching a search query' do it 'returns projects matching a search query' do
foo_project = create(:project) foo_project = create(:empty_project)
foo_project.team << [user, :master] foo_project.team << [user, :master]
wadus_project = create(:project, name: 'wadus') wadus_project = create(:empty_project, name: 'wadus')
wadus_project.team << [user, :master] wadus_project.team << [user, :master]
expect(subject.execute(project).to_a).to eq([wadus_project, foo_project]) expect(subject.execute(project).to_a).to eq([wadus_project, foo_project])
......
...@@ -65,7 +65,7 @@ describe MergeRequest, models: true do ...@@ -65,7 +65,7 @@ describe MergeRequest, models: true do
end end
describe '#target_branch_sha' do describe '#target_branch_sha' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
subject { create(:merge_request, source_project: project, target_project: project) } subject { create(:merge_request, source_project: project, target_project: project) }
...@@ -150,7 +150,7 @@ describe MergeRequest, models: true do ...@@ -150,7 +150,7 @@ describe MergeRequest, models: true do
end end
it 'supports a cross-project reference' do 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(merge_request.to_reference(another_project)).to eq "sample-project!1" expect(merge_request.to_reference(another_project)).to eq "sample-project!1"
end end
...@@ -245,8 +245,8 @@ describe MergeRequest, models: true do ...@@ -245,8 +245,8 @@ describe MergeRequest, models: true do
describe '#for_fork?' do describe '#for_fork?' do
it 'returns true if the merge request is for a fork' do it 'returns true if the merge request is for a fork' do
subject.source_project = create(:project, namespace: create(:group)) subject.source_project = build_stubbed(:empty_project, namespace: create(:group))
subject.target_project = create(:project, namespace: create(:group)) subject.target_project = build_stubbed(:empty_project, namespace: create(:group))
expect(subject.for_fork?).to be_truthy expect(subject.for_fork?).to be_truthy
end end
...@@ -501,8 +501,8 @@ describe MergeRequest, models: true do ...@@ -501,8 +501,8 @@ describe MergeRequest, models: true do
end end
describe '#diverged_commits_count' do describe '#diverged_commits_count' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:project, :repository, forked_from_project: project) }
context 'when the target branch does not exist anymore' do context 'when the target branch does not exist anymore' do
subject { create(:merge_request, source_project: project, target_project: project) } subject { create(:merge_request, source_project: project, target_project: project) }
...@@ -727,7 +727,7 @@ describe MergeRequest, models: true do ...@@ -727,7 +727,7 @@ describe MergeRequest, models: true do
end end
describe '#participants' do describe '#participants' do
let(:project) { create(:project, :public) } let(:project) { create(:empty_project, :public) }
let(:mr) do let(:mr) do
create(:merge_request, source_project: project, target_project: project) create(:merge_request, source_project: project, target_project: project)
...@@ -768,7 +768,7 @@ describe MergeRequest, models: true do ...@@ -768,7 +768,7 @@ describe MergeRequest, models: true do
end end
describe '#check_if_can_be_merged' do describe '#check_if_can_be_merged' do
let(:project) { create(:project, only_allow_merge_if_build_succeeds: true) } let(:project) { create(:empty_project, only_allow_merge_if_build_succeeds: true) }
subject { create(:merge_request, source_project: project, merge_status: :unchecked) } subject { create(:merge_request, source_project: project, merge_status: :unchecked) }
...@@ -810,7 +810,7 @@ describe MergeRequest, models: true do ...@@ -810,7 +810,7 @@ describe MergeRequest, models: true do
end end
describe '#mergeable?' do describe '#mergeable?' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
subject { create(:merge_request, source_project: project) } subject { create(:merge_request, source_project: project) }
...@@ -830,7 +830,7 @@ describe MergeRequest, models: true do ...@@ -830,7 +830,7 @@ describe MergeRequest, models: true do
end end
describe '#mergeable_state?' do describe '#mergeable_state?' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
subject { create(:merge_request, source_project: project) } subject { create(:merge_request, source_project: project) }
...@@ -957,7 +957,7 @@ describe MergeRequest, models: true do ...@@ -957,7 +957,7 @@ describe MergeRequest, models: true do
let(:merge_request) { create(:merge_request_with_diff_notes, source_project: project) } let(:merge_request) { create(:merge_request_with_diff_notes, source_project: project) }
context 'when project.only_allow_merge_if_all_discussions_are_resolved == true' do context 'when project.only_allow_merge_if_all_discussions_are_resolved == true' do
let(:project) { create(:project, only_allow_merge_if_all_discussions_are_resolved: true) } let(:project) { create(:project, :repository, only_allow_merge_if_all_discussions_are_resolved: true) }
context 'with all discussions resolved' do context 'with all discussions resolved' do
before do before do
...@@ -991,7 +991,7 @@ describe MergeRequest, models: true do ...@@ -991,7 +991,7 @@ describe MergeRequest, models: true do
end end
context 'when project.only_allow_merge_if_all_discussions_are_resolved == false' do context 'when project.only_allow_merge_if_all_discussions_are_resolved == false' do
let(:project) { create(:project, only_allow_merge_if_all_discussions_are_resolved: false) } let(:project) { create(:project, :repository, only_allow_merge_if_all_discussions_are_resolved: false) }
context 'with unresolved discussions' do context 'with unresolved discussions' do
before do before do
...@@ -1006,7 +1006,7 @@ describe MergeRequest, models: true do ...@@ -1006,7 +1006,7 @@ describe MergeRequest, models: true do
end end
describe "#environments" do describe "#environments" do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
context 'with multiple environments' do context 'with multiple environments' do
...@@ -1024,7 +1024,7 @@ describe MergeRequest, models: true do ...@@ -1024,7 +1024,7 @@ describe MergeRequest, models: true do
context 'with environments on source project' do context 'with environments on source project' do
let(:source_project) do let(:source_project) do
create(:project) do |fork_project| create(:project, :repository) do |fork_project|
fork_project.create_forked_project_link(forked_to_project_id: fork_project.id, forked_from_project_id: project.id) fork_project.create_forked_project_link(forked_to_project_id: fork_project.id, forked_from_project_id: project.id)
end end
end end
...@@ -1401,8 +1401,8 @@ describe MergeRequest, models: true do ...@@ -1401,8 +1401,8 @@ describe MergeRequest, models: true do
end end
describe "#source_project_missing?" do describe "#source_project_missing?" do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:empty_project, forked_from_project: project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) } let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) }
...@@ -1439,8 +1439,8 @@ describe MergeRequest, models: true do ...@@ -1439,8 +1439,8 @@ describe MergeRequest, models: true do
end end
describe "#closed_without_fork?" do describe "#closed_without_fork?" do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:empty_project, forked_from_project: project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) } let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) }
...@@ -1485,9 +1485,9 @@ describe MergeRequest, models: true do ...@@ -1485,9 +1485,9 @@ describe MergeRequest, models: true do
end end
context 'forked project' do context 'forked project' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:fork_project) { create(:project, forked_from_project: project, namespace: user.namespace) } let(:fork_project) { create(:empty_project, forked_from_project: project, namespace: user.namespace) }
let!(:merge_request) do let!(:merge_request) do
create(:closed_merge_request, create(:closed_merge_request,
...@@ -1531,7 +1531,7 @@ describe MergeRequest, models: true do ...@@ -1531,7 +1531,7 @@ describe MergeRequest, models: true do
status: status) status: status)
end end
let(:project) { create(:project, :public, only_allow_merge_if_build_succeeds: true) } let(:project) { create(:project, :public, :repository, only_allow_merge_if_build_succeeds: true) }
let(:developer) { create(:user) } let(:developer) { create(:user) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
......
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