Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
0
Merge Requests
0
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-shell
Commits
f3512031
Commit
f3512031
authored
Nov 25, 2016
by
Elan Ruusamäe
Committed by
Sean McGivern
Dec 01, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY: add helpers for expect hook calls
parent
37148a6c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
35 deletions
+31
-35
spec/gitlab_custom_hook_spec.rb
spec/gitlab_custom_hook_spec.rb
+31
-35
No files found.
spec/gitlab_custom_hook_spec.rb
View file @
f3512031
...
...
@@ -26,10 +26,10 @@ describe GitlabCustomHook do
end
# global hooks multiplexed
def
create_global_hooks_d
(
which
)
create_hook
(
'hooks/pre-receive.d/
hook'
,
which
)
create_hook
(
'hooks/update.d/
hook'
,
which
)
create_hook
(
'hooks/post-receive.d/
hook'
,
which
)
def
create_global_hooks_d
(
which
,
hook_name
=
'hook'
)
create_hook
(
'hooks/pre-receive.d/
'
+
hook_name
,
which
)
create_hook
(
'hooks/update.d/
'
+
hook_name
,
which
)
create_hook
(
'hooks/post-receive.d/
'
+
hook_name
,
which
)
end
# repo hooks
...
...
@@ -40,10 +40,10 @@ describe GitlabCustomHook do
end
# repo hooks multiplexed
def
create_repo_hooks_d
(
which
)
create_hook
(
'custom_hooks/pre-receive.d/
hook'
,
which
)
create_hook
(
'custom_hooks/update.d/
hook'
,
which
)
create_hook
(
'custom_hooks/post-receive.d/
hook'
,
which
)
def
create_repo_hooks_d
(
which
,
hook_name
=
'hook'
)
create_hook
(
'custom_hooks/pre-receive.d/
'
+
hook_name
,
which
)
create_hook
(
'custom_hooks/update.d/
'
+
hook_name
,
which
)
create_hook
(
'custom_hooks/post-receive.d/
'
+
hook_name
,
which
)
end
def
cleanup_hook_setup
...
...
@@ -51,6 +51,20 @@ describe GitlabCustomHook do
FileUtils
.
rm_rf
(
File
.
join
(
tmp_root_path
,
'hooks'
))
end
def
expect_call_receive_hook
(
path
)
expect
(
gitlab_custom_hook
)
.
to
receive
(
:call_receive_hook
)
.
with
(
hook_path
(
path
),
changes
)
.
and_call_original
end
def
expect_call_update_hook
(
path
)
expect
(
gitlab_custom_hook
)
.
to
receive
(
:system
)
.
with
(
vars
,
hook_path
(
path
),
ref_name
,
old_value
,
new_value
)
.
and_call_original
end
# setup paths
# <repository>.git/hooks/ - symlink to gitlab-shell/hooks global dir
# <repository>.git/hooks/<hook_name> - executed by git itself, this is gitlab-shell/hooks/<hook_name>
...
...
@@ -175,15 +189,9 @@ describe GitlabCustomHook do
end
it
"only executes the global hook"
do
expect
(
gitlab_custom_hook
).
to
receive
(
:call_receive_hook
)
.
with
(
hook_path
(
"custom_hooks/pre-receive.d/hook"
),
changes
)
.
and_call_original
expect
(
gitlab_custom_hook
).
to
receive
(
:system
)
.
with
(
vars
,
hook_path
(
"custom_hooks/update.d/hook"
),
ref_name
,
old_value
,
new_value
)
.
and_call_original
expect
(
gitlab_custom_hook
).
to
receive
(
:call_receive_hook
)
.
with
(
hook_path
(
"custom_hooks/post-receive.d/hook"
),
changes
)
.
and_call_original
expect_call_receive_hook
(
"custom_hooks/pre-receive.d/hook"
)
expect_call_update_hook
(
"custom_hooks/update.d/hook"
)
expect_call_receive_hook
(
"custom_hooks/post-receive.d/hook"
)
gitlab_custom_hook
.
pre_receive
(
changes
)
gitlab_custom_hook
.
update
(
ref_name
,
old_value
,
new_value
)
...
...
@@ -204,24 +212,12 @@ describe GitlabCustomHook do
end
it
"executes the relevant hooks"
do
expect
(
gitlab_custom_hook
).
to
receive
(
:call_receive_hook
)
.
with
(
hook_path
(
"hooks/pre-receive.d/hook"
),
changes
)
.
and_call_original
expect
(
gitlab_custom_hook
).
to
receive
(
:call_receive_hook
)
.
with
(
hook_path
(
"custom_hooks/pre-receive.d/hook"
),
changes
)
.
and_call_original
expect
(
gitlab_custom_hook
).
to
receive
(
:system
)
.
with
(
vars
,
hook_path
(
"hooks/update.d/hook"
),
ref_name
,
old_value
,
new_value
)
.
and_call_original
expect
(
gitlab_custom_hook
).
to
receive
(
:system
)
.
with
(
vars
,
hook_path
(
"custom_hooks/update.d/hook"
),
ref_name
,
old_value
,
new_value
)
.
and_call_original
expect
(
gitlab_custom_hook
).
to
receive
(
:call_receive_hook
)
.
with
(
hook_path
(
"hooks/post-receive.d/hook"
),
changes
)
.
and_call_original
expect
(
gitlab_custom_hook
).
to
receive
(
:call_receive_hook
)
.
with
(
hook_path
(
"custom_hooks/post-receive.d/hook"
),
changes
)
.
and_call_original
expect_call_receive_hook
(
"hooks/pre-receive.d/hook"
)
expect_call_receive_hook
(
"custom_hooks/pre-receive.d/hook"
)
expect_call_update_hook
(
"hooks/update.d/hook"
)
expect_call_update_hook
(
"custom_hooks/update.d/hook"
)
expect_call_receive_hook
(
"hooks/post-receive.d/hook"
)
expect_call_receive_hook
(
"custom_hooks/post-receive.d/hook"
)
gitlab_custom_hook
.
pre_receive
(
changes
)
gitlab_custom_hook
.
update
(
ref_name
,
old_value
,
new_value
)
...
...
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