diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/requests/api/wikis_spec.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/requests/api/wikis_spec.rb')
-rw-r--r-- | spec/requests/api/wikis_spec.rb | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/spec/requests/api/wikis_spec.rb b/spec/requests/api/wikis_spec.rb index d35aab40ca9..64fde3db19f 100644 --- a/spec/requests/api/wikis_spec.rb +++ b/spec/requests/api/wikis_spec.rb @@ -16,8 +16,19 @@ RSpec.describe API::Wikis do include WorkhorseHelpers include AfterNextHelpers - let(:user) { create(:user) } - let(:group) { create(:group).tap { |g| g.add_owner(user) } } + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group).tap { |g| g.add_owner(user) } } + let_it_be(:group_project) { create(:project, :wiki_repo, namespace: group) } + + let_it_be(:developer) { create(:user) } + let_it_be(:maintainer) { create(:user) } + let_it_be(:project_wiki_disabled) do + create(:project, :wiki_repo, :wiki_disabled).tap do |project| + project.add_developer(developer) + project.add_maintainer(maintainer) + end + end + 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) } @@ -32,7 +43,7 @@ RSpec.describe API::Wikis do let(:url) { "/projects/#{project.id}/wikis" } context 'when wiki is disabled' do - let(:project) { create(:project, :wiki_repo, :wiki_disabled) } + let(:project) { project_wiki_disabled } context 'when user is guest' do before do @@ -44,9 +55,7 @@ RSpec.describe API::Wikis do context 'when user is developer' do before do - project.add_developer(user) - - get api(url, user) + get api(url, developer) end include_examples 'wiki API 403 Forbidden' @@ -54,9 +63,7 @@ RSpec.describe API::Wikis do context 'when user is maintainer' do before do - project.add_maintainer(user) - - get api(url, user) + get api(url, maintainer) end include_examples 'wiki API 403 Forbidden' @@ -125,7 +132,7 @@ RSpec.describe API::Wikis do let(:url) { "/projects/#{project.id}/wikis/#{page.slug}" } context 'when wiki is disabled' do - let(:project) { create(:project, :wiki_repo, :wiki_disabled) } + let(:project) { project_wiki_disabled } context 'when user is guest' do before do @@ -137,9 +144,7 @@ RSpec.describe API::Wikis do context 'when user is developer' do before do - project.add_developer(user) - - get api(url, user) + get api(url, developer) end include_examples 'wiki API 403 Forbidden' @@ -147,9 +152,7 @@ RSpec.describe API::Wikis do context 'when user is maintainer' do before do - project.add_maintainer(user) - - get api(url, user) + get api(url, maintainer) end include_examples 'wiki API 403 Forbidden' @@ -249,7 +252,7 @@ RSpec.describe API::Wikis do let(:url) { "/projects/#{project.id}/wikis" } context 'when wiki is disabled' do - let(:project) { create(:project, :wiki_disabled, :wiki_repo) } + let(:project) { project_wiki_disabled } context 'when user is guest' do before do @@ -261,8 +264,7 @@ RSpec.describe API::Wikis do context 'when user is developer' do before do - project.add_developer(user) - post(api(url, user), params: payload) + post(api(url, developer), params: payload) end include_examples 'wiki API 403 Forbidden' @@ -270,8 +272,7 @@ RSpec.describe API::Wikis do context 'when user is maintainer' do before do - project.add_maintainer(user) - post(api(url, user), params: payload) + post(api(url, maintainer), params: payload) end include_examples 'wiki API 403 Forbidden' @@ -469,7 +470,7 @@ RSpec.describe API::Wikis do end context 'when wiki belongs to a group project' do - let(:project) { create(:project, :wiki_repo, namespace: group) } + let(:project) { group_project } include_examples 'wikis API updates wiki page' end |