Commit 6ab0df04 authored by Illya Klymov's avatar Illya Klymov

Merge branch '324972-hide-suggest-wiki-improvement-button-on-wiki-page-from-auditors' into 'master'

Hide "Suggest wiki improvement" button from Auditors on "Wiki" pages

See merge request gitlab-org/gitlab!56897
parents c788db1e cf103168
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
- elsif @project && can?(current_user, :read_issue, @project) - elsif @project && can?(current_user, :read_issue, @project)
- issues_link = link_to s_('WikiEmptyIssueMessage|issue tracker'), project_issues_path(@project) - issues_link = link_to s_('WikiEmptyIssueMessage|issue tracker'), project_issues_path(@project)
- new_issue_link = link_to s_('WikiEmpty|Suggest wiki improvement'), new_project_issue_path(@project), class: 'btn gl-button btn-confirm', title: s_('WikiEmptyIssueMessage|Suggest wiki improvement')
= render layout: layout_path, locals: { image_path: 'illustrations/wiki_logout_empty.svg' } do = render layout: layout_path, locals: { image_path: 'illustrations/wiki_logout_empty.svg' } do
%h4 %h4
= messages.dig(:issuable, :title) = messages.dig(:issuable, :title)
%p.text-left %p.text-left
= messages.dig(:issuable, :body).html_safe % { issues_link: issues_link } = messages.dig(:issuable, :body).html_safe % { issues_link: issues_link }
= new_issue_link - if show_new_issue_link?(@project)
= link_to s_('WikiEmpty|Suggest wiki improvement'), new_project_issue_path(@project), class: 'btn gl-button btn-confirm', title: s_('WikiEmptyIssueMessage|Suggest wiki improvement')
- else - else
= render layout: layout_path, locals: { image_path: 'illustrations/wiki_logout_empty.svg' } do = render layout: layout_path, locals: { image_path: 'illustrations/wiki_logout_empty.svg' } do
......
---
title: Hide "Suggest wiki improvement" button from Auditors on project wiki page
merge_request: 56897
author:
type: fixed
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Project > User views empty wiki' do
let_it_be(:auditor) { create(:user, auditor: true) }
let_it_be(:project) { create(:project, :private) }
let_it_be(:wiki) { create(:project_wiki, project: project) }
it_behaves_like 'User views empty wiki' do
context 'when signed in user is an Auditor' do
before do
sign_in(auditor)
end
context 'when user is not a member of the project' do
it_behaves_like 'empty wiki message', issuable: true, expect_button: false
end
context 'when user is a member of the project' do
before do
project.add_guest(auditor)
end
it_behaves_like 'empty wiki message', issuable: true, expect_button: true
end
end
end
end
...@@ -20,7 +20,7 @@ RSpec.shared_examples 'User views empty wiki' do ...@@ -20,7 +20,7 @@ RSpec.shared_examples 'User views empty wiki' do
end end
end end
shared_examples 'empty wiki message' do |writable: false, issuable: false, confluence: false| shared_examples 'empty wiki message' do |writable: false, issuable: false, confluence: false, expect_button: true|
# This mirrors the logic in: # This mirrors the logic in:
# - app/views/shared/empty_states/_wikis.html.haml # - app/views/shared/empty_states/_wikis.html.haml
# - WikiHelper#wiki_empty_state_messages # - WikiHelper#wiki_empty_state_messages
...@@ -37,7 +37,7 @@ RSpec.shared_examples 'User views empty wiki' do ...@@ -37,7 +37,7 @@ RSpec.shared_examples 'User views empty wiki' do
if issuable && !writable if issuable && !writable
expect(element).to have_content("improve the wiki for this #{container_name}") expect(element).to have_content("improve the wiki for this #{container_name}")
expect(element).to have_link("issue tracker", href: project_issues_path(project)) expect(element).to have_link("issue tracker", href: project_issues_path(project))
expect(element).to have_link("Suggest wiki improvement", href: new_project_issue_path(project)) expect(element.has_link?("Suggest wiki improvement", href: new_project_issue_path(project))).to be(expect_button)
else else
expect(element).not_to have_content("improve the wiki for this #{container_name}") expect(element).not_to have_content("improve the wiki for this #{container_name}")
expect(element).not_to have_link("issue tracker") expect(element).not_to have_link("issue tracker")
......
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