Commit f212210d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Optimize system note service specs

parent aacc6110
......@@ -3,9 +3,9 @@ require 'spec_helper'
describe SystemNoteService do
include Gitlab::Routing
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let(:author) { create(:user) }
set(:group) { create(:group) }
set(:project) { create(:project, :repository, group: group) }
set(:author) { create(:user) }
let(:noteable) { create(:issue, project: project) }
let(:issue) { noteable }
......@@ -29,8 +29,7 @@ describe SystemNoteService do
describe '.add_commits' do
subject { described_class.add_commits(noteable, project, author, new_commits, old_commits, oldrev) }
let(:project) { create(:project, :repository) }
let(:noteable) { create(:merge_request, source_project: project) }
let(:noteable) { create(:merge_request, source_project: project, target_project: project) }
let(:new_commits) { noteable.commits }
let(:old_commits) { [] }
let(:oldrev) { nil }
......@@ -185,7 +184,7 @@ describe SystemNoteService do
describe '.change_label' do
subject { described_class.change_label(noteable, project, author, added, removed) }
let(:labels) { create_list(:label, 2) }
let(:labels) { create_list(:label, 2, project: project) }
let(:added) { [] }
let(:removed) { [] }
......@@ -294,7 +293,6 @@ describe SystemNoteService do
end
describe '.merge_when_pipeline_succeeds' do
let(:project) { create(:project, :repository) }
let(:pipeline) { build(:ci_pipeline_without_jobs )}
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
......@@ -312,7 +310,6 @@ describe SystemNoteService do
end
describe '.cancel_merge_when_pipeline_succeeds' do
let(:project) { create(:project, :repository) }
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
end
......@@ -390,7 +387,6 @@ describe SystemNoteService do
describe '.change_branch' do
subject { described_class.change_branch(noteable, project, author, 'target', old_branch, new_branch) }
let(:project) { create(:project, :repository) }
let(:old_branch) { 'old_branch'}
let(:new_branch) { 'new_branch'}
......@@ -408,8 +404,6 @@ describe SystemNoteService do
describe '.change_branch_presence' do
subject { described_class.change_branch_presence(noteable, project, author, :source, 'feature', :delete) }
let(:project) { create(:project, :repository) }
it_behaves_like 'a system note' do
let(:action) { 'branch' }
end
......@@ -424,8 +418,6 @@ describe SystemNoteService do
describe '.new_issue_branch' do
subject { described_class.new_issue_branch(noteable, project, author, "1-mepmep") }
let(:project) { create(:project, :repository) }
it_behaves_like 'a system note' do
let(:action) { 'branch' }
end
......@@ -471,7 +463,7 @@ describe SystemNoteService do
describe 'note_body' do
context 'cross-project' do
let(:project2) { create(:project, :repository) }
let(:project2) { create(:project, :repository) }
let(:mentioner) { create(:issue, project: project2) }
context 'from Commit' do
......@@ -491,7 +483,6 @@ describe SystemNoteService do
context 'within the same project' do
context 'from Commit' do
let(:project) { create(:project, :repository) }
let(:mentioner) { project.repository.commit }
it 'references the mentioning commit' do
......@@ -533,7 +524,6 @@ describe SystemNoteService do
end
context 'when mentioner is a MergeRequest' do
let(:project) { create(:project, :repository) }
let(:mentioner) { create(:merge_request, :simple, source_project: project) }
let(:noteable) { project.commit }
......@@ -561,7 +551,6 @@ describe SystemNoteService do
end
describe '.cross_reference_exists?' do
let(:project) { create(:project, :repository) }
let(:commit0) { project.commit }
let(:commit1) { project.commit('HEAD~2') }
......@@ -899,9 +888,8 @@ describe SystemNoteService do
end
describe '.discussion_continued_in_issue' do
let(:discussion) { create(:diff_note_on_merge_request).to_discussion }
let(:discussion) { create(:diff_note_on_merge_request, project: project).to_discussion }
let(:merge_request) { discussion.noteable }
let(:project) { merge_request.source_project }
let(:issue) { create(:issue, project: project) }
def reloaded_merge_request
......@@ -1023,7 +1011,6 @@ describe SystemNoteService do
end
describe '.add_merge_request_wip_from_commit' do
let(:project) { create(:project, :repository) }
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
end
......@@ -1078,9 +1065,8 @@ describe SystemNoteService do
end
describe '.diff_discussion_outdated' do
let(:discussion) { create(:diff_note_on_merge_request).to_discussion }
let(:discussion) { create(:diff_note_on_merge_request, project: project).to_discussion }
let(:merge_request) { discussion.noteable }
let(:project) { merge_request.source_project }
let(:change_position) { discussion.position }
def reloaded_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