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
2ba71571
Commit
2ba71571
authored
Oct 25, 2018
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify query and add tests for authorization change
parent
6dda8592
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
app/controllers/concerns/boards_responses.rb
app/controllers/concerns/boards_responses.rb
+3
-7
spec/controllers/boards/issues_controller_spec.rb
spec/controllers/boards/issues_controller_spec.rb
+15
-4
No files found.
app/controllers/concerns/boards_responses.rb
View file @
2ba71571
...
@@ -50,14 +50,10 @@ module BoardsResponses
...
@@ -50,14 +50,10 @@ module BoardsResponses
end
end
def
authorize_create_issue
def
authorize_create_issue
board
=
board_parent
.
boards
.
find
(
issue_params
[
:board
_id
])
list
=
List
.
find
(
issue_params
[
:list
_id
])
list
=
board
.
lists
.
find
(
issue_params
[
:list_id
])
action
=
list
.
backlog?
?
:create_issue
:
:admin_issue
if
list
.
backlog?
authorize_action_for!
(
project
,
action
)
authorize_action_for!
(
project
,
:create_issue
)
else
authorize_action_for!
(
project
,
:admin_issue
)
end
end
end
def
authorize_admin_list
def
authorize_admin_list
...
...
spec/controllers/boards/issues_controller_spec.rb
View file @
2ba71571
...
@@ -208,11 +208,22 @@ describe Boards::IssuesController do
...
@@ -208,11 +208,22 @@ describe Boards::IssuesController do
end
end
end
end
context
'with unauthorized user'
do
context
'with guest user'
do
it
'returns a forbidden 403 response'
do
context
'in open list'
do
create_issue
user:
guest
,
board:
board
,
list:
list1
,
title:
'New issue'
it
'returns a successful 200 response'
do
open_list
=
board
.
lists
.
create
(
list_type: :backlog
)
create_issue
user:
guest
,
board:
board
,
list:
open_list
,
title:
'New issue'
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
context
'in label list'
do
it
'returns a forbidden 403 response'
do
create_issue
user:
guest
,
board:
board
,
list:
list1
,
title:
'New issue'
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
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