Commit 866b4ba3 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'ld-fix-mutations-to-persisted-project-in-merge_request_spec' into 'master'

Fix places in merge_request_spec.rb that persist changes to the project

See merge request gitlab-org/gitlab!53196
parents 53332c5c 2ace0ad6
...@@ -715,6 +715,10 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -715,6 +715,10 @@ RSpec.describe MergeRequest, factory_default: :keep do
end end
context 'when external issue tracker is enabled' do context 'when external issue tracker is enabled' do
let(:project) { create(:project, :repository) }
subject { create(:merge_request, source_project: project) }
before do before do
subject.project.has_external_issue_tracker = true subject.project.has_external_issue_tracker = true
subject.project.save! subject.project.save!
...@@ -788,6 +792,10 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -788,6 +792,10 @@ RSpec.describe MergeRequest, factory_default: :keep do
end end
context 'when only external issue tracker enabled' do context 'when only external issue tracker enabled' do
let(:project) { create(:project, :repository) }
subject { create(:merge_request, source_project: project) }
before do before do
subject.project.has_external_issue_tracker = true subject.project.has_external_issue_tracker = true
subject.project.issues_enabled = false subject.project.issues_enabled = false
...@@ -1274,8 +1282,6 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -1274,8 +1282,6 @@ RSpec.describe MergeRequest, factory_default: :keep do
let(:mentioned_issue) { create :issue, project: subject.project } let(:mentioned_issue) { create :issue, project: subject.project }
let(:commit) { double('commit', safe_message: "Fixes #{closing_issue.to_reference}") } let(:commit) { double('commit', safe_message: "Fixes #{closing_issue.to_reference}") }
subject { create(:merge_request, source_project: create(:project)) }
it 'detects issues mentioned in description but not closed' do it 'detects issues mentioned in description but not closed' do
subject.project.add_developer(subject.author) subject.project.add_developer(subject.author)
subject.description = "Is related to #{mentioned_issue.to_reference} and #{closing_issue.to_reference}" subject.description = "Is related to #{mentioned_issue.to_reference} and #{closing_issue.to_reference}"
...@@ -1478,8 +1484,6 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -1478,8 +1484,6 @@ RSpec.describe MergeRequest, factory_default: :keep do
end end
describe '#default_merge_commit_message' do describe '#default_merge_commit_message' do
subject { create(:merge_request, source_project: create(:project)) }
it 'includes merge information as the title' do it 'includes merge information as the title' do
request = build(:merge_request, source_branch: 'source', target_branch: 'target') request = build(:merge_request, source_branch: 'source', target_branch: 'target')
...@@ -3424,6 +3428,10 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -3424,6 +3428,10 @@ RSpec.describe MergeRequest, factory_default: :keep do
end end
context 'when resolve_outdated_diff_discussions is set' do context 'when resolve_outdated_diff_discussions is set' do
let(:project) { create(:project, :repository) }
subject { create(:merge_request, source_project: project) }
before do before do
discussion discussion
...@@ -3444,7 +3452,7 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -3444,7 +3452,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
describe '#branch_merge_base_commit' do describe '#branch_merge_base_commit' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
subject { create(:merge_request, :with_diffs, source_project: project) } subject { create(:merge_request, source_project: project) }
context 'source and target branch exist' do context 'source and target branch exist' do
it { expect(subject.branch_merge_base_commit.sha).to eq('ae73cb07c9eeaf35924a10f713b364d32b2dd34f') } it { expect(subject.branch_merge_base_commit.sha).to eq('ae73cb07c9eeaf35924a10f713b364d32b2dd34f') }
...@@ -3467,7 +3475,7 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -3467,7 +3475,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
context "with diffs" do context "with diffs" do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
subject { create(:merge_request, :with_diffs, source_project: project) } subject { create(:merge_request, source_project: project) }
let(:expected_diff_refs) do let(:expected_diff_refs) do
Gitlab::Diff::DiffRefs.new( Gitlab::Diff::DiffRefs.new(
...@@ -3871,7 +3879,7 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -3871,7 +3879,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
describe '#fetch_ref!' do describe '#fetch_ref!' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
subject { create(:merge_request, :with_diffs, source_project: project) } subject { create(:merge_request, source_project: project) }
it 'fetches the ref correctly' do it 'fetches the ref correctly' do
expect { subject.target_project.repository.delete_refs(subject.ref_path) }.not_to raise_error expect { subject.target_project.repository.delete_refs(subject.ref_path) }.not_to raise_error
......
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