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
aea03d7c
Commit
aea03d7c
authored
Jun 02, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'port-refactor-wiki-page-services' into 'master'
Refactor specs for WikiPage services See merge request !11862
parents
57dddacf
afd94480
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
48 deletions
+53
-48
create_service_spec.rb
spec/services/wiki_pages/create_service_spec.rb
+21
-19
destroy_service_spec.rb
spec/services/wiki_pages/destroy_service_spec.rb
+10
-9
update_service_spec.rb
spec/services/wiki_pages/update_service_spec.rb
+22
-20
No files found.
spec/services/wiki_pages/create_service_spec.rb
View file @
aea03d7c
...
@@ -3,6 +3,7 @@ require 'spec_helper'
...
@@ -3,6 +3,7 @@ require 'spec_helper'
describe
WikiPages
::
CreateService
,
services:
true
do
describe
WikiPages
::
CreateService
,
services:
true
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:opts
)
do
let
(
:opts
)
do
{
{
title:
'Title'
,
title:
'Title'
,
...
@@ -10,27 +11,28 @@ describe WikiPages::CreateService, services: true do
...
@@ -10,27 +11,28 @@ describe WikiPages::CreateService, services: true do
format:
'markdown'
format:
'markdown'
}
}
end
end
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
opts
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
user
,
opts
)
}
before
do
project
.
add_developer
(
user
)
end
describe
'#execute'
do
describe
'#execute'
do
context
"valid params"
do
it
'creates wiki page with valid attributes'
do
before
do
page
=
service
.
execute
allow
(
service
).
to
receive
(
:execute_hooks
)
project
.
add_master
(
user
)
expect
(
page
).
to
be_valid
end
expect
(
page
.
title
).
to
eq
(
opts
[
:title
])
expect
(
page
.
content
).
to
eq
(
opts
[
:content
])
subject
{
service
.
execute
}
expect
(
page
.
format
).
to
eq
(
opts
[
:format
].
to_sym
)
end
it
'creates a valid wiki page'
do
is_expected
.
to
be_valid
it
'executes webhooks'
do
expect
(
subject
.
title
).
to
eq
(
opts
[
:title
])
expect
(
service
).
to
receive
(
:execute_hooks
).
once
expect
(
subject
.
content
).
to
eq
(
opts
[
:content
])
.
with
(
instance_of
(
WikiPage
),
'create'
)
expect
(
subject
.
format
).
to
eq
(
opts
[
:format
].
to_sym
)
end
service
.
execute
it
'executes webhooks'
do
expect
(
service
).
to
have_received
(
:execute_hooks
).
once
.
with
(
subject
,
'create'
)
end
end
end
end
end
end
end
spec/services/wiki_pages/destroy_service_spec.rb
View file @
aea03d7c
...
@@ -3,19 +3,20 @@ require 'spec_helper'
...
@@ -3,19 +3,20 @@ require 'spec_helper'
describe
WikiPages
::
DestroyService
,
services:
true
do
describe
WikiPages
::
DestroyService
,
services:
true
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:wiki_page
)
{
create
(
:wiki_page
)
}
let
(
:page
)
{
create
(
:wiki_page
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
describe
'#execute'
do
subject
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
before
do
allow
(
service
).
to
receive
(
:execute_hooks
)
project
.
add_master
(
user
)
end
before
do
project
.
add_developer
(
user
)
end
describe
'#execute'
do
it
'executes webhooks'
do
it
'executes webhooks'
do
service
.
execute
(
wiki_page
)
expect
(
service
).
to
receive
(
:execute_hooks
).
once
.
with
(
instance_of
(
WikiPage
),
'delete'
)
expect
(
service
).
to
have_received
(
:execute_hooks
).
once
.
with
(
wiki_page
,
'delete'
)
service
.
execute
(
page
)
end
end
end
end
end
end
spec/services/wiki_pages/update_service_spec.rb
View file @
aea03d7c
...
@@ -3,7 +3,8 @@ require 'spec_helper'
...
@@ -3,7 +3,8 @@ require 'spec_helper'
describe
WikiPages
::
UpdateService
,
services:
true
do
describe
WikiPages
::
UpdateService
,
services:
true
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:wiki_page
)
{
create
(
:wiki_page
)
}
let
(
:page
)
{
create
(
:wiki_page
)
}
let
(
:opts
)
do
let
(
:opts
)
do
{
{
content:
'New content for wiki page'
,
content:
'New content for wiki page'
,
...
@@ -11,27 +12,28 @@ describe WikiPages::UpdateService, services: true do
...
@@ -11,27 +12,28 @@ describe WikiPages::UpdateService, services: true do
message:
'New wiki message'
message:
'New wiki message'
}
}
end
end
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
opts
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
user
,
opts
)
}
before
do
project
.
add_developer
(
user
)
end
describe
'#execute'
do
describe
'#execute'
do
context
"valid params"
do
it
'updates the wiki page'
do
before
do
updated_page
=
service
.
execute
(
page
)
allow
(
service
).
to
receive
(
:execute_hooks
)
project
.
add_master
(
user
)
expect
(
updated_page
).
to
be_valid
end
expect
(
updated_page
.
message
).
to
eq
(
opts
[
:message
])
expect
(
updated_page
.
content
).
to
eq
(
opts
[
:content
])
subject
{
service
.
execute
(
wiki_page
)
}
expect
(
updated_page
.
format
).
to
eq
(
opts
[
:format
].
to_sym
)
end
it
'updates the wiki page'
do
is_expected
.
to
be_valid
it
'executes webhooks'
do
expect
(
subject
.
content
).
to
eq
(
opts
[
:content
])
expect
(
service
).
to
receive
(
:execute_hooks
).
once
expect
(
subject
.
format
).
to
eq
(
opts
[
:format
].
to_sym
)
.
with
(
instance_of
(
WikiPage
),
'update'
)
expect
(
subject
.
message
).
to
eq
(
opts
[
:message
])
end
service
.
execute
(
page
)
it
'executes webhooks'
do
expect
(
service
).
to
have_received
(
:execute_hooks
).
once
.
with
(
subject
,
'update'
)
end
end
end
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