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
1eef9e4d
Commit
1eef9e4d
authored
Jun 01, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor wiki page services to avoid merge conflicts
parent
ac2d7687
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
147 additions
and
70 deletions
+147
-70
app/services/ee/wiki_pages/base_service.rb
app/services/ee/wiki_pages/base_service.rb
+28
-0
app/services/wiki_pages/base_service.rb
app/services/wiki_pages/base_service.rb
+2
-10
app/services/wiki_pages/create_service.rb
app/services/wiki_pages/create_service.rb
+0
-1
app/services/wiki_pages/destroy_service.rb
app/services/wiki_pages/destroy_service.rb
+0
-1
app/services/wiki_pages/update_service.rb
app/services/wiki_pages/update_service.rb
+0
-1
spec/services/ee/wiki_pages/create_service_spec.rb
spec/services/ee/wiki_pages/create_service_spec.rb
+41
-0
spec/services/ee/wiki_pages/destroy_service_spec.rb
spec/services/ee/wiki_pages/destroy_service_spec.rb
+34
-0
spec/services/ee/wiki_pages/update_service_spec.rb
spec/services/ee/wiki_pages/update_service_spec.rb
+42
-0
spec/services/wiki_pages/create_service_spec.rb
spec/services/wiki_pages/create_service_spec.rb
+0
-19
spec/services/wiki_pages/destroy_service_spec.rb
spec/services/wiki_pages/destroy_service_spec.rb
+0
-19
spec/services/wiki_pages/update_service_spec.rb
spec/services/wiki_pages/update_service_spec.rb
+0
-19
No files found.
app/services/ee/wiki_pages/base_service.rb
0 → 100644
View file @
1eef9e4d
module
EE
module
WikiPages
# CreateService EE mixin
#
# This module is intended to encapsulate EE-specific service logic
# and be included in the `WikiPages::BaseService` service
module
BaseService
extend
ActiveSupport
::
Concern
private
def
execute_hooks
(
page
,
action
=
'create'
)
super
process_wiki_repository_update
end
def
process_wiki_repository_update
if
::
Gitlab
::
Geo
.
primary?
# Create wiki repository updated event on Geo event log
::
Geo
::
PushEventStore
.
new
(
project
,
source:
Geo
::
PushEvent
::
WIKI
).
create
# Triggers repository update on secondary nodes
::
Gitlab
::
Geo
.
notify_wiki_update
(
project
)
end
end
end
end
end
app/services/wiki_pages/base_service.rb
View file @
1eef9e4d
module
WikiPages
class
BaseService
<
::
BaseService
prepend
EE
::
WikiPages
::
BaseService
def
hook_data
(
page
,
action
)
hook_data
=
{
object_kind:
page
.
class
.
name
.
underscore
,
...
...
@@ -21,15 +23,5 @@ module WikiPages
@project
.
execute_hooks
(
page_data
,
:wiki_page_hooks
)
@project
.
execute_services
(
page_data
,
:wiki_page_hooks
)
end
def
process_wiki_changes
if
Gitlab
::
Geo
.
primary?
# Create wiki update event on Geo event log
Geo
::
PushEventStore
.
new
(
project
,
source:
Geo
::
PushEvent
::
WIKI
).
create
# Triggers repository update on secondary nodes
Gitlab
::
Geo
.
notify_wiki_update
(
project
)
end
end
end
end
app/services/wiki_pages/create_service.rb
View file @
1eef9e4d
...
...
@@ -6,7 +6,6 @@ module WikiPages
if
page
.
create
(
@params
)
execute_hooks
(
page
,
'create'
)
process_wiki_changes
end
page
...
...
app/services/wiki_pages/destroy_service.rb
View file @
1eef9e4d
...
...
@@ -3,7 +3,6 @@ module WikiPages
def
execute
(
page
)
if
page
&
.
delete
execute_hooks
(
page
,
'delete'
)
process_wiki_changes
end
page
...
...
app/services/wiki_pages/update_service.rb
View file @
1eef9e4d
...
...
@@ -3,7 +3,6 @@ module WikiPages
def
execute
(
page
)
if
page
.
update
(
@params
[
:content
],
@params
[
:format
],
@params
[
:message
])
execute_hooks
(
page
,
'update'
)
process_wiki_changes
end
page
...
...
spec/services/ee/wiki_pages/create_service_spec.rb
0 → 100644
View file @
1eef9e4d
require
'spec_helper'
describe
WikiPages
::
CreateService
,
services:
true
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:opts
)
do
{
title:
'Title'
,
content:
'Content for wiki page'
,
format:
'markdown'
}
end
subject
(
:service
)
{
described_class
.
new
(
project
,
user
,
opts
)
}
before
do
project
.
add_master
(
user
)
end
describe
'#execute'
do
context
'when running on a Geo primary node'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
end
it
'triggers Geo::PushEventStore when Geo is enabled'
do
expect
(
Geo
::
PushEventStore
).
to
receive
(
:new
).
with
(
instance_of
(
Project
),
source:
Geo
::
PushEvent
::
WIKI
).
and_call_original
expect_any_instance_of
(
Geo
::
PushEventStore
).
to
receive
(
:create
)
service
.
execute
end
it
'triggers wiki update on secondary nodes'
do
expect
(
Gitlab
::
Geo
).
to
receive
(
:notify_wiki_update
).
with
(
instance_of
(
Project
))
service
.
execute
end
end
end
end
spec/services/ee/wiki_pages/destroy_service_spec.rb
0 → 100644
View file @
1eef9e4d
require
'spec_helper'
describe
WikiPages
::
DestroyService
,
services:
true
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:page
)
{
create
(
:wiki_page
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
before
do
project
.
add_master
(
user
)
end
describe
'#execute'
do
context
'when running on a Geo primary node'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
end
it
'triggers Geo::PushEventStore when Geo is enabled'
do
expect
(
Geo
::
PushEventStore
).
to
receive
(
:new
).
with
(
instance_of
(
Project
),
source:
Geo
::
PushEvent
::
WIKI
).
and_call_original
expect_any_instance_of
(
Geo
::
PushEventStore
).
to
receive
(
:create
)
service
.
execute
(
page
)
end
it
'triggers wiki update on secondary nodes'
do
expect
(
Gitlab
::
Geo
).
to
receive
(
:notify_wiki_update
).
with
(
instance_of
(
Project
))
service
.
execute
(
page
)
end
end
end
end
spec/services/ee/wiki_pages/update_service_spec.rb
0 → 100644
View file @
1eef9e4d
require
'spec_helper'
describe
WikiPages
::
UpdateService
,
services:
true
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:page
)
{
create
(
:wiki_page
)
}
let
(
:opts
)
do
{
content:
'New content for wiki page'
,
format:
'markdown'
,
message:
'New wiki message'
}
end
subject
(
:service
)
{
described_class
.
new
(
project
,
user
,
opts
)
}
before
do
project
.
add_master
(
user
)
end
describe
'#execute'
do
context
'when running on a Geo primary node'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
end
it
'triggers Geo::PushEventStore when Geo is enabled'
do
expect
(
Geo
::
PushEventStore
).
to
receive
(
:new
).
with
(
instance_of
(
Project
),
source:
Geo
::
PushEvent
::
WIKI
).
and_call_original
expect_any_instance_of
(
Geo
::
PushEventStore
).
to
receive
(
:create
)
service
.
execute
(
page
)
end
it
'triggers wiki update on secondary nodes'
do
expect
(
Gitlab
::
Geo
).
to
receive
(
:notify_wiki_update
).
with
(
instance_of
(
Project
))
service
.
execute
(
page
)
end
end
end
end
spec/services/wiki_pages/create_service_spec.rb
View file @
1eef9e4d
...
...
@@ -31,24 +31,5 @@ describe WikiPages::CreateService, services: true do
service
.
execute
end
context
'when running on a Geo primary node'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
end
it
'triggers Geo::PushEventStore when Geo is enabled'
do
expect
(
Geo
::
PushEventStore
).
to
receive
(
:new
).
with
(
instance_of
(
Project
),
source:
Geo
::
PushEvent
::
WIKI
).
and_call_original
expect_any_instance_of
(
Geo
::
PushEventStore
).
to
receive
(
:create
)
service
.
execute
end
it
'triggers wiki update on secondary nodes'
do
expect
(
Gitlab
::
Geo
).
to
receive
(
:notify_wiki_update
).
with
(
instance_of
(
Project
))
service
.
execute
end
end
end
end
spec/services/wiki_pages/destroy_service_spec.rb
View file @
1eef9e4d
...
...
@@ -17,24 +17,5 @@ describe WikiPages::DestroyService, services: true do
service
.
execute
(
page
)
end
context
'when running on a Geo primary node'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
end
it
'triggers Geo::PushEventStore when Geo is enabled'
do
expect
(
Geo
::
PushEventStore
).
to
receive
(
:new
).
with
(
instance_of
(
Project
),
source:
Geo
::
PushEvent
::
WIKI
).
and_call_original
expect_any_instance_of
(
Geo
::
PushEventStore
).
to
receive
(
:create
)
service
.
execute
(
page
)
end
it
'triggers wiki update on secondary nodes'
do
expect
(
Gitlab
::
Geo
).
to
receive
(
:notify_wiki_update
).
with
(
instance_of
(
Project
))
service
.
execute
(
page
)
end
end
end
end
spec/services/wiki_pages/update_service_spec.rb
View file @
1eef9e4d
...
...
@@ -32,24 +32,5 @@ describe WikiPages::UpdateService, services: true do
service
.
execute
(
page
)
end
context
'when running on a Geo primary node'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
end
it
'triggers Geo::PushEventStore when Geo is enabled'
do
expect
(
Geo
::
PushEventStore
).
to
receive
(
:new
).
with
(
instance_of
(
Project
),
source:
Geo
::
PushEvent
::
WIKI
).
and_call_original
expect_any_instance_of
(
Geo
::
PushEventStore
).
to
receive
(
:create
)
service
.
execute
(
page
)
end
it
'triggers wiki update on secondary nodes'
do
expect
(
Gitlab
::
Geo
).
to
receive
(
:notify_wiki_update
).
with
(
instance_of
(
Project
))
service
.
execute
(
page
)
end
end
end
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