Commit cf103168 authored by peterhegman's avatar peterhegman Committed by Illya Klymov

Apply reviewer feedback

Add spec for when Auditor is part of the project
parent 849e8935
......@@ -7,17 +7,23 @@ RSpec.describe 'Project > User views empty wiki' do
let_it_be(:project) { create(:project, :private) }
let_it_be(:wiki) { create(:project_wiki, project: project) }
context 'when signed in user is an Auditor' do
before do
sign_in(auditor)
end
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
it 'shows empty state without "Suggest wiki improvement" button' do
visit wiki_path(wiki)
context 'when user is a member of the project' do
before do
project.add_guest(auditor)
end
expect(page).to have_content('This project has no wiki pages')
expect(page).to have_content('You must be a project member in order to add wiki pages. If you have suggestions for how to improve the wiki for this project, consider opening an issue in the issue tracker.')
expect(page).not_to have_link('Suggest wiki improvement')
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
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:
# - app/views/shared/empty_states/_wikis.html.haml
# - WikiHelper#wiki_empty_state_messages
......@@ -37,7 +37,7 @@ RSpec.shared_examples 'User views empty wiki' do
if issuable && !writable
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("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
expect(element).not_to have_content("improve the wiki for this #{container_name}")
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