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
98e31bf4
Commit
98e31bf4
authored
Mar 10, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added mutation spec
parent
87be05bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
app/assets/javascripts/notes/stores/mutations.js
app/assets/javascripts/notes/stores/mutations.js
+8
-6
spec/javascripts/notes/stores/mutation_spec.js
spec/javascripts/notes/stores/mutation_spec.js
+13
-2
No files found.
app/assets/javascripts/notes/stores/mutations.js
View file @
98e31bf4
...
...
@@ -93,16 +93,18 @@ export default {
// To support legacy notes, should be very rare case.
if
(
note
.
individual_note
&&
note
.
notes
.
length
>
1
)
{
note
.
notes
.
forEach
((
n
)
=>
{
const
nn
=
Object
.
assign
({},
note
);
nn
.
notes
=
[
n
];
// override notes array to only have one item to mimick individual_note
notes
.
push
(
nn
);
notes
.
push
({
...
note
,
notes
:
[
n
],
// override notes array to only have one item to mimick individual_note
});
});
}
else
{
const
nn
=
Object
.
assign
({},
note
);
const
oldNote
=
utils
.
findNoteObjectById
(
state
.
notes
,
note
.
id
);
nn
.
expanded
=
oldNote
?
oldNote
.
expanded
:
note
.
expanded
;
notes
.
push
(
nn
);
notes
.
push
({
...
note
,
expanded
:
(
oldNote
?
oldNote
.
expanded
:
note
.
expanded
),
});
}
});
...
...
spec/javascripts/notes/stores/mutation_spec.js
View file @
98e31bf4
...
...
@@ -101,10 +101,21 @@ describe('Notes Store mutations', () => {
const
state
=
{
notes
:
[],
};
const
legacyNote
=
{
id
:
2
,
individual_note
:
true
,
notes
:
[{
note
:
'
1
'
,
},
{
note
:
'
2
'
,
}],
};
mutations
.
SET_INITIAL_NOTES
(
state
,
[
note
]);
mutations
.
SET_INITIAL_NOTES
(
state
,
[
note
,
legacyNote
]);
expect
(
state
.
notes
[
0
].
id
).
toEqual
(
note
.
id
);
expect
(
state
.
notes
.
length
).
toEqual
(
1
);
expect
(
state
.
notes
[
1
].
notes
[
0
].
note
).
toBe
(
legacyNote
.
notes
[
0
].
note
);
expect
(
state
.
notes
[
2
].
notes
[
0
].
note
).
toBe
(
legacyNote
.
notes
[
1
].
note
);
expect
(
state
.
notes
.
length
).
toEqual
(
3
);
});
});
...
...
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