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
a5c9e82f
Commit
a5c9e82f
authored
Jul 12, 2019
by
Winnie Hellmann
Committed by
Mike Greiling
Jul 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move functions for multiple boards in BoardService to core
parent
7ca12def
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
209 additions
and
214 deletions
+209
-214
app/assets/javascripts/boards/services/board_service.js
app/assets/javascripts/boards/services/board_service.js
+16
-0
app/assets/javascripts/boards/stores/boards_store.js
app/assets/javascripts/boards/stores/boards_store.js
+34
-0
ee/app/assets/javascripts/boards/services/board_service.js
ee/app/assets/javascripts/boards/services/board_service.js
+0
-18
ee/app/assets/javascripts/boards/stores/boards_store_ee.js
ee/app/assets/javascripts/boards/stores/boards_store_ee.js
+0
-34
ee/spec/frontend/boards/services/board_service_spec.js
ee/spec/frontend/boards/services/board_service_spec.js
+0
-162
spec/frontend/boards/services/board_service_spec.js
spec/frontend/boards/services/board_service_spec.js
+159
-0
No files found.
app/assets/javascripts/boards/services/board_service.js
View file @
a5c9e82f
...
...
@@ -62,6 +62,22 @@ export default class BoardService {
static
toggleIssueSubscription
(
endpoint
)
{
return
boardsStore
.
toggleIssueSubscription
(
endpoint
);
}
allBoards
()
{
return
boardsStore
.
allBoards
();
}
recentBoards
()
{
return
boardsStore
.
recentBoards
();
}
createBoard
(
board
)
{
return
boardsStore
.
createBoard
(
board
);
}
deleteBoard
({
id
})
{
return
boardsStore
.
deleteBoard
({
id
});
}
}
window
.
BoardService
=
BoardService
;
app/assets/javascripts/boards/stores/boards_store.js
View file @
a5c9e82f
...
...
@@ -340,6 +340,40 @@ const boardsStore = {
toggleIssueSubscription
(
endpoint
)
{
return
axios
.
post
(
endpoint
);
},
allBoards
()
{
return
axios
.
get
(
this
.
generateBoardsPath
());
},
recentBoards
()
{
return
axios
.
get
(
this
.
state
.
endpoints
.
recentBoardsEndpoint
);
},
createBoard
(
board
)
{
const
boardPayload
=
{
...
board
};
boardPayload
.
label_ids
=
(
board
.
labels
||
[]).
map
(
b
=>
b
.
id
);
if
(
boardPayload
.
label_ids
.
length
===
0
)
{
boardPayload
.
label_ids
=
[
''
];
}
if
(
boardPayload
.
assignee
)
{
boardPayload
.
assignee_id
=
boardPayload
.
assignee
.
id
;
}
if
(
boardPayload
.
milestone
)
{
boardPayload
.
milestone_id
=
boardPayload
.
milestone
.
id
;
}
if
(
boardPayload
.
id
)
{
return
axios
.
put
(
this
.
generateBoardsPath
(
boardPayload
.
id
),
{
board
:
boardPayload
});
}
return
axios
.
post
(
this
.
generateBoardsPath
(),
{
board
:
boardPayload
});
},
deleteBoard
({
id
})
{
return
axios
.
delete
(
this
.
generateBoardsPath
(
id
));
},
};
BoardsStoreEE
.
initEESpecific
(
boardsStore
);
...
...
ee/app/assets/javascripts/boards/services/board_service.js
View file @
a5c9e82f
/* eslint-disable class-methods-use-this */
import
BoardService
from
'
~/boards/services/board_service
'
;
import
boardsStore
from
'
~/boards/stores/boards_store
'
;
export
default
class
BoardServiceEE
extends
BoardService
{
allBoards
()
{
return
boardsStore
.
allBoards
();
}
recentBoards
()
{
return
boardsStore
.
recentBoards
();
}
createBoard
(
board
)
{
return
boardsStore
.
createBoard
(
board
);
}
deleteBoard
({
id
})
{
return
boardsStore
.
deleteBoard
({
id
});
}
static
updateWeight
(
endpoint
,
weight
=
null
)
{
return
boardsStore
.
updateWeight
(
endpoint
,
weight
);
}
...
...
ee/app/assets/javascripts/boards/stores/boards_store_ee.js
View file @
a5c9e82f
...
...
@@ -67,40 +67,6 @@ class BoardsStoreEE {
sidebarEventHub
.
$on
(
'
updateWeight
'
,
this
.
updateWeight
.
bind
(
this
));
Object
.
assign
(
this
.
store
,
{
allBoards
()
{
return
axios
.
get
(
this
.
generateBoardsPath
());
},
recentBoards
()
{
return
axios
.
get
(
this
.
state
.
endpoints
.
recentBoardsEndpoint
);
},
createBoard
(
board
)
{
const
boardPayload
=
{
...
board
};
boardPayload
.
label_ids
=
(
board
.
labels
||
[]).
map
(
b
=>
b
.
id
);
if
(
boardPayload
.
label_ids
.
length
===
0
)
{
boardPayload
.
label_ids
=
[
''
];
}
if
(
boardPayload
.
assignee
)
{
boardPayload
.
assignee_id
=
boardPayload
.
assignee
.
id
;
}
if
(
boardPayload
.
milestone
)
{
boardPayload
.
milestone_id
=
boardPayload
.
milestone
.
id
;
}
if
(
boardPayload
.
id
)
{
return
axios
.
put
(
this
.
generateBoardsPath
(
boardPayload
.
id
),
{
board
:
boardPayload
});
}
return
axios
.
post
(
this
.
generateBoardsPath
(),
{
board
:
boardPayload
});
},
deleteBoard
({
id
})
{
return
axios
.
delete
(
this
.
generateBoardsPath
(
id
));
},
updateWeight
(
endpoint
,
weight
=
null
)
{
return
axios
.
put
(
endpoint
,
{
weight
,
...
...
ee/spec/frontend/boards/services/board_service_spec.js
View file @
a5c9e82f
...
...
@@ -19,7 +19,6 @@ describe('BoardService', () => {
recentBoardsEndpoint
:
`
${
TEST_HOST
}
/recent/boards`
,
};
let
service
;
let
axiosMock
;
beforeEach
(()
=>
{
...
...
@@ -29,167 +28,6 @@ describe('BoardService', () => {
...
endpoints
,
boardId
,
});
service
=
new
BoardServiceEE
();
});
describe
(
'
allBoards
'
,
()
=>
{
const
url
=
`
${
endpoints
.
boardsEndpoint
}
.json`
;
it
(
'
makes a request to fetch all boards
'
,
()
=>
{
axiosMock
.
onGet
(
url
).
replyOnce
(
200
,
dummyResponse
);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
service
.
allBoards
()).
resolves
.
toEqual
(
expectedResponse
);
});
it
(
'
fails for error response
'
,
()
=>
{
axiosMock
.
onGet
(
url
).
replyOnce
(
500
);
return
expect
(
service
.
allBoards
()).
rejects
.
toThrow
();
});
});
describe
(
'
recentBoards
'
,
()
=>
{
const
url
=
`
${
endpoints
.
recentBoardsEndpoint
}
.json`
;
it
(
'
makes a request to fetch all boards
'
,
()
=>
{
axiosMock
.
onGet
(
url
).
replyOnce
(
200
,
dummyResponse
);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
service
.
recentBoards
()).
resolves
.
toEqual
(
expectedResponse
);
});
it
(
'
fails for error response
'
,
()
=>
{
axiosMock
.
onGet
(
url
).
replyOnce
(
500
);
return
expect
(
service
.
recentBoards
()).
rejects
.
toThrow
();
});
});
describe
(
'
createBoard
'
,
()
=>
{
const
labelIds
=
[
'
first label
'
,
'
second label
'
];
const
assigneeId
=
'
as sign ee
'
;
const
milestoneId
=
'
vegetable soup
'
;
const
board
=
{
labels
:
labelIds
.
map
(
id
=>
({
id
})),
assignee
:
{
id
:
assigneeId
},
milestone
:
{
id
:
milestoneId
},
};
describe
(
'
for existing board
'
,
()
=>
{
const
id
=
'
skate-board
'
;
const
url
=
`
${
endpoints
.
boardsEndpoint
}
/
${
id
}
.json`
;
const
expectedRequest
=
expect
.
objectContaining
({
data
:
JSON
.
stringify
({
board
:
{
...
board
,
id
,
label_ids
:
labelIds
,
assignee_id
:
assigneeId
,
milestone_id
:
milestoneId
,
},
}),
});
let
requestSpy
;
beforeEach
(()
=>
{
requestSpy
=
jest
.
fn
();
axiosMock
.
onPut
(
url
).
replyOnce
(
config
=>
requestSpy
(
config
));
});
it
(
'
makes a request to update the board
'
,
()
=>
{
requestSpy
.
mockReturnValue
([
200
,
dummyResponse
]);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
service
.
createBoard
({
...
board
,
id
,
}),
)
.
resolves
.
toEqual
(
expectedResponse
)
.
then
(()
=>
{
expect
(
requestSpy
).
toHaveBeenCalledWith
(
expectedRequest
);
});
});
it
(
'
fails for error response
'
,
()
=>
{
requestSpy
.
mockReturnValue
([
500
]);
return
expect
(
service
.
createBoard
({
...
board
,
id
,
}),
)
.
rejects
.
toThrow
()
.
then
(()
=>
{
expect
(
requestSpy
).
toHaveBeenCalledWith
(
expectedRequest
);
});
});
});
describe
(
'
for new board
'
,
()
=>
{
const
url
=
`
${
endpoints
.
boardsEndpoint
}
.json`
;
const
expectedRequest
=
expect
.
objectContaining
({
data
:
JSON
.
stringify
({
board
:
{
...
board
,
label_ids
:
labelIds
,
assignee_id
:
assigneeId
,
milestone_id
:
milestoneId
,
},
}),
});
let
requestSpy
;
beforeEach
(()
=>
{
requestSpy
=
jest
.
fn
();
axiosMock
.
onPost
(
url
).
replyOnce
(
config
=>
requestSpy
(
config
));
});
it
(
'
makes a request to create a new board
'
,
()
=>
{
requestSpy
.
mockReturnValue
([
200
,
dummyResponse
]);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
service
.
createBoard
(
board
))
.
resolves
.
toEqual
(
expectedResponse
)
.
then
(()
=>
{
expect
(
requestSpy
).
toHaveBeenCalledWith
(
expectedRequest
);
});
});
it
(
'
fails for error response
'
,
()
=>
{
requestSpy
.
mockReturnValue
([
500
]);
return
expect
(
service
.
createBoard
(
board
))
.
rejects
.
toThrow
()
.
then
(()
=>
{
expect
(
requestSpy
).
toHaveBeenCalledWith
(
expectedRequest
);
});
});
});
});
describe
(
'
deleteBoard
'
,
()
=>
{
const
id
=
'
capsized
'
;
const
url
=
`
${
endpoints
.
boardsEndpoint
}
/
${
id
}
.json`
;
it
(
'
makes a request to delete a boards
'
,
()
=>
{
axiosMock
.
onDelete
(
url
).
replyOnce
(
200
,
dummyResponse
);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
service
.
deleteBoard
({
id
})).
resolves
.
toEqual
(
expectedResponse
);
});
it
(
'
fails for error response
'
,
()
=>
{
axiosMock
.
onDelete
(
url
).
replyOnce
(
500
);
return
expect
(
service
.
deleteBoard
({
id
})).
rejects
.
toThrow
();
});
});
describe
(
'
updateWeight
'
,
()
=>
{
...
...
spec/frontend/boards/services/board_service_spec.js
View file @
a5c9e82f
...
...
@@ -389,4 +389,163 @@ describe('BoardService', () => {
return
expect
(
BoardService
.
toggleIssueSubscription
(
dummyEndpoint
)).
rejects
.
toThrow
();
});
});
describe
(
'
allBoards
'
,
()
=>
{
const
url
=
`
${
endpoints
.
boardsEndpoint
}
.json`
;
it
(
'
makes a request to fetch all boards
'
,
()
=>
{
axiosMock
.
onGet
(
url
).
replyOnce
(
200
,
dummyResponse
);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
service
.
allBoards
()).
resolves
.
toEqual
(
expectedResponse
);
});
it
(
'
fails for error response
'
,
()
=>
{
axiosMock
.
onGet
(
url
).
replyOnce
(
500
);
return
expect
(
service
.
allBoards
()).
rejects
.
toThrow
();
});
});
describe
(
'
recentBoards
'
,
()
=>
{
const
url
=
`
${
endpoints
.
recentBoardsEndpoint
}
.json`
;
it
(
'
makes a request to fetch all boards
'
,
()
=>
{
axiosMock
.
onGet
(
url
).
replyOnce
(
200
,
dummyResponse
);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
service
.
recentBoards
()).
resolves
.
toEqual
(
expectedResponse
);
});
it
(
'
fails for error response
'
,
()
=>
{
axiosMock
.
onGet
(
url
).
replyOnce
(
500
);
return
expect
(
service
.
recentBoards
()).
rejects
.
toThrow
();
});
});
describe
(
'
createBoard
'
,
()
=>
{
const
labelIds
=
[
'
first label
'
,
'
second label
'
];
const
assigneeId
=
'
as sign ee
'
;
const
milestoneId
=
'
vegetable soup
'
;
const
board
=
{
labels
:
labelIds
.
map
(
id
=>
({
id
})),
assignee
:
{
id
:
assigneeId
},
milestone
:
{
id
:
milestoneId
},
};
describe
(
'
for existing board
'
,
()
=>
{
const
id
=
'
skate-board
'
;
const
url
=
`
${
endpoints
.
boardsEndpoint
}
/
${
id
}
.json`
;
const
expectedRequest
=
expect
.
objectContaining
({
data
:
JSON
.
stringify
({
board
:
{
...
board
,
id
,
label_ids
:
labelIds
,
assignee_id
:
assigneeId
,
milestone_id
:
milestoneId
,
},
}),
});
let
requestSpy
;
beforeEach
(()
=>
{
requestSpy
=
jest
.
fn
();
axiosMock
.
onPut
(
url
).
replyOnce
(
config
=>
requestSpy
(
config
));
});
it
(
'
makes a request to update the board
'
,
()
=>
{
requestSpy
.
mockReturnValue
([
200
,
dummyResponse
]);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
service
.
createBoard
({
...
board
,
id
,
}),
)
.
resolves
.
toEqual
(
expectedResponse
)
.
then
(()
=>
{
expect
(
requestSpy
).
toHaveBeenCalledWith
(
expectedRequest
);
});
});
it
(
'
fails for error response
'
,
()
=>
{
requestSpy
.
mockReturnValue
([
500
]);
return
expect
(
service
.
createBoard
({
...
board
,
id
,
}),
)
.
rejects
.
toThrow
()
.
then
(()
=>
{
expect
(
requestSpy
).
toHaveBeenCalledWith
(
expectedRequest
);
});
});
});
describe
(
'
for new board
'
,
()
=>
{
const
url
=
`
${
endpoints
.
boardsEndpoint
}
.json`
;
const
expectedRequest
=
expect
.
objectContaining
({
data
:
JSON
.
stringify
({
board
:
{
...
board
,
label_ids
:
labelIds
,
assignee_id
:
assigneeId
,
milestone_id
:
milestoneId
,
},
}),
});
let
requestSpy
;
beforeEach
(()
=>
{
requestSpy
=
jest
.
fn
();
axiosMock
.
onPost
(
url
).
replyOnce
(
config
=>
requestSpy
(
config
));
});
it
(
'
makes a request to create a new board
'
,
()
=>
{
requestSpy
.
mockReturnValue
([
200
,
dummyResponse
]);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
service
.
createBoard
(
board
))
.
resolves
.
toEqual
(
expectedResponse
)
.
then
(()
=>
{
expect
(
requestSpy
).
toHaveBeenCalledWith
(
expectedRequest
);
});
});
it
(
'
fails for error response
'
,
()
=>
{
requestSpy
.
mockReturnValue
([
500
]);
return
expect
(
service
.
createBoard
(
board
))
.
rejects
.
toThrow
()
.
then
(()
=>
{
expect
(
requestSpy
).
toHaveBeenCalledWith
(
expectedRequest
);
});
});
});
});
describe
(
'
deleteBoard
'
,
()
=>
{
const
id
=
'
capsized
'
;
const
url
=
`
${
endpoints
.
boardsEndpoint
}
/
${
id
}
.json`
;
it
(
'
makes a request to delete a boards
'
,
()
=>
{
axiosMock
.
onDelete
(
url
).
replyOnce
(
200
,
dummyResponse
);
const
expectedResponse
=
expect
.
objectContaining
({
data
:
dummyResponse
});
return
expect
(
service
.
deleteBoard
({
id
})).
resolves
.
toEqual
(
expectedResponse
);
});
it
(
'
fails for error response
'
,
()
=>
{
axiosMock
.
onDelete
(
url
).
replyOnce
(
500
);
return
expect
(
service
.
deleteBoard
({
id
})).
rejects
.
toThrow
();
});
});
});
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