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
de219055
Commit
de219055
authored
Jul 27, 2020
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add confidential attr to graphQL for notes update
- update mutation and specs - update graphql docs
parent
a22b50dc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
75 additions
and
15 deletions
+75
-15
app/graphql/mutations/notes/update/base.rb
app/graphql/mutations/notes/update/base.rb
+1
-1
app/graphql/mutations/notes/update/note.rb
app/graphql/mutations/notes/update/note.rb
+6
-1
changelogs/unreleased/207473-graphl-update-note-conf.yml
changelogs/unreleased/207473-graphl-update-note-conf.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+6
-1
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+13
-7
spec/requests/api/graphql/mutations/notes/update/note_spec.rb
.../requests/api/graphql/mutations/notes/update/note_spec.rb
+34
-5
spec/services/notes/update_service_spec.rb
spec/services/notes/update_service_spec.rb
+10
-0
No files found.
app/graphql/mutations/notes/update/base.rb
View file @
de219055
...
...
@@ -40,7 +40,7 @@ module Mutations
end
def
note_params
(
_note
,
args
)
{
note:
args
[
:body
]
}.
compact
{
note:
args
[
:body
]
,
confidential:
args
[
:confidential
]
}.
compact
end
end
end
...
...
app/graphql/mutations/notes/update/note.rb
View file @
de219055
...
...
@@ -8,9 +8,14 @@ module Mutations
argument
:body
,
GraphQL
::
STRING_TYPE
,
required:
tru
e
,
required:
fals
e
,
description:
copy_field_description
(
Types
::
Notes
::
NoteType
,
:body
)
argument
:confidential
,
GraphQL
::
BOOLEAN_TYPE
,
required:
false
,
description:
'The confidentiality flag of a note. Default is false.'
private
def
pre_update_checks!
(
note
,
_args
)
...
...
changelogs/unreleased/207473-graphl-update-note-conf.yml
0 → 100644
View file @
de219055
---
title
:
Add confidential attribute to graphQL for notes update
merge_request
:
37920
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
de219055
...
...
@@ -14312,13 +14312,18 @@ input UpdateNoteInput {
"""
Content
of
the
note
"""
body
:
String
!
body
:
String
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
The
confidentiality
flag
of
a
note
.
Default
is
false
.
"""
confidential
:
Boolean
"""
The
global
id
of
the
note
to
update
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
de219055
...
...
@@ -42306,13 +42306,19 @@
"name": "body",
"description": "Content of the note",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "confidential",
"description": "The confidentiality flag of a note. Default is false.",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null
},
spec/requests/api/graphql/mutations/notes/update/note_spec.rb
View file @
de219055
...
...
@@ -8,11 +8,9 @@ RSpec.describe 'Updating a Note' do
let!
(
:note
)
{
create
(
:note
,
note:
original_body
)
}
let
(
:original_body
)
{
'Initial body text'
}
let
(
:updated_body
)
{
'Updated body text'
}
let
(
:params
)
{
{
body:
updated_body
,
confidential:
true
}
}
let
(
:mutation
)
do
variables
=
{
id:
GitlabSchema
.
id_from_object
(
note
).
to_s
,
body:
updated_body
}
variables
=
params
.
merge
(
id:
GitlabSchema
.
id_from_object
(
note
).
to_s
)
graphql_mutation
(
:update_note
,
variables
)
end
...
...
@@ -31,6 +29,7 @@ RSpec.describe 'Updating a Note' do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
note
.
reload
.
note
).
to
eq
(
original_body
)
expect
(
note
.
confidential
).
to
be_falsey
end
end
...
...
@@ -43,12 +42,40 @@ RSpec.describe 'Updating a Note' do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
note
.
reload
.
note
).
to
eq
(
updated_body
)
expect
(
note
.
confidential
).
to
be_truthy
end
it
'returns the updated Note'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
mutation_response
[
'note'
][
'body'
]).
to
eq
(
updated_body
)
expect
(
mutation_response
[
'note'
][
'confidential'
]).
to
be_truthy
end
context
'when only confidential param is present'
do
let
(
:params
)
{
{
confidential:
true
}
}
it
'updates only the note confidentiality'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
note
.
reload
.
note
).
to
eq
(
original_body
)
expect
(
note
.
confidential
).
to
be_truthy
end
end
context
'when only body param is present'
do
let
(
:params
)
{
{
body:
updated_body
}
}
before
do
note
.
update_column
(
:confidential
,
true
)
end
it
'updates only the note body'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
note
.
reload
.
note
).
to
eq
(
updated_body
)
expect
(
note
.
confidential
).
to
be_truthy
end
end
context
'when there are ActiveRecord validation errors'
do
...
...
@@ -60,12 +87,14 @@ RSpec.describe 'Updating a Note' do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
note
.
reload
.
note
).
to
eq
(
original_body
)
expect
(
note
.
confidential
).
to
be_falsey
end
it
'returns the
Note with its original body
'
do
it
'returns the
original Note
'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
mutation_response
[
'note'
][
'body'
]).
to
eq
(
original_body
)
expect
(
mutation_response
[
'note'
][
'confidential'
]).
to
be_falsey
end
end
...
...
spec/services/notes/update_service_spec.rb
View file @
de219055
...
...
@@ -36,6 +36,16 @@ RSpec.describe Notes::UpdateService do
end
end
context
'with system note'
do
before
do
note
.
update_column
(
:system
,
true
)
end
it
'does not update the note'
do
expect
{
update_note
(
note:
'new text'
)
}.
not_to
change
{
note
.
reload
.
note
}
end
end
context
'suggestions'
do
it
'refreshes note suggestions'
do
markdown
=
<<-
MARKDOWN
.
strip_heredoc
...
...
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