2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-29 07:28:49 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
RSpec.describe 'Project > User views empty wiki' do
|
|
|
|
let_it_be(:user) { create(:user) }
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
let(:wiki) { create(:project_wiki, project: project) }
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
it_behaves_like 'User views empty wiki' do
|
|
|
|
context 'when project is public' do
|
|
|
|
let(:project) { create(:project, :public) }
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
it_behaves_like 'empty wiki message', issuable: true
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'when issue tracker is private' do
|
|
|
|
let(:project) { create(:project, :public, :issues_private) }
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
it_behaves_like 'empty wiki message', issuable: false
|
|
|
|
end
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'when issue tracker is disabled' do
|
|
|
|
let(:project) { create(:project, :public, :issues_disabled) }
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
it_behaves_like 'empty wiki message', issuable: false
|
|
|
|
end
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'and user is logged in' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'and user is not a member' do
|
|
|
|
it_behaves_like 'empty wiki message', issuable: true
|
|
|
|
end
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'and user is a member' do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
it_behaves_like 'empty wiki message', writable: true, issuable: true
|
|
|
|
end
|
|
|
|
end
|
2018-05-29 07:28:49 +00:00
|
|
|
end
|
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'when project is private' do
|
|
|
|
let(:project) { create(:project, :private) }
|
2020-06-11 15:08:36 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
it_behaves_like 'wiki is not found'
|
2018-05-29 07:28:49 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'and user is logged in' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
2020-07-14 18:09:55 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'and user is not a member' do
|
|
|
|
it_behaves_like 'wiki is not found'
|
|
|
|
end
|
2020-07-14 18:09:55 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'and user is a member' do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
2020-07-14 18:09:55 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
it_behaves_like 'empty wiki message', writable: true, issuable: true
|
|
|
|
end
|
2020-07-14 18:09:55 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'and user is a maintainer' do
|
|
|
|
before do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
end
|
2020-07-14 18:09:55 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
it_behaves_like 'empty wiki message', writable: true, issuable: true, confluence: true
|
2020-07-14 18:09:55 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
context 'and Confluence is already enabled' do
|
|
|
|
before do
|
2021-06-09 18:11:25 +00:00
|
|
|
create(:confluence_integration, project: project)
|
2020-09-29 09:09:49 +00:00
|
|
|
end
|
2020-07-14 18:09:55 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
it_behaves_like 'empty wiki message', writable: true, issuable: true, confluence: false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-07-14 18:09:55 +00:00
|
|
|
end
|
2018-05-29 07:28:49 +00:00
|
|
|
end
|
|
|
|
end
|