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 ...@@ -7,17 +7,23 @@ RSpec.describe 'Project > User views empty wiki' do
let_it_be(:project) { create(:project, :private) } let_it_be(:project) { create(:project, :private) }
let_it_be(:wiki) { create(:project_wiki, project: project) } 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 context 'when signed in user is an Auditor' do
before do before do
sign_in(auditor) sign_in(auditor)
end end
it 'shows empty state without "Suggest wiki improvement" button' do context 'when user is not a member of the project' do
visit wiki_path(wiki) it_behaves_like 'empty wiki message', issuable: true, expect_button: false
end
expect(page).to have_content('This project has no wiki pages') context 'when user is a member of the project' do
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.') before do
expect(page).not_to have_link('Suggest wiki improvement') project.add_guest(auditor)
end
it_behaves_like 'empty wiki message', issuable: true, expect_button: true
end
end end
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