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
Boxiang Sun
gitlab-ce
Commits
e7439c31
Commit
e7439c31
authored
Nov 26, 2018
by
Winnie Hellmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass commit when posting diff discussions
parent
cfe48479
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
12 deletions
+35
-12
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+2
-1
app/assets/javascripts/diffs/store/utils.js
app/assets/javascripts/diffs/store/utils.js
+2
-1
changelogs/unreleased/winh-merge-request-diff-discussion-commit-id.yml
...released/winh-merge-request-diff-discussion-commit-id.yml
+5
-0
spec/javascripts/diffs/store/actions_spec.js
spec/javascripts/diffs/store/actions_spec.js
+24
-8
spec/javascripts/diffs/store/utils_spec.js
spec/javascripts/diffs/store/utils_spec.js
+2
-2
No files found.
app/assets/javascripts/diffs/store/actions.js
View file @
e7439c31
...
@@ -192,8 +192,9 @@ export const toggleFileDiscussions = ({ getters, dispatch }, diff) => {
...
@@ -192,8 +192,9 @@ export const toggleFileDiscussions = ({ getters, dispatch }, diff) => {
});
});
};
};
export
const
saveDiffDiscussion
=
({
dispatch
},
{
note
,
formData
})
=>
{
export
const
saveDiffDiscussion
=
({
state
,
dispatch
},
{
note
,
formData
})
=>
{
const
postData
=
getNoteFormData
({
const
postData
=
getNoteFormData
({
commit
:
state
.
commit
,
note
,
note
,
...
formData
,
...
formData
,
});
});
...
...
app/assets/javascripts/diffs/store/utils.js
View file @
e7439c31
...
@@ -27,6 +27,7 @@ export const getReversePosition = linePosition => {
...
@@ -27,6 +27,7 @@ export const getReversePosition = linePosition => {
export
function
getFormData
(
params
)
{
export
function
getFormData
(
params
)
{
const
{
const
{
commit
,
note
,
note
,
noteableType
,
noteableType
,
noteableData
,
noteableData
,
...
@@ -66,7 +67,7 @@ export function getFormData(params) {
...
@@ -66,7 +67,7 @@ export function getFormData(params) {
position
,
position
,
noteable_type
:
noteableType
,
noteable_type
:
noteableType
,
noteable_id
:
noteableData
.
id
,
noteable_id
:
noteableData
.
id
,
commit_id
:
''
,
commit_id
:
commit
&&
commit
.
id
,
type
:
type
:
diffFile
.
diff_refs
.
start_sha
&&
diffFile
.
diff_refs
.
head_sha
diffFile
.
diff_refs
.
start_sha
&&
diffFile
.
diff_refs
.
head_sha
?
DIFF_NOTE_TYPE
?
DIFF_NOTE_TYPE
...
...
changelogs/unreleased/winh-merge-request-diff-discussion-commit-id.yml
0 → 100644
View file @
e7439c31
---
title
:
Pass commit when posting diff discussions
merge_request
:
23371
author
:
type
:
fixed
spec/javascripts/diffs/store/actions_spec.js
View file @
e7439c31
...
@@ -29,6 +29,7 @@ import actions, {
...
@@ -29,6 +29,7 @@ import actions, {
}
from
'
~/diffs/store/actions
'
;
}
from
'
~/diffs/store/actions
'
;
import
*
as
types
from
'
~/diffs/store/mutation_types
'
;
import
*
as
types
from
'
~/diffs/store/mutation_types
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
mockDiffFile
from
'
spec/diffs/mock_data/diff_file
'
;
import
testAction
from
'
../../helpers/vuex_action_helper
'
;
import
testAction
from
'
../../helpers/vuex_action_helper
'
;
describe
(
'
DiffsStoreActions
'
,
()
=>
{
describe
(
'
DiffsStoreActions
'
,
()
=>
{
...
@@ -607,11 +608,18 @@ describe('DiffsStoreActions', () => {
...
@@ -607,11 +608,18 @@ describe('DiffsStoreActions', () => {
});
});
describe
(
'
saveDiffDiscussion
'
,
()
=>
{
describe
(
'
saveDiffDiscussion
'
,
()
=>
{
beforeEach
(()
=>
{
spyOnDependency
(
actions
,
'
getNoteFormData
'
).
and
.
returnValue
(
'
testData
'
);
});
it
(
'
dispatches actions
'
,
done
=>
{
it
(
'
dispatches actions
'
,
done
=>
{
const
commitId
=
'
something
'
;
const
formData
=
{
diffFile
:
{
...
mockDiffFile
},
noteableData
:
{},
};
const
note
=
{};
const
state
=
{
commit
:
{
id
:
commitId
,
},
};
const
dispatch
=
jasmine
.
createSpy
(
'
dispatch
'
).
and
.
callFake
(
name
=>
{
const
dispatch
=
jasmine
.
createSpy
(
'
dispatch
'
).
and
.
callFake
(
name
=>
{
switch
(
name
)
{
switch
(
name
)
{
case
'
saveNote
'
:
case
'
saveNote
'
:
...
@@ -625,11 +633,19 @@ describe('DiffsStoreActions', () => {
...
@@ -625,11 +633,19 @@ describe('DiffsStoreActions', () => {
}
}
});
});
saveDiffDiscussion
({
dispatch
},
{
note
:
{},
formData
:
{}
})
saveDiffDiscussion
({
state
,
dispatch
},
{
note
,
formData
})
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
dispatch
.
calls
.
argsFor
(
0
)).
toEqual
([
'
saveNote
'
,
'
testData
'
,
{
root
:
true
}]);
const
{
calls
}
=
dispatch
;
expect
(
dispatch
.
calls
.
argsFor
(
1
)).
toEqual
([
'
updateDiscussion
'
,
'
test
'
,
{
root
:
true
}]);
expect
(
dispatch
.
calls
.
argsFor
(
2
)).
toEqual
([
'
assignDiscussionsToDiff
'
,
[
'
discussion
'
]]);
expect
(
calls
.
count
()).
toBe
(
5
);
expect
(
calls
.
argsFor
(
0
)).
toEqual
([
'
saveNote
'
,
jasmine
.
any
(
Object
),
{
root
:
true
}]);
const
postData
=
calls
.
argsFor
(
0
)[
1
];
expect
(
postData
.
data
.
note
.
commit_id
).
toBe
(
commitId
);
expect
(
calls
.
argsFor
(
1
)).
toEqual
([
'
updateDiscussion
'
,
'
test
'
,
{
root
:
true
}]);
expect
(
calls
.
argsFor
(
2
)).
toEqual
([
'
assignDiscussionsToDiff
'
,
[
'
discussion
'
]]);
})
})
.
then
(
done
)
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
...
...
spec/javascripts/diffs/store/utils_spec.js
View file @
e7439c31
...
@@ -150,7 +150,7 @@ describe('DiffsStoreUtils', () => {
...
@@ -150,7 +150,7 @@ describe('DiffsStoreUtils', () => {
note
:
{
note
:
{
noteable_type
:
options
.
noteableType
,
noteable_type
:
options
.
noteableType
,
noteable_id
:
options
.
noteableData
.
id
,
noteable_id
:
options
.
noteableData
.
id
,
commit_id
:
''
,
commit_id
:
undefined
,
type
:
DIFF_NOTE_TYPE
,
type
:
DIFF_NOTE_TYPE
,
line_code
:
options
.
noteTargetLine
.
line_code
,
line_code
:
options
.
noteTargetLine
.
line_code
,
note
:
options
.
note
,
note
:
options
.
note
,
...
@@ -209,7 +209,7 @@ describe('DiffsStoreUtils', () => {
...
@@ -209,7 +209,7 @@ describe('DiffsStoreUtils', () => {
note
:
{
note
:
{
noteable_type
:
options
.
noteableType
,
noteable_type
:
options
.
noteableType
,
noteable_id
:
options
.
noteableData
.
id
,
noteable_id
:
options
.
noteableData
.
id
,
commit_id
:
''
,
commit_id
:
undefined
,
type
:
LEGACY_DIFF_NOTE_TYPE
,
type
:
LEGACY_DIFF_NOTE_TYPE
,
line_code
:
options
.
noteTargetLine
.
line_code
,
line_code
:
options
.
noteTargetLine
.
line_code
,
note
:
options
.
note
,
note
:
options
.
note
,
...
...
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