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
Léo-Paul Géneau
gitlab-ce
Commits
274987d5
Commit
274987d5
authored
Jan 27, 2017
by
Douglas Barbosa Alexandre
Committed by
Fatih Acet
Feb 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse endpoint to list issues for a list instead of create a new one
parent
7f58fc0e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
60 deletions
+79
-60
app/assets/javascripts/boards/components/modal/index.js.es6
app/assets/javascripts/boards/components/modal/index.js.es6
+1
-1
app/assets/javascripts/boards/services/board_service.js.es6
app/assets/javascripts/boards/services/board_service.js.es6
+3
-3
app/controllers/projects/boards/issues_controller.rb
app/controllers/projects/boards/issues_controller.rb
+1
-1
app/controllers/projects/boards_controller.rb
app/controllers/projects/boards_controller.rb
+1
-22
app/services/boards/issues/list_service.rb
app/services/boards/issues/list_service.rb
+10
-4
config/routes/project.rb
config/routes/project.rb
+1
-3
spec/controllers/projects/boards/issues_controller_spec.rb
spec/controllers/projects/boards/issues_controller_spec.rb
+50
-26
spec/services/boards/issues/list_service_spec.rb
spec/services/boards/issues/list_service_spec.rb
+12
-0
No files found.
app/assets/javascripts/boards/components/modal/index.js.es6
View file @
274987d5
...
...
@@ -48,7 +48,7 @@
}).then((res) => {
const data = res.json();
data.forEach((issueObj) => {
data.
issues.
forEach((issueObj) => {
const issue = new ListIssue(issueObj);
const foundSelectedIssue = ModalStore.findSelectedIssue(issue);
issue.selected = foundSelectedIssue !== undefined;
...
...
app/assets/javascripts/boards/services/board_service.js.es6
View file @
274987d5
...
...
@@ -4,9 +4,9 @@
class BoardService {
constructor (root, boardId) {
this.boards = Vue.resource(`${root}{/id}.json`, {}, {
backlog
: {
issues
: {
method: 'GET',
url: `${root}/${boardId}/
backlog
.json`
url: `${root}/${boardId}/
issues
.json`
}
});
this.lists = Vue.resource(`${root}/${boardId}/lists{/id}`, {}, {
...
...
@@ -73,7 +73,7 @@ class BoardService {
}
getBacklog(data) {
return this.boards.
backlog
(data);
return this.boards.
issues
(data);
}
}
...
...
app/controllers/projects/boards/issues_controller.rb
View file @
274987d5
...
...
@@ -59,7 +59,7 @@ module Projects
end
def
filter_params
params
.
merge
(
board_id:
params
[
:board_id
],
id:
params
[
:list_id
])
params
.
merge
(
board_id:
params
[
:board_id
],
id:
params
[
:list_id
])
.
compact
end
def
move_params
...
...
app/controllers/projects/boards_controller.rb
View file @
274987d5
class
Projects::BoardsController
<
Projects
::
ApplicationController
include
IssuableCollections
# before_action :authorize_read_board!, only: [:index, :show, :backlog
]
before_action
:authorize_read_board!
,
only:
[
:index
,
:show
]
def
index
@boards
=
::
Boards
::
ListService
.
new
(
project
,
current_user
).
execute
...
...
@@ -25,27 +25,6 @@ class Projects::BoardsController < Projects::ApplicationController
end
end
def
backlog
board
=
project
.
boards
.
find
(
params
[
:id
])
@issues
=
issues_collection
@issues
=
@issues
.
where
.
not
(
LabelLink
.
where
(
"label_links.target_type = 'Issue' AND label_links.target_id = issues.id"
)
.
where
(
label_id:
board
.
lists
.
movable
.
pluck
(
:label_id
)).
limit
(
1
).
arel
.
exists
)
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
params
[
:per
])
render
json:
@issues
.
as_json
(
labels:
true
,
only:
[
:id
,
:iid
,
:title
,
:confidential
,
:due_date
],
include:
{
assignee:
{
only:
[
:id
,
:name
,
:username
],
methods:
[
:avatar_url
]
},
milestone:
{
only:
[
:id
,
:title
]
}
},
user:
current_user
)
end
private
def
authorize_read_board!
...
...
app/services/boards/issues/list_service.rb
View file @
274987d5
...
...
@@ -3,8 +3,8 @@ module Boards
class
ListService
<
BaseService
def
execute
issues
=
IssuesFinder
.
new
(
current_user
,
filter_params
).
execute
issues
=
without_board_labels
(
issues
)
unless
list
.
movable
?
issues
=
with_list_label
(
issues
)
if
list
.
movable
?
issues
=
without_board_labels
(
issues
)
unless
movable_list
?
issues
=
with_list_label
(
issues
)
if
movable_list
?
issues
end
...
...
@@ -15,7 +15,13 @@ module Boards
end
def
list
@list
||=
board
.
lists
.
find
(
params
[
:id
])
return
@list
if
defined?
(
@list
)
@list
=
board
.
lists
.
find
(
params
[
:id
])
if
params
.
key?
(
:id
)
end
def
movable_list?
@movable_list
||=
list
.
present?
&&
list
.
movable?
end
def
filter_params
...
...
@@ -40,7 +46,7 @@ module Boards
end
def
set_state
params
[
:state
]
=
list
.
done?
?
'closed'
:
'opened'
params
[
:state
]
=
list
&&
list
.
done?
?
'closed'
:
'opened'
end
def
board_label_ids
...
...
config/routes/project.rb
View file @
274987d5
...
...
@@ -266,10 +266,8 @@ constraints(ProjectUrlConstrainer.new) do
end
resources
:boards
,
only:
[
:index
,
:show
]
do
get
:backlog
,
on: :member
scope
module: :boards
do
resources
:issues
,
only:
[
:update
]
resources
:issues
,
only:
[
:
index
,
:
update
]
resources
:lists
,
only:
[
:index
,
:create
,
:update
,
:destroy
]
do
collection
do
...
...
spec/controllers/projects/boards/issues_controller_spec.rb
View file @
274987d5
...
...
@@ -18,9 +18,19 @@ describe Projects::Boards::IssuesController do
end
describe
'GET index'
do
let
(
:johndoe
)
{
create
(
:user
,
avatar:
fixture_file_upload
(
File
.
join
(
Rails
.
root
,
'spec/fixtures/dk.png'
)))
}
context
'with invalid board id'
do
it
'returns a not found 404 response'
do
list_issues
user:
user
,
board:
999
,
list:
list2
expect
(
response
).
to
have_http_status
(
404
)
end
end
context
'when list id is present'
do
context
'with valid list id'
do
it
'returns issues that have the list label applied'
do
johndoe
=
create
(
:user
,
avatar:
fixture_file_upload
(
File
.
join
(
Rails
.
root
,
'spec/fixtures/dk.png'
)))
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
planning
])
create
(
:labeled_issue
,
project:
project
,
labels:
[
planning
])
create
(
:labeled_issue
,
project:
project
,
labels:
[
development
],
due_date:
Date
.
tomorrow
)
...
...
@@ -36,19 +46,29 @@ describe Projects::Boards::IssuesController do
end
end
context
'with invalid board
id'
do
context
'with invalid list
id'
do
it
'returns a not found 404 response'
do
list_issues
user:
user
,
board:
999
,
list:
list2
list_issues
user:
user
,
board:
board
,
list:
999
expect
(
response
).
to
have_http_status
(
404
)
end
end
end
context
'with invalid list id'
do
it
'returns a not found 404 response'
do
list_issues
user:
user
,
board:
board
,
list:
999
context
'when list id is missing'
do
it
'returns opened issues without board labels applied'
do
bug
=
create
(
:label
,
project:
project
,
name:
'Bug'
)
create
(
:issue
,
project:
project
)
create
(
:labeled_issue
,
project:
project
,
labels:
[
planning
])
create
(
:labeled_issue
,
project:
project
,
labels:
[
development
])
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
expect
(
response
).
to
have_http_status
(
404
)
list_issues
user:
user
,
board:
board
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'issues'
)
expect
(
parsed_response
.
length
).
to
eq
2
end
end
...
...
@@ -65,13 +85,17 @@ describe Projects::Boards::IssuesController do
end
end
def
list_issues
(
user
:,
board
:,
list
:)
def
list_issues
(
user
:,
board
:,
list:
nil
)
sign_in
(
user
)
get
:index
,
namespace_id:
project
.
namespace
.
to_param
,
params
=
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
board_id:
board
.
to_param
,
list_id:
list
.
to_param
list_id:
list
.
try
(
:to_param
)
}
get
:index
,
params
.
compact
end
end
...
...
spec/services/boards/issues/list_service_spec.rb
View file @
274987d5
...
...
@@ -17,6 +17,10 @@ describe Boards::Issues::ListService, services: true do
let!
(
:list2
)
{
create
(
:list
,
board:
board
,
label:
testing
,
position:
1
)
}
let!
(
:done
)
{
create
(
:done_list
,
board:
board
)
}
let!
(
:opened_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
}
let!
(
:opened_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
p2
])
}
let!
(
:reopened_issue1
)
{
create
(
:issue
,
:reopened
,
project:
project
)
}
let!
(
:list1_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
p2
,
development
])
}
let!
(
:list1_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
development
])
}
let!
(
:list1_issue3
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
development
,
p1
])
}
...
...
@@ -40,6 +44,14 @@ describe Boards::Issues::ListService, services: true do
end
context
'sets default order to priority'
do
it
'returns opened issues when list id is missing'
do
params
=
{
board_id:
board
.
id
}
issues
=
described_class
.
new
(
project
,
user
,
params
).
execute
expect
(
issues
).
to
eq
[
opened_issue2
,
reopened_issue1
,
opened_issue1
]
end
it
'returns closed issues when listing issues from Done'
do
params
=
{
board_id:
board
.
id
,
id:
done
.
id
}
...
...
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