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
79467437
Commit
79467437
authored
Mar 30, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cleanup-system-hook-spec' into 'master'
minor cleanup in system_hook_spec Clean up extracted from !3439 See merge request !3459
parents
2fb7392e
4b1ad75a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
27 deletions
+27
-27
system_hook_spec.rb
spec/models/hooks/system_hook_spec.rb
+27
-27
No files found.
spec/models/hooks/system_hook_spec.rb
View file @
79467437
...
@@ -20,24 +20,27 @@ require "spec_helper"
...
@@ -20,24 +20,27 @@ require "spec_helper"
describe
SystemHook
,
models:
true
do
describe
SystemHook
,
models:
true
do
describe
"execute"
do
describe
"execute"
do
before
(
:each
)
do
let
(
:system_hook
)
{
create
(
:system_hook
)
}
@system_hook
=
create
(
:system_hook
)
let
(
:user
)
{
create
(
:user
)
}
WebMock
.
stub_request
(
:post
,
@system_hook
.
url
)
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let
(
:group
)
{
create
(
:group
)
}
before
do
WebMock
.
stub_request
(
:post
,
system_hook
.
url
)
end
end
it
"project_create hook"
do
it
"project_create hook"
do
Projects
::
CreateService
.
new
(
create
(
:user
)
,
name:
'empty'
).
execute
Projects
::
CreateService
.
new
(
user
,
name:
'empty'
).
execute
expect
(
WebMock
).
to
have_requested
(
:post
,
@
system_hook
.
url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
system_hook
.
url
).
with
(
body:
/project_create/
,
body:
/project_create/
,
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
).
once
).
once
end
end
it
"project_destroy hook"
do
it
"project_destroy hook"
do
user
=
create
(
:user
)
project
=
create
(
:empty_project
,
namespace:
user
.
namespace
)
Projects
::
DestroyService
.
new
(
project
,
user
,
{}).
pending_delete!
Projects
::
DestroyService
.
new
(
project
,
user
,
{}).
pending_delete!
expect
(
WebMock
).
to
have_requested
(
:post
,
@system_hook
.
url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
system_hook
.
url
).
with
(
body:
/project_destroy/
,
body:
/project_destroy/
,
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
).
once
).
once
...
@@ -45,37 +48,36 @@ describe SystemHook, models: true do
...
@@ -45,37 +48,36 @@ describe SystemHook, models: true do
it
"user_create hook"
do
it
"user_create hook"
do
create
(
:user
)
create
(
:user
)
expect
(
WebMock
).
to
have_requested
(
:post
,
@system_hook
.
url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
system_hook
.
url
).
with
(
body:
/user_create/
,
body:
/user_create/
,
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
).
once
).
once
end
end
it
"user_destroy hook"
do
it
"user_destroy hook"
do
user
=
create
(
:user
)
user
.
destroy
user
.
destroy
expect
(
WebMock
).
to
have_requested
(
:post
,
@system_hook
.
url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
system_hook
.
url
).
with
(
body:
/user_destroy/
,
body:
/user_destroy/
,
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
).
once
).
once
end
end
it
"project_create hook"
do
it
"project_create hook"
do
user
=
create
(
:user
)
project
=
create
(
:project
)
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
expect
(
WebMock
).
to
have_requested
(
:post
,
@system_hook
.
url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
system_hook
.
url
).
with
(
body:
/user_add_to_team/
,
body:
/user_add_to_team/
,
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
).
once
).
once
end
end
it
"project_destroy hook"
do
it
"project_destroy hook"
do
user
=
create
(
:user
)
project
=
create
(
:project
)
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
project
.
project_members
.
destroy_all
project
.
project_members
.
destroy_all
expect
(
WebMock
).
to
have_requested
(
:post
,
@system_hook
.
url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
system_hook
.
url
).
with
(
body:
/user_remove_from_team/
,
body:
/user_remove_from_team/
,
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
).
once
).
once
...
@@ -83,41 +85,39 @@ describe SystemHook, models: true do
...
@@ -83,41 +85,39 @@ describe SystemHook, models: true do
it
'group create hook'
do
it
'group create hook'
do
create
(
:group
)
create
(
:group
)
expect
(
WebMock
).
to
have_requested
(
:post
,
@system_hook
.
url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
system_hook
.
url
).
with
(
body:
/group_create/
,
body:
/group_create/
,
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
).
once
).
once
end
end
it
'group destroy hook'
do
it
'group destroy hook'
do
group
=
create
(
:group
)
group
.
destroy
group
.
destroy
expect
(
WebMock
).
to
have_requested
(
:post
,
@system_hook
.
url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
system_hook
.
url
).
with
(
body:
/group_destroy/
,
body:
/group_destroy/
,
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
).
once
).
once
end
end
it
'group member create hook'
do
it
'group member create hook'
do
group
=
create
(
:group
)
user
=
create
(
:user
)
group
.
add_master
(
user
)
group
.
add_master
(
user
)
expect
(
WebMock
).
to
have_requested
(
:post
,
@system_hook
.
url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
system_hook
.
url
).
with
(
body:
/user_add_to_group/
,
body:
/user_add_to_group/
,
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
).
once
).
once
end
end
it
'group member destroy hook'
do
it
'group member destroy hook'
do
group
=
create
(
:group
)
user
=
create
(
:user
)
group
.
add_master
(
user
)
group
.
add_master
(
user
)
group
.
group_members
.
destroy_all
group
.
group_members
.
destroy_all
expect
(
WebMock
).
to
have_requested
(
:post
,
@system_hook
.
url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
system_hook
.
url
).
with
(
body:
/user_remove_from_group/
,
body:
/user_remove_from_group/
,
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
headers:
{
'Content-Type'
=>
'application/json'
,
'X-Gitlab-Event'
=>
'System Hook'
}
).
once
).
once
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