Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f353d63f
Commit
f353d63f
authored
Mar 27, 2018
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trigger wiki sync when enabled
parent
e46cd8b5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
2 deletions
+89
-2
ee/app/services/ee/projects/update_service.rb
ee/app/services/ee/projects/update_service.rb
+11
-2
ee/changelogs/unreleased/mk-geo-sync-reenabled-wikis.yml
ee/changelogs/unreleased/mk-geo-sync-reenabled-wikis.yml
+5
-0
ee/spec/services/projects/update_service_spec.rb
ee/spec/services/projects/update_service_spec.rb
+73
-0
No files found.
ee/app/services/ee/projects/update_service.rb
View file @
f353d63f
...
...
@@ -14,12 +14,17 @@ module EE
end
should_remove_old_approvers
=
params
.
delete
(
:remove_old_approvers
)
wiki_was_enabled
=
project
.
wiki_enabled?
result
=
super
cleanup_approvers
(
project
)
if
should_remove_old_approvers
&&
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
cleanup_approvers
(
project
)
if
should_remove_old_approvers
log_audit_events
if
result
[
:status
]
==
:success
log_audit_events
sync_wiki_on_enable
if
!
wiki_was_enabled
&&
project
.
wiki_enabled?
end
result
end
...
...
@@ -36,6 +41,10 @@ module EE
def
log_audit_events
EE
::
Audit
::
ProjectChangesAuditor
.
new
(
current_user
,
project
).
execute
end
def
sync_wiki_on_enable
::
Geo
::
RepositoryUpdatedService
.
new
(
project
,
source:
::
Geo
::
RepositoryUpdatedEvent
::
WIKI
).
execute
end
end
end
end
ee/changelogs/unreleased/mk-geo-sync-reenabled-wikis.yml
0 → 100644
View file @
f353d63f
---
title
:
'
Geo:
Sync
wiki
when
it
is
enabled'
merge_request
:
5139
author
:
type
:
fixed
ee/spec/services/projects/update_service_spec.rb
View file @
f353d63f
require
'spec_helper'
describe
Projects
::
UpdateService
,
'#execute'
do
include
EE
::
GeoHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
creator:
user
,
namespace:
user
.
namespace
)
}
...
...
@@ -123,6 +125,77 @@ describe Projects::UpdateService, '#execute' do
end
end
context
'triggering wiki Geo syncs'
,
:geo
do
context
'on a Geo primary'
do
set
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
set
(
:secondary
)
{
create
(
:geo_node
)
}
before
do
stub_current_geo_node
(
primary
)
end
context
'when enabling a wiki'
do
it
'creates a RepositoryUpdatedEvent'
do
project
.
project_feature
.
update
(
wiki_access_level:
ProjectFeature
::
DISABLED
)
project
.
reload
expect
do
result
=
update_project
(
project
,
user
,
project_feature_attributes:
{
wiki_access_level:
ProjectFeature
::
ENABLED
})
expect
(
result
).
to
eq
({
status: :success
})
end
.
to
change
{
Geo
::
RepositoryUpdatedEvent
.
count
}.
by
(
1
)
expect
(
project
.
wiki_enabled?
).
to
be
true
end
end
context
'when we update project but not enabling a wiki'
do
context
'when the wiki is disabled'
do
it
'does not create a RepositoryUpdatedEvent'
do
project
.
project_feature
.
update
(
wiki_access_level:
ProjectFeature
::
DISABLED
)
expect
do
result
=
update_project
(
project
,
user
,
{
name:
'test1'
})
expect
(
result
).
to
eq
({
status: :success
})
end
.
not_to
change
{
Geo
::
RepositoryUpdatedEvent
.
count
}
expect
(
project
.
wiki_enabled?
).
to
be
false
end
end
context
'when the wiki was already enabled'
do
it
'does not create a RepositoryUpdatedEvent'
do
project
.
project_feature
.
update
(
wiki_access_level:
ProjectFeature
::
ENABLED
)
expect
do
result
=
update_project
(
project
,
user
,
{
name:
'test1'
})
expect
(
result
).
to
eq
({
status: :success
})
end
.
not_to
change
{
Geo
::
RepositoryUpdatedEvent
.
count
}
expect
(
project
.
wiki_enabled?
).
to
be
true
end
end
end
end
context
'not on a Geo node'
do
before
do
allow
(
::
Gitlab
::
Geo
).
to
receive
(
:current_node
).
and_return
(
nil
)
end
it
'does not create a RepositoryUpdatedEvent when enabling a wiki'
do
project
.
project_feature
.
update
(
wiki_access_level:
ProjectFeature
::
DISABLED
)
project
.
reload
expect
do
result
=
update_project
(
project
,
user
,
project_feature_attributes:
{
wiki_access_level:
ProjectFeature
::
ENABLED
})
expect
(
result
).
to
eq
({
status: :success
})
end
.
not_to
change
{
Geo
::
RepositoryUpdatedEvent
.
count
}
expect
(
project
.
wiki_enabled?
).
to
be
true
end
end
end
def
update_project
(
project
,
user
,
opts
)
Projects
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
end
...
...
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