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
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
Boxiang Sun
gitlab-ce
Commits
caadfcde
Commit
caadfcde
authored
May 21, 2018
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport changes in app/services/test_hooks/project_service.rb
parent
fe0ebf76
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
app/services/test_hooks/project_service.rb
app/services/test_hooks/project_service.rb
+3
-1
spec/services/test_hooks/project_service_spec.rb
spec/services/test_hooks/project_service_spec.rb
+8
-2
No files found.
app/services/test_hooks/project_service.rb
View file @
caadfcde
module
TestHooks
module
TestHooks
class
ProjectService
<
TestHooks
::
BaseService
class
ProjectService
<
TestHooks
::
BaseService
private
attr_writer
:project
def
project
def
project
@project
||=
hook
.
project
@project
||=
hook
.
project
end
end
private
def
push_events_data
def
push_events_data
throw
(
:validation_error
,
'Ensure the project has at least one commit.'
)
if
project
.
empty_repo?
throw
(
:validation_error
,
'Ensure the project has at least one commit.'
)
if
project
.
empty_repo?
...
...
spec/services/test_hooks/project_service_spec.rb
View file @
caadfcde
...
@@ -6,13 +6,19 @@ describe TestHooks::ProjectService do
...
@@ -6,13 +6,19 @@ describe TestHooks::ProjectService do
describe
'#execute'
do
describe
'#execute'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:hook
)
{
create
(
:project_hook
,
project:
project
)
}
let
(
:hook
)
{
create
(
:project_hook
,
project:
project
)
}
let
(
:trigger
)
{
'not_implemented_events'
}
let
(
:service
)
{
described_class
.
new
(
hook
,
current_user
,
trigger
)
}
let
(
:service
)
{
described_class
.
new
(
hook
,
current_user
,
trigger
)
}
let
(
:sample_data
)
{
{
data:
'sample'
}
}
let
(
:sample_data
)
{
{
data:
'sample'
}
}
let
(
:success_result
)
{
{
status: :success
,
http_status:
200
,
message:
'ok'
}
}
let
(
:success_result
)
{
{
status: :success
,
http_status:
200
,
message:
'ok'
}
}
context
'hook with not implemented test'
do
it
'allows to set a custom project'
do
let
(
:trigger
)
{
'not_implemented_events'
}
project
=
double
service
.
project
=
project
expect
(
service
.
project
).
to
eq
(
project
)
end
context
'hook with not implemented test'
do
it
'returns error message'
do
it
'returns error message'
do
expect
(
hook
).
not_to
receive
(
:execute
)
expect
(
hook
).
not_to
receive
(
:execute
)
expect
(
service
.
execute
).
to
include
({
status: :error
,
message:
'Testing not available for this hook'
})
expect
(
service
.
execute
).
to
include
({
status: :error
,
message:
'Testing not available for this hook'
})
...
...
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