BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
fb03846b
Commit
fb03846b
authored
Feb 28, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '4826-create-empty-wiki-when-it-s-enabled' into 'master'
Make sure wiki exists when it's enabled See merge request gitlab-org/gitlab-ce!17117
parents
ee631557
86de1e29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
0 deletions
+54
-0
update_service.rb
app/services/projects/update_service.rb
+15
-0
4826-create-empty-wiki-when-it-s-enabled.yml
...s/unreleased/4826-create-empty-wiki-when-it-s-enabled.yml
+5
-0
update_service_spec.rb
spec/services/projects/update_service_spec.rb
+34
-0
No files found.
app/services/projects/update_service.rb
View file @
fb03846b
...
...
@@ -15,6 +15,8 @@ module Projects
return
error
(
"Could not set the default branch"
)
unless
project
.
change_head
(
params
[
:default_branch
])
end
ensure_wiki_exists
if
enabling_wiki?
if
project
.
update_attributes
(
params
.
except
(
:default_branch
))
if
project
.
previous_changes
.
include?
(
'path'
)
project
.
rename_repo
...
...
@@ -52,5 +54,18 @@ module Projects
project
.
repository
.
exists?
&&
new_branch
&&
new_branch
!=
project
.
default_branch
end
def
enabling_wiki?
return
false
if
@project
.
wiki_enabled?
params
[
:project_feature_attributes
][
:wiki_access_level
].
to_i
>
ProjectFeature
::
DISABLED
end
def
ensure_wiki_exists
ProjectWiki
.
new
(
project
,
project
.
owner
).
wiki
rescue
ProjectWiki
::
CouldNotCreateWikiError
log_error
(
"Could not create wiki for
#{
project
.
full_name
}
"
)
Gitlab
::
Metrics
.
counter
(
:wiki_can_not_be_created_total
,
'Counts the times we failed to create a wiki'
)
end
end
end
changelogs/unreleased/4826-create-empty-wiki-when-it-s-enabled.yml
0 → 100644
View file @
fb03846b
---
title
:
Make sure wiki exists when it's enabled
merge_request
:
author
:
type
:
fixed
spec/services/projects/update_service_spec.rb
View file @
fb03846b
...
...
@@ -123,6 +123,40 @@ describe Projects::UpdateService do
end
end
context
'when we update project but not enabling a wiki'
do
it
'does not try to create an empty wiki'
do
FileUtils
.
rm_rf
(
project
.
wiki
.
repository
.
path
)
result
=
update_project
(
project
,
user
,
{
name:
'test1'
})
expect
(
result
).
to
eq
({
status: :success
})
expect
(
project
.
wiki_repository_exists?
).
to
be
false
end
end
context
'when enabling a wiki'
do
it
'creates a wiki'
do
project
.
project_feature
.
update
(
wiki_access_level:
ProjectFeature
::
DISABLED
)
FileUtils
.
rm_rf
(
project
.
wiki
.
repository
.
path
)
result
=
update_project
(
project
,
user
,
project_feature_attributes:
{
wiki_access_level:
ProjectFeature
::
ENABLED
})
expect
(
result
).
to
eq
({
status: :success
})
expect
(
project
.
wiki_repository_exists?
).
to
be
true
expect
(
project
.
wiki_enabled?
).
to
be
true
end
it
'logs an error and creates a metric when wiki can not be created'
do
project
.
project_feature
.
update
(
wiki_access_level:
ProjectFeature
::
DISABLED
)
expect_any_instance_of
(
ProjectWiki
).
to
receive
(
:wiki
).
and_raise
(
ProjectWiki
::
CouldNotCreateWikiError
)
expect_any_instance_of
(
described_class
).
to
receive
(
:log_error
).
with
(
"Could not create wiki for
#{
project
.
full_name
}
"
)
expect
(
Gitlab
::
Metrics
).
to
receive
(
:counter
)
update_project
(
project
,
user
,
project_feature_attributes:
{
wiki_access_level:
ProjectFeature
::
ENABLED
})
end
end
context
'when updating a project that contains container images'
do
before
do
stub_container_registry_config
(
enabled:
true
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment