debian-mirror-gitlab/spec/features/projects/issues/email_participants_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.3 KiB
Ruby
Raw Permalink Normal View History

2021-03-08 18:12:59 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-04-23 21:23:45 +05:30
RSpec.describe 'viewing an issue', :js, feature_category: :service_desk do
2021-03-08 18:12:59 +05:30
let_it_be(:user) { create(:user) }
2023-04-23 21:23:45 +05:30
let_it_be(:non_member) { create(:user) }
2021-03-08 18:12:59 +05:30
let_it_be(:project) { create(:project, :public) }
2023-03-04 22:38:38 +05:30
let_it_be_with_refind(:issue) { create(:issue, project: project) }
2021-03-08 18:12:59 +05:30
let_it_be(:note) { create(:note_on_issue, project: project, noteable: issue) }
let_it_be(:participants) { create_list(:issue_email_participant, 4, issue: issue) }
before do
2023-03-04 22:38:38 +05:30
project.add_reporter(user)
2021-03-08 18:12:59 +05:30
end
shared_examples 'email participants warning' do |selector|
it 'shows the correct message' do
expect(find(selector)).to have_content(", and 1 more will be notified of your comment")
end
end
2023-04-23 21:23:45 +05:30
shared_examples 'email participants warning in all editors' do
context 'for a new note' do
it_behaves_like 'email participants warning', '.new-note'
end
context 'for a reply form' do
before do
find('.js-reply-button').click
end
it_behaves_like 'email participants warning', '.note-edit-form'
2023-03-04 22:38:38 +05:30
end
end
context 'when issue is confidential' do
before do
issue.update!(confidential: true)
sign_in(user)
visit project_issue_path(project, issue)
end
2023-04-23 21:23:45 +05:30
it_behaves_like 'email participants warning in all editors'
end
2023-03-04 22:38:38 +05:30
2023-04-23 21:23:45 +05:30
context 'when issue is not confidential' do
context 'with signed in user' do
context 'when user has no role in project' do
before do
sign_in(non_member)
visit project_issue_path(project, issue)
end
it_behaves_like 'email participants warning in all editors'
2023-03-04 22:38:38 +05:30
end
2023-04-23 21:23:45 +05:30
context 'when user has (at least) reporter role in project' do
before do
sign_in(user)
visit project_issue_path(project, issue)
end
it_behaves_like 'email participants warning in all editors'
end
2023-03-04 22:38:38 +05:30
end
2021-03-08 18:12:59 +05:30
end
2023-04-23 21:23:45 +05:30
context 'for feature flags' do
2021-03-08 18:12:59 +05:30
before do
2023-03-04 22:38:38 +05:30
sign_in(user)
2021-03-08 18:12:59 +05:30
end
2023-04-23 21:23:45 +05:30
it 'pushes service_desk_new_note_email_native_attachments feature flag to frontend' do
stub_feature_flags(service_desk_new_note_email_native_attachments: true)
2023-03-04 22:38:38 +05:30
2023-04-23 21:23:45 +05:30
visit project_issue_path(project, issue)
2023-03-04 22:38:38 +05:30
2023-04-23 21:23:45 +05:30
expect(page).to have_pushed_frontend_feature_flags(serviceDeskNewNoteEmailNativeAttachments: true)
2023-03-04 22:38:38 +05:30
end
2021-03-08 18:12:59 +05:30
end
end