Commit 096ed8fa authored by Peter Leitzen's avatar Peter Leitzen

Speed up specs for Issues::CreateService

Reduce the total amount of factories from 260 to 43 cutting
the total amount of events in half.

Queries saved: 6121
parent 697698a6
...@@ -3,18 +3,18 @@ ...@@ -3,18 +3,18 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Issues::CreateService do RSpec.describe Issues::CreateService do
let(:project) { create(:project) } let_it_be_with_reload(:project) { create(:project) }
let(:user) { create(:user) } let_it_be(:user) { create(:user) }
describe '#execute' do describe '#execute' do
let_it_be(:assignee) { create(:user) }
let_it_be(:milestone) { create(:milestone, project: project) }
let(:issue) { described_class.new(project, user, opts).execute } let(:issue) { described_class.new(project, user, opts).execute }
let(:assignee) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
context 'when params are valid' do context 'when params are valid' do
let(:labels) { create_pair(:label, project: project) } let_it_be(:labels) { create_pair(:label, project: project) }
before do before_all do
project.add_maintainer(user) project.add_maintainer(user)
project.add_maintainer(assignee) project.add_maintainer(assignee)
end end
...@@ -66,9 +66,9 @@ RSpec.describe Issues::CreateService do ...@@ -66,9 +66,9 @@ RSpec.describe Issues::CreateService do
end end
context 'when current user cannot admin issues in the project' do context 'when current user cannot admin issues in the project' do
let(:guest) { create(:user) } let_it_be(:guest) { create(:user) }
before do before_all do
project.add_guest(guest) project.add_guest(guest)
end end
...@@ -263,7 +263,7 @@ RSpec.describe Issues::CreateService do ...@@ -263,7 +263,7 @@ RSpec.describe Issues::CreateService do
context 'issue create service' do context 'issue create service' do
context 'assignees' do context 'assignees' do
before do before_all do
project.add_maintainer(user) project.add_maintainer(user)
end end
...@@ -329,7 +329,7 @@ RSpec.describe Issues::CreateService do ...@@ -329,7 +329,7 @@ RSpec.describe Issues::CreateService do
} }
end end
before do before_all do
project.add_maintainer(user) project.add_maintainer(user)
project.add_maintainer(assignee) project.add_maintainer(assignee)
end end
...@@ -343,11 +343,11 @@ RSpec.describe Issues::CreateService do ...@@ -343,11 +343,11 @@ RSpec.describe Issues::CreateService do
end end
context 'resolving discussions' do context 'resolving discussions' do
let(:discussion) { create(:diff_note_on_merge_request).to_discussion } let_it_be(:discussion) { create(:diff_note_on_merge_request).to_discussion }
let(:merge_request) { discussion.noteable } let_it_be(:merge_request) { discussion.noteable }
let(:project) { merge_request.source_project } let_it_be(:project) { merge_request.source_project }
before do before_all do
project.add_maintainer(user) project.add_maintainer(user)
end end
......
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