Commit 7945d196 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'fj-improve-some-wiki-specs' into 'master'

Improve some wiki specs

See merge request gitlab-org/gitlab!63150
parents 72ef8dfa 6a498b31
......@@ -17,6 +17,7 @@ RSpec.describe API::Wikis do
include WorkhorseHelpers
let_it_be(:user) { create(:user) }
let(:group) { create(:group, :internal, :wiki_repo) }
let(:wiki) { create(:group_wiki, container: group, user: user) }
let(:payload) { { content: 'content', format: 'rdoc', title: 'title' } }
......@@ -474,8 +475,8 @@ RSpec.describe API::Wikis do
end
context 'when user is owner of parent group' do
let(:namespace) { create(:group).tap { |g| g.add_owner(user) } }
let(:group) { create(:group, :wiki_repo, parent: namespace) }
let_it_be(:namespace) { create(:group).tap { |g| g.add_owner(user) } }
let_it_be(:group) { create(:group, :wiki_repo, parent: namespace) }
include_examples 'wikis API updates wiki page'
end
......@@ -589,8 +590,8 @@ RSpec.describe API::Wikis do
end
context 'when user is owner of parent group' do
let(:namespace) { create(:group).tap { |g| g.add_owner(user) } }
let(:group) { create(:group, :wiki_repo, parent: namespace) }
let_it_be(:namespace) { create(:group).tap { |g| g.add_owner(user) } }
let_it_be(:group) { create(:group, :wiki_repo, parent: namespace) }
before do
delete(api(url, user))
......
......@@ -3,15 +3,12 @@
require 'spec_helper'
RSpec.describe 'Projects > Wiki > User views wiki in project page' do
let(:user) { create(:user) }
before do
project.add_maintainer(user)
sign_in(user)
sign_in(project.owner)
end
context 'when repository is disabled for project' do
let(:project) do
let_it_be(:project) do
create(:project,
:wiki_repo,
:repository_disabled,
......
......@@ -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
......
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