diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
commit | 41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch) | |
tree | 9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/requests/api/wikis_spec.rb | |
parent | 0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff) |
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'spec/requests/api/wikis_spec.rb')
-rw-r--r-- | spec/requests/api/wikis_spec.rb | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/spec/requests/api/wikis_spec.rb b/spec/requests/api/wikis_spec.rb index ec34dc7e7a1..06ae61ca5eb 100644 --- a/spec/requests/api/wikis_spec.rb +++ b/spec/requests/api/wikis_spec.rb @@ -31,7 +31,7 @@ RSpec.describe API::Wikis do let(:project_wiki) { create(:project_wiki, project: project, user: user) } let(:payload) { { content: 'content', format: 'rdoc', title: 'title' } } - let(:expected_keys_with_content) { %w(content format slug title) } + let(:expected_keys_with_content) { %w(content format slug title encoding) } let(:expected_keys_without_content) { %w(format slug title) } let(:wiki) { project_wiki } @@ -130,41 +130,42 @@ RSpec.describe API::Wikis do describe 'GET /projects/:id/wikis/:slug' do let(:page) { create(:wiki_page, wiki: project.wiki) } let(:url) { "/projects/#{project.id}/wikis/#{page.slug}" } + let(:params) { {} } + + subject(:request) { get api(url, user), params: params } context 'when wiki is disabled' do let(:project) { project_wiki_disabled } + before do + request + end + context 'when user is guest' do - before do - get api(url) - end + let(:user) { nil } include_examples 'wiki API 404 Project Not Found' end context 'when user is developer' do - before do - get api(url, developer) - end + let(:user) { developer } include_examples 'wiki API 403 Forbidden' end context 'when user is maintainer' do - before do - get api(url, maintainer) - end + let(:user) { maintainer } include_examples 'wiki API 403 Forbidden' end end context 'when wiki is available only for team members' do - let(:project) { create(:project, :wiki_repo, :wiki_private) } + let_it_be_with_reload(:project) { create(:project, :wiki_repo, :wiki_private) } context 'when user is guest' do before do - get api(url) + request end include_examples 'wiki API 404 Project Not Found' @@ -173,7 +174,6 @@ RSpec.describe API::Wikis do context 'when user is developer' do before do project.add_developer(user) - get api(url, user) end include_examples 'wikis API returns wiki page' @@ -181,6 +181,10 @@ RSpec.describe API::Wikis do context 'when page is not existing' do let(:url) { "/projects/#{project.id}/wikis/unknown" } + before do + request + end + include_examples 'wiki API 404 Wiki Page Not Found' end end @@ -188,8 +192,6 @@ RSpec.describe API::Wikis do context 'when user is maintainer' do before do project.add_maintainer(user) - - get api(url, user) end include_examples 'wikis API returns wiki page' @@ -197,17 +199,23 @@ RSpec.describe API::Wikis do context 'when page is not existing' do let(:url) { "/projects/#{project.id}/wikis/unknown" } + before do + request + end + include_examples 'wiki API 404 Wiki Page Not Found' end end end context 'when wiki is available for everyone with access' do - let(:project) { create(:project, :wiki_repo) } + let_it_be_with_reload(:project) { create(:project, :wiki_repo) } context 'when user is guest' do + let(:user) { nil } + before do - get api(url) + request end include_examples 'wiki API 404 Project Not Found' @@ -216,8 +224,6 @@ RSpec.describe API::Wikis do context 'when user is developer' do before do project.add_developer(user) - - get api(url, user) end include_examples 'wikis API returns wiki page' @@ -225,6 +231,10 @@ RSpec.describe API::Wikis do context 'when page is not existing' do let(:url) { "/projects/#{project.id}/wikis/unknown" } + before do + request + end + include_examples 'wiki API 404 Wiki Page Not Found' end end @@ -232,8 +242,6 @@ RSpec.describe API::Wikis do context 'when user is maintainer' do before do project.add_maintainer(user) - - get api(url, user) end include_examples 'wikis API returns wiki page' @@ -241,6 +249,10 @@ RSpec.describe API::Wikis do context 'when page is not existing' do let(:url) { "/projects/#{project.id}/wikis/unknown" } + before do + request + end + include_examples 'wiki API 404 Wiki Page Not Found' end end |