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
207e701e
Commit
207e701e
authored
Dec 16, 2019
by
nuwe1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add save tests
parent
d301f5bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
23 deletions
+60
-23
app/assets/javascripts/boards/stores/boards_store.js
app/assets/javascripts/boards/stores/boards_store.js
+23
-23
spec/frontend/boards/boards_store_spec.js
spec/frontend/boards/boards_store_spec.js
+37
-0
No files found.
app/assets/javascripts/boards/stores/boards_store.js
View file @
207e701e
...
...
@@ -408,6 +408,29 @@ const boardsStore = {
return
axios
.
delete
(
`
${
this
.
state
.
endpoints
.
listsEndpoint
}
/
${
id
}
`
);
},
saveList
(
list
)
{
const
entity
=
list
.
label
||
list
.
assignee
||
list
.
milestone
;
let
entityType
=
''
;
if
(
list
.
label
)
{
entityType
=
'
label_id
'
;
}
else
if
(
list
.
assignee
)
{
entityType
=
'
assignee_id
'
;
}
else
if
(
IS_EE
&&
list
.
milestone
)
{
entityType
=
'
milestone_id
'
;
}
return
this
.
createList
(
entity
.
id
,
entityType
)
.
then
(
res
=>
res
.
data
)
.
then
(
data
=>
{
list
.
id
=
data
.
id
;
list
.
type
=
data
.
list_type
;
list
.
position
=
data
.
position
;
list
.
label
=
data
.
label
;
return
list
.
getIssues
();
});
},
getIssuesForList
(
id
,
filter
=
{})
{
const
data
=
{
id
};
Object
.
keys
(
filter
).
forEach
(
key
=>
{
...
...
@@ -525,29 +548,6 @@ const boardsStore = {
clearMultiSelect
()
{
this
.
multiSelect
.
list
=
[];
},
saveList
(
list
)
{
const
entity
=
list
.
label
||
list
.
assignee
||
list
.
milestone
;
let
entityType
=
''
;
if
(
list
.
label
)
{
entityType
=
'
label_id
'
;
}
else
if
(
list
.
assignee
)
{
entityType
=
'
assignee_id
'
;
}
else
if
(
IS_EE
&&
list
.
milestone
)
{
entityType
=
'
milestone_id
'
;
}
return
this
.
createList
(
entity
.
id
,
entityType
)
.
then
(
res
=>
res
.
data
)
.
then
(
data
=>
{
list
.
id
=
data
.
id
;
list
.
type
=
data
.
list_type
;
list
.
position
=
data
.
position
;
list
.
label
=
data
.
label
;
return
list
.
getIssues
();
});
},
};
BoardsStoreEE
.
initEESpecific
(
boardsStore
);
...
...
spec/frontend/boards/boards_store_spec.js
View file @
207e701e
...
...
@@ -189,6 +189,42 @@ describe('boardsStore', () => {
});
});
});
describe
(
'
saveList
'
,()
=>
{
const
entityType
=
'
moorhen
'
;
const
entity
.
id
=
'
quack
'
;
const
expectedRequest
=
expect
.
objectContaining
({
data
:
JSON
.
stringify
({
list
:
{
[
entityType
]:
entityId
}
}),
});
let
requestSpy
;
beforeEach
(()
=>
{
requestSpy
=
jest
.
fn
();
axiosMock
.
onPost
(
endpoints
.
listsEndpoint
).
replyOnce
(
config
=>
requestSpy
(
config
));
});
it
(
'
makes a request to save a list
'
,
()
=>
{
requestSpy
.
mockReturnValue
([
200
,
dummyResponse
]);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
boardsStore
.
saveList
(
this
))
.
resolves
.
toEqual
(
expectedResponse
)
.
then
(()
=>
{
expect
(
requestSpy
).
toHaveBeenCalledWith
(
expectedRequest
);
});
});
it
(
'
fails for error response
'
,
()
=>
{
requestSpy
.
mockReturnValue
([
500
]);
return
expect
(
boardsStore
.
saveList
(
this
))
.
rejects
.
toThrow
()
.
then
(()
=>
{
expect
(
requestSpy
).
toHaveBeenCalledWith
(
expectedRequest
);
});
});
});
describe
(
'
getIssuesForList
'
,
()
=>
{
const
id
=
'
TOO-MUCH
'
;
...
...
@@ -575,6 +611,7 @@ describe('boardsStore', () => {
});
});
describe
(
'
when created
'
,
()
=>
{
beforeEach
(()
=>
{
setupDefaultResponses
();
...
...
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