Commit 26070c97 authored by Thong Kuah's avatar Thong Kuah

Convert some let to let_it_be to save re-creating DB records

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