Commit 67bf6822 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'notification_service_spec_performance' into 'master'

notification_service_spec.rb: Convert some let to let_it_be to save re-creating DB records

See merge request gitlab-org/gitlab!40446
parents b8233eac 26070c97
......@@ -7,6 +7,8 @@ RSpec.describe NotificationService, :mailer do
include ExternalAuthorizationServiceHelpers
include NotificationHelpers
let_it_be(:project, reload: true) { create(:project, :public) }
let(:notification) { described_class.new }
let(:assignee) { create(:user) }
......@@ -513,9 +515,7 @@ RSpec.describe NotificationService, :mailer do
end
context 'confidential issue note' do
let(:project) { create(:project, :public) }
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:guest) { create(:user) }
......@@ -569,7 +569,6 @@ RSpec.describe NotificationService, :mailer do
end
context 'issue note mention', :deliver_mails_inline do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project, assignees: [assignee]) }
let(:mentioned_issue) { create(:issue, assignees: issue.assignees) }
let(:author) { create(:user) }
......@@ -635,7 +634,6 @@ RSpec.describe NotificationService, :mailer do
end
context 'project snippet note', :deliver_mails_inline do
let!(:project) { create(:project, :public) }
let(:snippet) { create(:project_snippet, project: project, author: create(:user)) }
let(:author) { create(:user) }
let(:note) { create(:note_on_project_snippet, author: author, noteable: snippet, project_id: project.id, note: '@all mentioned') }
......@@ -891,11 +889,11 @@ RSpec.describe NotificationService, :mailer do
end
describe 'Participating project notification settings have priority over group and global settings if available', :deliver_mails_inline do
let!(:group) { create(:group) }
let!(:maintainer) { group.add_owner(create(:user, username: 'maintainer')).user }
let!(:user1) { group.add_developer(create(:user, username: 'user_with_project_and_custom_setting')).user }
let_it_be(:group) { create(:group) }
let_it_be(:maintainer) { group.add_owner(create(:user, username: 'maintainer')).user }
let_it_be(:user1) { group.add_developer(create(:user, username: 'user_with_project_and_custom_setting')).user }
let_it_be(:project) { create(:project, :public, namespace: group) }
let(:project) { create(:project, :public, namespace: group) }
let(:issue) { create :issue, project: project, assignees: [assignee], description: '' }
before do
......@@ -1079,7 +1077,6 @@ RSpec.describe NotificationService, :mailer do
context 'confidential issues' do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:guest) { create(:user) }
......@@ -1285,7 +1282,6 @@ RSpec.describe NotificationService, :mailer do
context 'confidential issues' do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:guest) { create(:user) }
......@@ -1338,7 +1334,6 @@ RSpec.describe NotificationService, :mailer do
context 'confidential issues' do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:guest) { create(:user) }
......@@ -1390,7 +1385,6 @@ RSpec.describe NotificationService, :mailer do
context 'confidential issues' do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:guest) { create(:user) }
......@@ -1587,7 +1581,6 @@ RSpec.describe NotificationService, :mailer do
let(:group) { create(:group) }
let(:project) { create(:project, :public, :repository, namespace: group) }
let(:another_project) { create(:project, :public, namespace: group) }
let(:assignee) { create(:user) }
let(:assignees) { Array.wrap(assignee) }
let(:author) { create(:user) }
let(:merge_request) { create :merge_request, author: author, source_project: project, assignees: assignees, description: 'cc @participant' }
......@@ -2079,8 +2072,6 @@ RSpec.describe NotificationService, :mailer do
end
describe 'Projects', :deliver_mails_inline do
let(:project) { create(:project) }
before do
build_team(project)
reset_delivered_emails!
......@@ -2306,7 +2297,6 @@ RSpec.describe NotificationService, :mailer do
end
describe 'ProjectMember', :deliver_mails_inline do
let(:project) { create(:project) }
let(:added_user) { create(:user) }
describe '#new_access_request' do
......@@ -2340,7 +2330,6 @@ RSpec.describe NotificationService, :mailer do
end
it_behaves_like 'sends notification only to a maximum of ten, most recently active project maintainers' do
let(:project) { create(:project, :public) }
let(:notification_trigger) { project.request_access(added_user) }
end
end
......@@ -2470,7 +2459,6 @@ RSpec.describe NotificationService, :mailer do
let(:private_project) { create(:project, :private) }
let(:guest) { create(:user) }
let(:developer) { create(:user) }
let(:assignee) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: private_project, assignees: [assignee]) }
let(:merge_request1) { create(:merge_request, source_project: private_project, assignees: [assignee], description: "cc @#{guest.username}") }
let(:note) { create(:note, noteable: merge_request, project: private_project) }
......@@ -2902,7 +2890,6 @@ RSpec.describe NotificationService, :mailer do
describe 'Repository cleanup', :deliver_mails_inline do
let(:user) { create(:user) }
let(:project) { create(:project) }
describe '#repository_cleanup_success' do
it 'emails the specified user only' do
......@@ -2933,7 +2920,6 @@ RSpec.describe NotificationService, :mailer do
context 'Remote mirror notifications', :deliver_mails_inline do
describe '#remote_mirror_update_failed' do
let(:project) { create(:project) }
let(:remote_mirror) { create(:remote_mirror, project: project) }
let(:u_blocked) { create(:user, :blocked) }
let(:u_silence) { create_user_with_notification(:disabled, 'silent-maintainer', project) }
......
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