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
57737785
Commit
57737785
authored
Aug 15, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move board related controllers to the `Boards` namespace
parent
8e4e294a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
135 additions
and
125 deletions
+135
-125
app/controllers/projects/board_issues_controller.rb
app/controllers/projects/board_issues_controller.rb
+0
-52
app/controllers/projects/board_lists_controller.rb
app/controllers/projects/board_lists_controller.rb
+0
-65
app/controllers/projects/boards/issues_controller.rb
app/controllers/projects/boards/issues_controller.rb
+56
-0
app/controllers/projects/boards/lists_controller.rb
app/controllers/projects/boards/lists_controller.rb
+69
-0
config/routes.rb
config/routes.rb
+8
-6
spec/controllers/projects/boards/issues_controller_spec.rb
spec/controllers/projects/boards/issues_controller_spec.rb
+1
-1
spec/controllers/projects/boards/lists_controller_spec.rb
spec/controllers/projects/boards/lists_controller_spec.rb
+1
-1
No files found.
app/controllers/projects/board_issues_controller.rb
deleted
100644 → 0
View file @
8e4e294a
class
Projects::BoardIssuesController
<
Projects
::
ApplicationController
respond_to
:json
before_action
:authorize_read_issue!
,
only:
[
:index
]
before_action
:authorize_update_issue!
,
only:
[
:update
]
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
def
index
issues
=
Boards
::
Issues
::
ListService
.
new
(
project
,
current_user
,
filter_params
).
execute
issues
=
issues
.
page
(
params
[
:page
])
render
json:
issues
.
as_json
(
only:
[
:iid
,
:title
,
:confidential
],
include:
{
assignee:
{
only:
[
:id
,
:name
,
:username
],
methods:
[
:avatar_url
]
},
labels:
{
only:
[
:id
,
:title
,
:description
,
:color
,
:priority
]
}
})
end
def
update
service
=
Boards
::
Issues
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
if
service
.
execute
head
:ok
else
head
:unprocessable_entity
end
end
private
def
authorize_read_issue!
return
render_403
unless
can?
(
current_user
,
:read_issue
,
project
)
end
def
authorize_update_issue!
return
render_403
unless
can?
(
current_user
,
:update_issue
,
project
)
end
def
filter_params
params
.
merge
(
id:
params
[
:list_id
])
end
def
move_params
params
.
permit
(
:id
,
:from_list_id
,
:to_list_id
)
end
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
end
app/controllers/projects/board_lists_controller.rb
deleted
100644 → 0
View file @
8e4e294a
class
Projects::BoardListsController
<
Projects
::
ApplicationController
respond_to
:json
before_action
:authorize_admin_list!
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
def
create
list
=
Boards
::
Lists
::
CreateService
.
new
(
project
,
current_user
,
list_params
).
execute
if
list
.
valid?
render
json:
list
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:description
,
:color
,
:priority
]
}
})
else
render
json:
list
.
errors
,
status: :unprocessable_entity
end
end
def
update
service
=
Boards
::
Lists
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
if
service
.
execute
head
:ok
else
head
:unprocessable_entity
end
end
def
destroy
service
=
Boards
::
Lists
::
DestroyService
.
new
(
project
,
current_user
,
params
)
if
service
.
execute
head
:ok
else
head
:unprocessable_entity
end
end
def
generate
service
=
Boards
::
Lists
::
GenerateService
.
new
(
project
,
current_user
)
if
service
.
execute
render
json:
project
.
board
.
lists
.
label
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:description
,
:color
,
:priority
]
}
})
else
head
:unprocessable_entity
end
end
private
def
authorize_admin_list!
return
render_403
unless
can?
(
current_user
,
:admin_list
,
project
)
end
def
list_params
params
.
require
(
:list
).
permit
(
:label_id
)
end
def
move_params
params
.
require
(
:list
).
permit
(
:position
).
merge
(
id:
params
[
:id
])
end
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
end
app/controllers/projects/boards/issues_controller.rb
0 → 100644
View file @
57737785
module
Projects
module
Boards
class
IssuesController
<
Projects
::
ApplicationController
respond_to
:json
before_action
:authorize_read_issue!
,
only:
[
:index
]
before_action
:authorize_update_issue!
,
only:
[
:update
]
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
def
index
issues
=
::
Boards
::
Issues
::
ListService
.
new
(
project
,
current_user
,
filter_params
).
execute
issues
=
issues
.
page
(
params
[
:page
])
render
json:
issues
.
as_json
(
only:
[
:iid
,
:title
,
:confidential
],
include:
{
assignee:
{
only:
[
:id
,
:name
,
:username
],
methods:
[
:avatar_url
]
},
labels:
{
only:
[
:id
,
:title
,
:description
,
:color
,
:priority
]
}
})
end
def
update
service
=
::
Boards
::
Issues
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
if
service
.
execute
head
:ok
else
head
:unprocessable_entity
end
end
private
def
authorize_read_issue!
return
render_403
unless
can?
(
current_user
,
:read_issue
,
project
)
end
def
authorize_update_issue!
return
render_403
unless
can?
(
current_user
,
:update_issue
,
project
)
end
def
filter_params
params
.
merge
(
id:
params
[
:list_id
])
end
def
move_params
params
.
permit
(
:id
,
:from_list_id
,
:to_list_id
)
end
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
end
end
end
app/controllers/projects/boards/lists_controller.rb
0 → 100644
View file @
57737785
module
Projects
module
Boards
class
ListsController
<
Projects
::
ApplicationController
respond_to
:json
before_action
:authorize_admin_list!
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
def
create
list
=
::
Boards
::
Lists
::
CreateService
.
new
(
project
,
current_user
,
list_params
).
execute
if
list
.
valid?
render
json:
list
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:description
,
:color
,
:priority
]
}
})
else
render
json:
list
.
errors
,
status: :unprocessable_entity
end
end
def
update
service
=
::
Boards
::
Lists
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
if
service
.
execute
head
:ok
else
head
:unprocessable_entity
end
end
def
destroy
service
=
::
Boards
::
Lists
::
DestroyService
.
new
(
project
,
current_user
,
params
)
if
service
.
execute
head
:ok
else
head
:unprocessable_entity
end
end
def
generate
service
=
::
Boards
::
Lists
::
GenerateService
.
new
(
project
,
current_user
)
if
service
.
execute
render
json:
project
.
board
.
lists
.
label
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:description
,
:color
,
:priority
]
}
})
else
head
:unprocessable_entity
end
end
private
def
authorize_admin_list!
return
render_403
unless
can?
(
current_user
,
:admin_list
,
project
)
end
def
list_params
params
.
require
(
:list
).
permit
(
:label_id
)
end
def
move_params
params
.
require
(
:list
).
permit
(
:position
).
merge
(
id:
params
[
:id
])
end
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
end
end
end
config/routes.rb
View file @
57737785
...
...
@@ -857,14 +857,16 @@ Rails.application.routes.draw do
end
resource
:board
,
only:
[
:show
]
do
resources
:issues
,
only:
[
:update
],
controller: :board_issues
scope
module: :boards
do
resources
:issues
,
only:
[
:update
]
resources
:lists
,
only:
[
:create
,
:update
,
:destroy
],
controller: :board_lists
do
resources
:lists
,
only:
[
:create
,
:update
,
:destroy
]
do
collection
do
post
:generate
end
resources
:issues
,
only:
[
:index
],
controller: :board_issues
resources
:issues
,
only:
[
:index
]
end
end
end
...
...
spec/controllers/projects/board
_
issues_controller_spec.rb
→
spec/controllers/projects/board
s/
issues_controller_spec.rb
View file @
57737785
require
'spec_helper'
describe
Projects
::
BoardIssuesController
do
describe
Projects
::
Board
s
::
IssuesController
do
let
(
:project
)
{
create
(
:project_with_board
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
spec/controllers/projects/board
_
lists_controller_spec.rb
→
spec/controllers/projects/board
s/
lists_controller_spec.rb
View file @
57737785
require
'spec_helper'
describe
Projects
::
BoardListsController
do
describe
Projects
::
Board
s
::
ListsController
do
let
(
:project
)
{
create
(
:project_with_board
)
}
let
(
:board
)
{
project
.
board
}
let
(
:user
)
{
create
(
:user
)
}
...
...
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