debian-mirror-gitlab/spec/features/projects/settings/service_desk_setting_spec.rb

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

98 lines
3.4 KiB
Ruby
Raw Permalink Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Service Desk Setting', :js, :clean_gitlab_redis_cache, feature_category: :projects do
2020-07-28 23:09:34 +05:30
let(:project) { create(:project_empty_repo, :private, service_desk_enabled: false) }
let(:presenter) { project.present(current_user: user) }
let(:user) { create(:user) }
before do
project.add_maintainer(user)
sign_in(user)
allow_any_instance_of(Project).to receive(:present).with(current_user: user).and_return(presenter)
2023-06-20 00:43:36 +05:30
allow(::Gitlab::Email::IncomingEmail).to receive(:enabled?) { true }
allow(::Gitlab::Email::IncomingEmail).to receive(:supports_wildcard?) { true }
2020-07-28 23:09:34 +05:30
end
it 'shows activation checkbox' do
2021-02-22 17:27:13 +05:30
visit edit_project_path(project)
2020-07-28 23:09:34 +05:30
expect(page).to have_selector("#service-desk-checkbox")
end
2021-02-22 17:27:13 +05:30
context 'when service_desk_email is disabled' do
before do
2023-06-20 00:43:36 +05:30
allow(::Gitlab::Email::ServiceDeskEmail).to receive(:enabled?).and_return(false)
2021-02-22 17:27:13 +05:30
visit edit_project_path(project)
end
it 'shows incoming email but not project name suffix after activating' do
find("#service-desk-checkbox").click
wait_for_requests
project.reload
expect(project.service_desk_enabled).to be_truthy
expect(project.service_desk_address).to be_present
expect(find('[data-testid="incoming-email"]').value).to eq(project.service_desk_incoming_address)
end
end
context 'when service_desk_email is enabled' do
before do
2023-06-20 00:43:36 +05:30
allow(::Gitlab::Email::ServiceDeskEmail).to receive(:enabled?) { true }
allow(::Gitlab::Email::ServiceDeskEmail).to receive(:address_for_key) { 'address-suffix@example.com' }
2021-02-22 17:27:13 +05:30
visit edit_project_path(project)
end
it 'allows setting of custom address suffix' do
find("#service-desk-checkbox").click
wait_for_requests
project.reload
2021-12-11 22:18:48 +05:30
expect(find('[data-testid="incoming-email"]').value).to eq(project.service_desk_custom_address)
2021-02-22 17:27:13 +05:30
page.within '#js-service-desk' do
fill_in('service-desk-project-suffix', with: 'foo')
click_button 'Save changes'
end
wait_for_requests
expect(find('[data-testid="incoming-email"]').value).to eq('address-suffix@example.com')
end
2021-04-17 20:07:23 +05:30
context 'issue description templates' do
let_it_be(:issuable_project_template_files) do
{
'.gitlab/issue_templates/project-issue-bar.md' => 'Project Issue Template Bar',
'.gitlab/issue_templates/project-issue-foo.md' => 'Project Issue Template Foo'
}
end
let_it_be(:issuable_group_template_files) do
{
'.gitlab/issue_templates/group-issue-bar.md' => 'Group Issue Template Bar',
'.gitlab/issue_templates/group-issue-foo.md' => 'Group Issue Template Foo'
}
end
2022-08-27 11:52:29 +05:30
let_it_be_with_reload(:group) { create(:group) }
2021-04-17 20:07:23 +05:30
let_it_be_with_reload(:project) { create(:project, :custom_repo, group: group, files: issuable_project_template_files) }
let_it_be(:group_template_repo) { create(:project, :custom_repo, group: group, files: issuable_group_template_files) }
before do
stub_licensed_features(custom_file_templates_for_namespace: false, custom_file_templates: false)
group.update_columns(file_template_project_id: group_template_repo.id)
2021-09-04 01:27:46 +05:30
visit edit_project_path(project)
2021-04-17 20:07:23 +05:30
end
2021-09-04 01:27:46 +05:30
it_behaves_like 'issue description templates from current project only'
2021-04-17 20:07:23 +05:30
end
2020-07-28 23:09:34 +05:30
end
end