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
8f9f9877
Commit
8f9f9877
authored
Nov 08, 2021
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update specs to cover Alert todos
parent
d3e62ab7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
config/routes/project.rb
config/routes/project.rb
+1
-3
lib/api/entities/todo.rb
lib/api/entities/todo.rb
+1
-1
spec/requests/api/todos_spec.rb
spec/requests/api/todos_spec.rb
+9
-3
No files found.
config/routes/project.rb
View file @
8f9f9877
...
@@ -360,9 +360,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
...
@@ -360,9 +360,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get
'details'
,
on: :member
get
'details'
,
on: :member
end
end
resources
:alert_management
,
only:
[],
as:
'alert_management_alert'
do
get
'alert_management/:id'
,
to:
'alert_management#details'
,
as:
'alert_management_alert'
get
''
,
on: :member
,
action: :details
,
as:
''
end
get
'work_items/*work_items_path'
=>
'work_items#index'
,
as: :work_items
get
'work_items/*work_items_path'
=>
'work_items#index'
,
as: :work_items
...
...
lib/api/entities/todo.rb
View file @
8f9f9877
...
@@ -33,7 +33,7 @@ module API
...
@@ -33,7 +33,7 @@ module API
def
todo_target_url
(
todo
)
def
todo_target_url
(
todo
)
return
design_todo_target_url
(
todo
)
if
todo
.
for_design?
return
design_todo_target_url
(
todo
)
if
todo
.
for_design?
target_type
=
todo
.
target_type
.
constantize
.
model_name
.
param_key
target_type
=
todo
.
target_type
.
gsub
(
'::'
,
'_'
).
underscore
target_url
=
"
#{
todo
.
resource_parent
.
class
.
to_s
.
underscore
}
_
#{
target_type
}
_url"
target_url
=
"
#{
todo
.
resource_parent
.
class
.
to_s
.
underscore
}
_
#{
target_type
}
_url"
Gitlab
::
Routing
Gitlab
::
Routing
...
...
spec/requests/api/todos_spec.rb
View file @
8f9f9877
...
@@ -13,6 +13,8 @@ RSpec.describe API::Todos do
...
@@ -13,6 +13,8 @@ RSpec.describe API::Todos do
let_it_be
(
:john_doe
)
{
create
(
:user
,
username:
'john_doe'
)
}
let_it_be
(
:john_doe
)
{
create
(
:user
,
username:
'john_doe'
)
}
let_it_be
(
:issue
)
{
create
(
:issue
,
project:
project_1
)
}
let_it_be
(
:issue
)
{
create
(
:issue
,
project:
project_1
)
}
let_it_be
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project_1
)
}
let_it_be
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project_1
)
}
let_it_be
(
:alert
)
{
create
(
:alert_management_alert
,
project:
project_1
)
}
let_it_be
(
:alert_todo
)
{
create
(
:todo
,
project:
project_1
,
author:
john_doe
,
user:
john_doe
,
target:
alert
)
}
let_it_be
(
:merge_request_todo
)
{
create
(
:todo
,
project:
project_1
,
author:
author_2
,
user:
john_doe
,
target:
merge_request
)
}
let_it_be
(
:merge_request_todo
)
{
create
(
:todo
,
project:
project_1
,
author:
author_2
,
user:
john_doe
,
target:
merge_request
)
}
let_it_be
(
:pending_1
)
{
create
(
:todo
,
:mentioned
,
project:
project_1
,
author:
author_1
,
user:
john_doe
,
target:
issue
)
}
let_it_be
(
:pending_1
)
{
create
(
:todo
,
:mentioned
,
project:
project_1
,
author:
author_1
,
user:
john_doe
,
target:
issue
)
}
let_it_be
(
:pending_2
)
{
create
(
:todo
,
project:
project_2
,
author:
author_2
,
user:
john_doe
,
target:
issue
)
}
let_it_be
(
:pending_2
)
{
create
(
:todo
,
project:
project_2
,
author:
author_2
,
user:
john_doe
,
target:
issue
)
}
...
@@ -67,7 +69,7 @@ RSpec.describe API::Todos do
...
@@ -67,7 +69,7 @@ RSpec.describe API::Todos do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
4
)
expect
(
json_response
.
length
).
to
eq
(
5
)
expect
(
json_response
[
0
][
'id'
]).
to
eq
(
pending_3
.
id
)
expect
(
json_response
[
0
][
'id'
]).
to
eq
(
pending_3
.
id
)
expect
(
json_response
[
0
][
'project'
]).
to
be_a
Hash
expect
(
json_response
[
0
][
'project'
]).
to
be_a
Hash
expect
(
json_response
[
0
][
'author'
]).
to
be_a
Hash
expect
(
json_response
[
0
][
'author'
]).
to
be_a
Hash
...
@@ -95,6 +97,10 @@ RSpec.describe API::Todos do
...
@@ -95,6 +97,10 @@ RSpec.describe API::Todos do
expect
(
json_response
[
3
][
'target'
][
'merge_requests_count'
]).
to
be_nil
expect
(
json_response
[
3
][
'target'
][
'merge_requests_count'
]).
to
be_nil
expect
(
json_response
[
3
][
'target'
][
'upvotes'
]).
to
eq
(
1
)
expect
(
json_response
[
3
][
'target'
][
'upvotes'
]).
to
eq
(
1
)
expect
(
json_response
[
3
][
'target'
][
'downvotes'
]).
to
eq
(
0
)
expect
(
json_response
[
3
][
'target'
][
'downvotes'
]).
to
eq
(
0
)
expect
(
json_response
[
4
][
'target_type'
]).
to
eq
(
'AlertManagement::Alert'
)
expect
(
json_response
[
4
][
'target'
][
'iid'
]).
to
eq
(
alert
.
iid
)
expect
(
json_response
[
4
][
'target'
][
'title'
]).
to
eq
(
alert
.
title
)
end
end
context
"when current user does not have access to one of the TODO's target"
do
context
"when current user does not have access to one of the TODO's target"
do
...
@@ -105,7 +111,7 @@ RSpec.describe API::Todos do
...
@@ -105,7 +111,7 @@ RSpec.describe API::Todos do
get
api
(
'/todos'
,
john_doe
)
get
api
(
'/todos'
,
john_doe
)
expect
(
json_response
.
count
).
to
eq
(
4
)
expect
(
json_response
.
count
).
to
eq
(
5
)
expect
(
json_response
.
map
{
|
t
|
t
[
'id'
]
}).
not_to
include
(
no_access_todo
.
id
,
pending_4
.
id
)
expect
(
json_response
.
map
{
|
t
|
t
[
'id'
]
}).
not_to
include
(
no_access_todo
.
id
,
pending_4
.
id
)
end
end
end
end
...
@@ -163,7 +169,7 @@ RSpec.describe API::Todos do
...
@@ -163,7 +169,7 @@ RSpec.describe API::Todos do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
expect
(
json_response
.
length
).
to
eq
(
4
)
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