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
40bcc023
Commit
40bcc023
authored
Apr 29, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use nil-safe method to detect empty collections
Adds specs for new changes Changelog: fixed
parent
fb5bb717
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
5 deletions
+61
-5
app/controllers/projects/hooks_controller.rb
app/controllers/projects/hooks_controller.rb
+1
-0
app/views/admin/hook_logs/_index.html.haml
app/views/admin/hook_logs/_index.html.haml
+1
-1
app/views/projects/hook_logs/_index.html.haml
app/views/projects/hook_logs/_index.html.haml
+1
-1
changelogs/unreleased/320982-actionview-template-error-undefined-method-any-for-nil-nilclass.yml
...-template-error-undefined-method-any-for-nil-nilclass.yml
+5
-0
spec/controllers/projects/hooks_controller_spec.rb
spec/controllers/projects/hooks_controller_spec.rb
+53
-3
No files found.
app/controllers/projects/hooks_controller.rb
View file @
40bcc023
...
...
@@ -32,6 +32,7 @@ class Projects::HooksController < Projects::ApplicationController
end
def
edit
redirect_to
(
action: :index
)
unless
hook
end
def
update
...
...
app/views/admin/hook_logs/_index.html.haml
View file @
40bcc023
...
...
@@ -4,7 +4,7 @@
=
_
(
'Recent Deliveries'
)
%p
=
_
(
'When an event in GitLab triggers a webhook, you can use the request details to figure out if something went wrong.'
)
.col-lg-9
-
if
hook_logs
.
any
?
-
if
hook_logs
.
present
?
%table
.table
%thead
%tr
...
...
app/views/projects/hook_logs/_index.html.haml
View file @
40bcc023
...
...
@@ -4,7 +4,7 @@
Recent Deliveries
%p
When an event in GitLab triggers a webhook, you can use the request details to figure out if something went wrong.
.col-lg-9
-
if
hook_logs
.
any
?
-
if
hook_logs
.
present
?
%table
.table
%thead
%tr
...
...
changelogs/unreleased/320982-actionview-template-error-undefined-method-any-for-nil-nilclass.yml
0 → 100644
View file @
40bcc023
---
title
:
Ensure we never error in web hook logs
merge_request
:
60408
author
:
type
:
fixed
spec/controllers/projects/hooks_controller_spec.rb
View file @
40bcc023
...
...
@@ -3,11 +3,11 @@
require
'spec_helper'
RSpec
.
describe
Projects
::
HooksController
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
project
.
owner
}
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
end
...
...
@@ -20,6 +20,56 @@ RSpec.describe Projects::HooksController do
end
end
describe
'#edit'
do
let_it_be
(
:hook
)
{
create
(
:project_hook
,
project:
project
)
}
let
(
:params
)
do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
hook
.
id
}
end
render_views
it
'does not error if the hook cannot be found'
do
get
:edit
,
params:
params
.
merge
(
id:
non_existing_record_id
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
it
'assigns hook_logs'
do
get
:edit
,
params:
params
expect
(
assigns
[
:hook
]).
to
be_present
expect
(
assigns
[
:hook_logs
]).
to
be_empty
it_renders_correctly
end
it
'handles when logs are present'
do
create_list
(
:web_hook_log
,
3
,
web_hook:
hook
)
get
:edit
,
params:
params
expect
(
assigns
[
:hook
]).
to
be_present
expect
(
assigns
[
:hook_logs
].
count
).
to
eq
3
it_renders_correctly
end
it
'can paginate logs'
do
create_list
(
:web_hook_log
,
21
,
web_hook:
hook
)
get
:edit
,
params:
params
.
merge
(
page:
2
)
expect
(
assigns
[
:hook
]).
to
be_present
expect
(
assigns
[
:hook_logs
].
count
).
to
eq
1
it_renders_correctly
end
def
it_renders_correctly
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:edit
)
expect
(
response
).
to
render_template
(
'projects/hook_logs/_index'
)
end
end
describe
'#create'
do
it
'sets all parameters'
do
hook_params
=
{
...
...
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