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
67d5b95d
Commit
67d5b95d
authored
Jul 28, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7383 from Razer6/fix_test_hooks_empty_project
Do not execute hooks on empty projects, fixes #6108
parents
9f463c92
062ff17b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
7 deletions
+31
-7
app/controllers/projects/hooks_controller.rb
app/controllers/projects/hooks_controller.rb
+6
-1
features/project/hooks.feature
features/project/hooks.feature
+5
-0
features/steps/project/hooks.rb
features/steps/project/hooks.rb
+20
-6
No files found.
app/controllers/projects/hooks_controller.rb
View file @
67d5b95d
...
@@ -24,7 +24,12 @@ class Projects::HooksController < Projects::ApplicationController
...
@@ -24,7 +24,12 @@ class Projects::HooksController < Projects::ApplicationController
end
end
def
test
def
test
TestHookService
.
new
.
execute
(
hook
,
current_user
)
if
!
@project
.
empty_repo?
TestHookService
.
new
.
execute
(
hook
,
current_user
)
flash
[
:notice
]
=
'Hook successfully executed.'
else
flash
[
:alert
]
=
'Hook execution failed. Ensure the project has commits.'
end
redirect_to
:back
redirect_to
:back
end
end
...
...
features/project/hooks.feature
View file @
67d5b95d
...
@@ -19,3 +19,8 @@ Feature: Project Hooks
...
@@ -19,3 +19,8 @@ Feature: Project Hooks
When
I click test hook button
When
I click test hook button
Then
hook should be triggered
Then
hook should be triggered
Scenario
:
I
test a hook on empty project
Given
I own empty project with hook
And
I visit project hooks page
When
I click test hook button
Then
I should see hook error message
features/steps/project/hooks.rb
View file @
67d5b95d
...
@@ -8,31 +8,45 @@ class ProjectHooks < Spinach::FeatureSteps
...
@@ -8,31 +8,45 @@ class ProjectHooks < Spinach::FeatureSteps
include
RSpec
::
Mocks
::
ExampleMethods
include
RSpec
::
Mocks
::
ExampleMethods
include
WebMock
::
API
include
WebMock
::
API
Given
'project has hook'
do
step
'project has hook'
do
@hook
=
create
(
:project_hook
,
project:
current_project
)
@hook
=
create
(
:project_hook
,
project:
current_project
)
end
end
Then
'I should see project hook'
do
step
'I own empty project with hook'
do
@project
=
create
(
:empty_project
,
name:
'Empty Project'
,
namespace:
@user
.
namespace
)
@hook
=
create
(
:project_hook
,
project:
current_project
)
end
step
'I should see project hook'
do
page
.
should
have_content
@hook
.
url
page
.
should
have_content
@hook
.
url
end
end
When
'I submit new hook'
do
step
'I submit new hook'
do
@url
=
Faker
::
Internet
.
uri
(
"http"
)
@url
=
Faker
::
Internet
.
uri
(
"http"
)
fill_in
"hook_url"
,
with:
@url
fill_in
"hook_url"
,
with:
@url
expect
{
click_button
"Add Web Hook"
}.
to
change
(
ProjectHook
,
:count
).
by
(
1
)
expect
{
click_button
"Add Web Hook"
}.
to
change
(
ProjectHook
,
:count
).
by
(
1
)
end
end
Then
'I should see newly created hook'
do
step
'I should see newly created hook'
do
page
.
current_path
.
should
==
project_hooks_path
(
current_project
)
page
.
current_path
.
should
==
project_hooks_path
(
current_project
)
page
.
should
have_content
(
@url
)
page
.
should
have_content
(
@url
)
end
end
When
'I click test hook button'
do
step
'I click test hook button'
do
stub_request
(
:post
,
@hook
.
url
).
to_return
(
status:
200
)
stub_request
(
:post
,
@hook
.
url
).
to_return
(
status:
200
)
click_link
'Test Hook'
click_link
'Test Hook'
end
end
Then
'hook should be triggered'
do
step
'hook should be triggered'
do
page
.
current_path
.
should
==
project_hooks_path
(
current_project
)
page
.
current_path
.
should
==
project_hooks_path
(
current_project
)
page
.
should
have_selector
'.flash-notice'
,
text:
'Hook successfully executed.'
end
step
'I should see hook error message'
do
page
.
should
have_selector
'.flash-alert'
,
text:
'Hook execution failed. '
\
'Ensure the project has commits.'
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