Commit b12fcd0e authored by Jarka Košanová's avatar Jarka Košanová

Allow reporters to see the service desk email address

Changelog: added
parent ce274223
- service_desk_enabled = @project.service_desk_enabled?
- can_edit_project_settings = can?(current_user, :admin_project, @project)
- can_admin_issues = can?(current_user, :admin_issue, @project)
- title_text = s_("ServiceDesk|Use Service Desk to connect with your users and offer customer support through email right inside GitLab")
.non-empty-state.media
......@@ -10,7 +11,7 @@
.gl-mt-3.gl-ml-3
%h5= title_text
- if can_edit_project_settings && service_desk_enabled
- if can_admin_issues && service_desk_enabled
%p
= s_("ServiceDesk|Your users can send emails to this address:")
%code= @project.service_desk_address
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'projects/issues/_service_desk_info_content' do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:service_desk_address) { 'address@example.com' }
before do
assign(:project, project)
allow(project).to receive(:service_desk_address).and_return(service_desk_address)
allow(view).to receive(:current_user).and_return(user)
end
context 'when service desk is disabled' do
before do
allow(project).to receive(:service_desk_enabled?).and_return(false)
end
context 'when the logged user is at least maintainer' do
before do
project.add_maintainer(user)
end
it 'shows the info including the project settings link', :aggregate_failures do
render
expect(rendered).to have_text('Use Service Desk')
expect(rendered).not_to have_text(service_desk_address)
expect(rendered).to have_link(href: "/#{project.full_path}/edit")
end
end
context 'when the logged user is at only a developer' do
before do
project.add_developer(user)
end
it 'shows the info without the project settings link', :aggregate_failures do
render
expect(rendered).to have_text('Use Service Desk')
expect(rendered).not_to have_text(service_desk_address)
expect(rendered).not_to have_link(href: "/#{project.full_path}/edit")
end
end
end
context 'when service desk is enabled' do
before do
allow(project).to receive(:service_desk_enabled?).and_return(true)
end
context 'when the logged user is at least reporter' do
before do
project.add_reporter(user)
end
it 'shows the info including the email address', :aggregate_failures do
render
expect(rendered).to have_text('Use Service Desk')
expect(rendered).to have_text(service_desk_address)
expect(rendered).not_to have_link(href: "/#{project.full_path}/edit")
end
end
context 'when the logged user is at only a guest' do
before do
project.add_guest(user)
end
it 'shows the info without the email address', :aggregate_failures do
render
expect(rendered).to have_text('Use Service Desk')
expect(rendered).not_to have_text(service_desk_address)
expect(rendered).not_to have_link(href: "/#{project.full_path}/edit")
end
end
context 'when user is not logged in' do
let(:user) { nil }
it 'shows the info without the email address', :aggregate_failures do
render
expect(rendered).to have_text('Use Service Desk')
expect(rendered).not_to have_text(service_desk_address)
expect(rendered).not_to have_link(href: "/#{project.full_path}/edit")
end
end
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