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
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
Hide 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) => {
});
};
export
const
saveDiffDiscussion
=
({
dispatch
},
{
note
,
formData
})
=>
{
export
const
saveDiffDiscussion
=
({
state
,
dispatch
},
{
note
,
formData
})
=>
{
const
postData
=
getNoteFormData
({
commit
:
state
.
commit
,
note
,
...
formData
,
});
...
...
app/assets/javascripts/diffs/store/utils.js
View file @
e7439c31
...
...
@@ -27,6 +27,7 @@ export const getReversePosition = linePosition => {
export
function
getFormData
(
params
)
{
const
{
commit
,
note
,
noteableType
,
noteableData
,
...
...
@@ -66,7 +67,7 @@ export function getFormData(params) {
position
,
noteable_type
:
noteableType
,
noteable_id
:
noteableData
.
id
,
commit_id
:
''
,
commit_id
:
commit
&&
commit
.
id
,
type
:
diffFile
.
diff_refs
.
start_sha
&&
diffFile
.
diff_refs
.
head_sha
?
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, {
}
from
'
~/diffs/store/actions
'
;
import
*
as
types
from
'
~/diffs/store/mutation_types
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
mockDiffFile
from
'
spec/diffs/mock_data/diff_file
'
;
import
testAction
from
'
../../helpers/vuex_action_helper
'
;
describe
(
'
DiffsStoreActions
'
,
()
=>
{
...
...
@@ -607,11 +608,18 @@ describe('DiffsStoreActions', () => {
});
describe
(
'
saveDiffDiscussion
'
,
()
=>
{
beforeEach
(()
=>
{
spyOnDependency
(
actions
,
'
getNoteFormData
'
).
and
.
returnValue
(
'
testData
'
);
});
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
=>
{
switch
(
name
)
{
case
'
saveNote
'
:
...
...
@@ -625,11 +633,19 @@ describe('DiffsStoreActions', () => {
}
});
saveDiffDiscussion
({
dispatch
},
{
note
:
{},
formData
:
{}
})
saveDiffDiscussion
({
state
,
dispatch
},
{
note
,
formData
})
.
then
(()
=>
{
expect
(
dispatch
.
calls
.
argsFor
(
0
)).
toEqual
([
'
saveNote
'
,
'
testData
'
,
{
root
:
true
}]);
expect
(
dispatch
.
calls
.
argsFor
(
1
)).
toEqual
([
'
updateDiscussion
'
,
'
test
'
,
{
root
:
true
}]);
expect
(
dispatch
.
calls
.
argsFor
(
2
)).
toEqual
([
'
assignDiscussionsToDiff
'
,
[
'
discussion
'
]]);
const
{
calls
}
=
dispatch
;
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
)
.
catch
(
done
.
fail
);
...
...
spec/javascripts/diffs/store/utils_spec.js
View file @
e7439c31
...
...
@@ -150,7 +150,7 @@ describe('DiffsStoreUtils', () => {
note
:
{
noteable_type
:
options
.
noteableType
,
noteable_id
:
options
.
noteableData
.
id
,
commit_id
:
''
,
commit_id
:
undefined
,
type
:
DIFF_NOTE_TYPE
,
line_code
:
options
.
noteTargetLine
.
line_code
,
note
:
options
.
note
,
...
...
@@ -209,7 +209,7 @@ describe('DiffsStoreUtils', () => {
note
:
{
noteable_type
:
options
.
noteableType
,
noteable_id
:
options
.
noteableData
.
id
,
commit_id
:
''
,
commit_id
:
undefined
,
type
:
LEGACY_DIFF_NOTE_TYPE
,
line_code
:
options
.
noteTargetLine
.
line_code
,
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