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
1
Merge Requests
1
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-ce
Commits
120e0c4d
Commit
120e0c4d
authored
May 03, 2018
by
blackst0ne
Committed by
Rémy Coutable
May 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace the `group_hooks.feature` spinach test with an rspec analog
parent
547d2db5
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
111 deletions
+103
-111
ee/changelogs/unreleased/blackst0ne-replace-spinach-group-hooks-feature.yml
...leased/blackst0ne-replace-spinach-group-hooks-feature.yml
+5
-0
ee/spec/features/groups/hooks/user_adds_hook_spec.rb
ee/spec/features/groups/hooks/user_adds_hook_spec.rb
+23
-0
ee/spec/features/groups/hooks/user_tests_hooks_spec.rb
ee/spec/features/groups/hooks/user_tests_hooks_spec.rb
+58
-0
ee/spec/features/groups/hooks/user_views_hooks_spec.rb
ee/spec/features/groups/hooks/user_views_hooks_spec.rb
+17
-0
features/group_hooks.feature
features/group_hooks.feature
+0
-37
features/steps/group_hooks.rb
features/steps/group_hooks.rb
+0
-70
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+0
-4
No files found.
ee/changelogs/unreleased/blackst0ne-replace-spinach-group-hooks-feature.yml
0 → 100644
View file @
120e0c4d
---
title
:
'
Replace
the
`group_hooks.feature`
spinach
test
with
an
rspec
analog'
merge_request
:
5515
author
:
'
@blackst0ne'
type
:
other
ee/spec/features/groups/hooks/user_adds_hook_spec.rb
0 → 100644
View file @
120e0c4d
require
"spec_helper"
describe
"User adds hook"
do
set
(
:group
)
{
create
(
:group
)
}
set
(
:user
)
{
create
(
:user
)
}
set
(
:url
)
{
"http://example.org"
}
before
do
group
.
add_owner
(
user
)
sign_in
(
user
)
visit
(
group_hooks_path
(
group
))
end
it
"adds new hook"
do
fill_in
(
"hook_url"
,
with:
url
)
expect
{
click_button
(
"Add webhook"
)
}.
to
change
(
GroupHook
,
:count
).
by
(
1
)
expect
(
current_path
).
to
eq
group_hooks_path
(
group
)
expect
(
page
).
to
have_content
(
url
)
end
end
ee/spec/features/groups/hooks/user_tests_hooks_spec.rb
0 → 100644
View file @
120e0c4d
require
"spec_helper"
describe
"User tests hooks"
do
set
(
:group
)
{
create
(
:group
)
}
set
(
:hook
)
{
create
(
:group_hook
,
group:
group
)
}
set
(
:user
)
{
create
(
:user
)
}
before
do
group
.
add_owner
(
user
)
sign_in
(
user
)
visit
(
group_hooks_path
(
group
))
end
context
"when project is not empty"
do
let!
(
:project
)
{
create
(
:project
,
:repository
,
group:
group
)
}
context
"when URL is valid"
do
before
do
trigger_hook
end
it
"triggers a hook"
do
expect
(
current_path
).
to
eq
(
group_hooks_path
(
group
))
expect
(
page
).
to
have_selector
(
".flash-notice"
,
text:
"Hook executed successfully: HTTP 200"
)
end
end
context
"when URL is invalid"
do
before
do
stub_request
(
:post
,
hook
.
url
).
to_raise
(
SocketError
.
new
(
"Failed to open"
))
click_link
(
"Test"
)
end
it
{
expect
(
page
).
to
have_selector
(
".flash-alert"
,
text:
"Hook execution failed: Failed to open"
)
}
end
end
context
"when project is empty"
do
let!
(
:project
)
{
create
(
:project
,
group:
group
)
}
before
do
trigger_hook
end
it
{
expect
(
page
).
to
have_selector
(
'.flash-alert'
,
text:
'Hook execution failed. Ensure the group has a project with commits.'
)
}
end
private
def
trigger_hook
stub_request
(
:post
,
hook
.
url
).
to_return
(
status:
200
)
click_link
(
"Test"
)
end
end
ee/spec/features/groups/hooks/user_views_hooks_spec.rb
0 → 100644
View file @
120e0c4d
require
"spec_helper"
describe
"User views hooks"
do
set
(
:group
)
{
create
(
:group
)
}
set
(
:hook
)
{
create
(
:group_hook
,
group:
group
)
}
set
(
:user
)
{
create
(
:user
)
}
before
do
group
.
add_owner
(
user
)
sign_in
(
user
)
visit
(
group_hooks_path
(
group
))
end
it
{
expect
(
page
).
to
have_content
(
hook
.
url
)
}
end
features/group_hooks.feature
deleted
100644 → 0
View file @
547d2db5
Feature
:
Group Hooks
Background
:
Given
I sign in as a user
And
I own group
"Sourcing"
Scenario
:
I
should see hook list
Given
I own project
"Shop"
in group
"Sourcing"
And
group has hook
When
I visit group hooks page
Then
I should see group hook
Scenario
:
I
add new hook
Given
I
own project
"Shop"
in group
"Sourcing"
And
I visit group hooks page
When
I submit new hook
Then
I should see newly created hook
Scenario
:
I
test hook
Given
I own project
"Shop"
in group
"Sourcing"
And
group has hook
And
I visit group hooks page
When
I click test hook button
Then
hook should be triggered
Scenario
:
I
test a hook on empty project
Given
I own empty project
"Empty Shop"
in group
"Sourcing"
And
group has hook
And
I visit group hooks page
When
I click test hook button
Then
I should see hook error message
Scenario
:
I
test a hook on down URL
Given
I own project
"Shop"
in group
"Sourcing"
And
group has hook
And
I visit group hooks page
When
I click test hook button with invalid URL
Then
I should see hook service down error message
features/steps/group_hooks.rb
deleted
100644 → 0
View file @
547d2db5
require
'webmock'
class
Spinach::Features::GroupHooks
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedProject
include
SharedPaths
include
RSpec
::
Matchers
include
RSpec
::
Mocks
::
ExampleMethods
include
WebMock
::
API
step
'I own group "Sourcing"'
do
@group
=
create
:group
,
name:
"Sourcing"
@group
.
add_owner
(
current_user
)
end
step
'I own project "Shop" in group "Sourcing"'
do
@project
=
create
(
:project
,
:repository
,
group:
@group
)
end
step
'I own empty project "Empty Shop" in group "Sourcing"'
do
@project
=
create
(
:project
,
group:
@group
)
end
step
'group has hook'
do
@hook
=
create
(
:group_hook
,
group:
@group
)
end
step
'I should see group hook'
do
expect
(
page
).
to
have_content
@hook
.
url
end
step
'I submit new hook'
do
@url
=
'http://example.org'
fill_in
"hook_url"
,
with:
@url
expect
{
click_button
"Add webhook"
}.
to
change
(
GroupHook
,
:count
).
by
(
1
)
end
step
'I should see newly created hook'
do
expect
(
current_path
).
to
eq
group_hooks_path
(
@group
)
expect
(
page
).
to
have_content
(
@url
)
end
step
'I click test hook button'
do
WebMock
.
enable!
stub_request
(
:post
,
@hook
.
url
).
to_return
(
status:
200
)
click_link
'Test'
WebMock
.
disable!
end
step
'I click test hook button with invalid URL'
do
stub_request
(
:post
,
@hook
.
url
).
to_raise
(
SocketError
.
new
(
'Failed to open'
))
click_link
'Test'
end
step
'hook should be triggered'
do
expect
(
current_path
).
to
eq
group_hooks_path
(
@group
)
expect
(
page
).
to
have_selector
'.flash-notice'
,
text:
'Hook executed successfully: HTTP 200'
end
step
'I should see hook error message'
do
expect
(
page
).
to
have_selector
'.flash-alert'
,
text:
'Hook execution failed. Ensure the group has a project with commits.'
end
step
'I should see hook service down error message'
do
expect
(
page
).
to
have_selector
'.flash-alert'
,
text:
'Hook execution failed: Failed to open'
end
end
features/steps/shared/paths.rb
View file @
120e0c4d
...
@@ -252,10 +252,6 @@ module SharedPaths
...
@@ -252,10 +252,6 @@ module SharedPaths
visit
project_settings_integrations_path
(
@project
)
visit
project_settings_integrations_path
(
@project
)
end
end
step
'I visit group hooks page'
do
visit
group_hooks_path
(
@group
)
end
step
'I visit project deploy keys page'
do
step
'I visit project deploy keys page'
do
visit
project_deploy_keys_path
(
@project
)
visit
project_deploy_keys_path
(
@project
)
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