Commit 9193d18b authored by Robert Speicher's avatar Robert Speicher

Convert most MergeRequest model specs to use `:empty_project`

parent 36cc3b92
...@@ -66,7 +66,7 @@ describe MergeRequest, models: true do ...@@ -66,7 +66,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) }
...@@ -151,7 +151,7 @@ describe MergeRequest, models: true do ...@@ -151,7 +151,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
...@@ -246,8 +246,8 @@ describe MergeRequest, models: true do ...@@ -246,8 +246,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
...@@ -696,8 +696,8 @@ describe MergeRequest, models: true do ...@@ -696,8 +696,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) }
...@@ -953,7 +953,7 @@ describe MergeRequest, models: true do ...@@ -953,7 +953,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)
...@@ -994,7 +994,7 @@ describe MergeRequest, models: true do ...@@ -994,7 +994,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) }
...@@ -1028,7 +1028,7 @@ describe MergeRequest, models: true do ...@@ -1028,7 +1028,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) }
...@@ -1048,7 +1048,7 @@ describe MergeRequest, models: true do ...@@ -1048,7 +1048,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) }
...@@ -1175,7 +1175,7 @@ describe MergeRequest, models: true do ...@@ -1175,7 +1175,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
...@@ -1209,7 +1209,7 @@ describe MergeRequest, models: true do ...@@ -1209,7 +1209,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
...@@ -1224,7 +1224,7 @@ describe MergeRequest, models: true do ...@@ -1224,7 +1224,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
...@@ -1242,7 +1242,7 @@ describe MergeRequest, models: true do ...@@ -1242,7 +1242,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
...@@ -1825,8 +1825,8 @@ describe MergeRequest, models: true do ...@@ -1825,8 +1825,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) }
...@@ -1863,8 +1863,8 @@ describe MergeRequest, models: true do ...@@ -1863,8 +1863,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) }
...@@ -1909,9 +1909,9 @@ describe MergeRequest, models: true do ...@@ -1909,9 +1909,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,
......
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