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
2b82f907
Commit
2b82f907
authored
Aug 31, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check the discussion lock only for issuables & clean style
parent
3d2917bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+1
-1
app/policies/note_policy.rb
app/policies/note_policy.rb
+1
-1
spec/controllers/projects/notes_controller_spec.rb
spec/controllers/projects/notes_controller_spec.rb
+2
-2
No files found.
app/controllers/projects/notes_controller.rb
View file @
2b82f907
...
...
@@ -77,7 +77,7 @@ class Projects::NotesController < Projects::ApplicationController
def
authorize_create_note!
noteable_type
=
note_params
[
:noteable_type
]
return
unless
[
'MergeRequest'
,
'Issue'
].
include?
(
noteable_type
)
return
unless
%w[MergeRequest Issue
]
.
include?
(
noteable_type
)
return
access_denied!
unless
can?
(
current_user
,
:create_note
,
project
)
noteable
=
noteable_type
.
constantize
.
find
(
note_params
[
:noteable_id
])
...
...
app/policies/note_policy.rb
View file @
2b82f907
...
...
@@ -7,7 +7,7 @@ class NotePolicy < BasePolicy
condition
(
:is_noteable_author
)
{
@user
&&
@subject
.
noteable
.
author_id
==
@user
.
id
}
condition
(
:editable
,
scope: :subject
)
{
@subject
.
editable?
}
condition
(
:locked
)
{
@subject
.
noteable
.
discussion_locked?
}
condition
(
:locked
)
{
[
MergeRequest
,
Issue
].
include?
(
@subject
.
noteable
.
class
)
&&
@subject
.
noteable
.
discussion_locked?
}
rule
{
~
editable
|
anonymous
}.
prevent
:edit_note
...
...
spec/controllers/projects/notes_controller_spec.rb
View file @
2b82f907
...
...
@@ -253,7 +253,7 @@ describe Projects::NotesController do
end
it
'creates a new note'
do
expect
{
post
:create
,
request_params
}.
to
change
{
Note
.
count
}.
by
(
1
)
expect
{
post
:create
,
request_params
}.
to
change
{
Note
.
count
}.
by
(
1
)
end
end
...
...
@@ -269,7 +269,7 @@ describe Projects::NotesController do
end
it
'does not create a new note'
do
expect
{
post
:create
,
request_params
}.
not_to
change
{
Note
.
count
}
expect
{
post
:create
,
request_params
}.
not_to
change
{
Note
.
count
}
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