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
ef3eb79a
Commit
ef3eb79a
authored
Jun 30, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reject creating boards when the feature is not available
parent
e5da0e50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
22 deletions
+37
-22
app/controllers/ee/projects/boards_controller.rb
app/controllers/ee/projects/boards_controller.rb
+1
-0
spec/controllers/ee/projects/boards_controller_spec.rb
spec/controllers/ee/projects/boards_controller_spec.rb
+36
-22
No files found.
app/controllers/ee/projects/boards_controller.rb
View file @
ef3eb79a
...
...
@@ -3,6 +3,7 @@ module EE
module
BoardsController
extend
ActiveSupport
::
Concern
prepended
do
before_action
:check_multiple_issue_boards_available!
,
only:
[
:create
]
before_action
:authorize_admin_board!
,
only:
[
:create
,
:update
,
:destroy
]
before_action
:find_board
,
only:
[
:update
,
:destroy
]
end
...
...
spec/controllers/ee/projects/boards_controller_spec.rb
View file @
ef3eb79a
...
...
@@ -30,40 +30,54 @@ describe Projects::BoardsController do # rubocop:disable RSpec/FilePath
end
describe
'POST create'
do
context
'with valid params'
do
it
'returns a successful 200 response'
do
create_board
name:
'Backend'
context
'with the multiple issue boards available'
do
before
do
stub_licensed_features
(
multiple_issue_boards:
true
)
end
expect
(
response
).
to
have_http_status
(
200
)
context
'with valid params'
do
it
'returns a successful 200 response'
do
create_board
name:
'Backend'
expect
(
response
).
to
have_http_status
(
200
)
end
it
'returns the created board'
do
create_board
name:
'Backend'
expect
(
response
).
to
match_response_schema
(
'board'
)
end
end
it
'returns the created board'
do
create_board
name:
'Backend'
context
'with invalid params'
do
it
'returns an unprocessable entity 422 response'
do
create_board
name:
nil
expect
(
response
).
to
match_response_schema
(
'board'
)
expect
(
response
).
to
have_http_status
(
422
)
end
end
end
context
'with invalid params'
do
it
'returns an unprocessable entity 422 response'
do
create_board
name:
nil
context
'with unauthorized user'
do
before
do
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user
,
:read_project
,
project
).
and_return
(
true
)
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user
,
:admin_board
,
project
).
and_return
(
false
)
end
expect
(
response
).
to
have_http_status
(
422
)
it
'returns a not found 404 response'
do
create_board
name:
'Backend'
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
response
).
to
have_http_status
(
404
)
end
end
end
context
'with unauthorized user'
do
before
do
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user
,
:read_project
,
project
).
and_return
(
true
)
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user
,
:admin_board
,
project
).
and_return
(
false
)
end
it
'renders a 404 when multiple issue boards are not available'
do
stub_licensed_features
(
multiple_issue_boards:
false
)
it
'returns a not found 404 response'
do
create_board
name:
'Backend'
create_board
name:
'Backend'
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
response
).
to
have_http_status
(
404
)
end
expect
(
response
).
to
have_http_status
(
404
)
end
def
create_board
(
name
:)
...
...
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