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
4ffc863a
Commit
4ffc863a
authored
Dec 15, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch boards to Axios
parent
ac9e65a9
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
131 additions
and
148 deletions
+131
-148
app/assets/javascripts/boards/boards_bundle.js
app/assets/javascripts/boards/boards_bundle.js
+7
-8
app/assets/javascripts/boards/components/board_blank_state.js
...assets/javascripts/boards/components/board_blank_state.js
+1
-1
app/assets/javascripts/boards/components/modal/index.js
app/assets/javascripts/boards/components/modal/index.js
+1
-1
app/assets/javascripts/boards/models/list.js
app/assets/javascripts/boards/models/list.js
+3
-3
app/assets/javascripts/boards/services/board_service.js
app/assets/javascripts/boards/services/board_service.js
+49
-52
spec/javascripts/boards/board_blank_state_spec.js
spec/javascripts/boards/board_blank_state_spec.js
+10
-13
spec/javascripts/boards/board_card_spec.js
spec/javascripts/boards/board_card_spec.js
+7
-6
spec/javascripts/boards/board_list_spec.js
spec/javascripts/boards/board_list_spec.js
+7
-7
spec/javascripts/boards/board_new_issue_spec.js
spec/javascripts/boards/board_new_issue_spec.js
+13
-10
spec/javascripts/boards/boards_store_spec.js
spec/javascripts/boards/boards_store_spec.js
+8
-7
spec/javascripts/boards/components/board_spec.js
spec/javascripts/boards/components/board_spec.js
+1
-2
spec/javascripts/boards/issue_card_spec.js
spec/javascripts/boards/issue_card_spec.js
+1
-2
spec/javascripts/boards/issue_spec.js
spec/javascripts/boards/issue_spec.js
+1
-2
spec/javascripts/boards/list_spec.js
spec/javascripts/boards/list_spec.js
+9
-12
spec/javascripts/boards/mock_data.js
spec/javascripts/boards/mock_data.js
+13
-22
No files found.
app/assets/javascripts/boards/boards_bundle.js
View file @
4ffc863a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
VueResource
from
'
vue-resource
'
;
import
Flash
from
'
../flash
'
;
import
Flash
from
'
../flash
'
;
import
{
__
}
from
'
../locale
'
;
import
{
__
}
from
'
../locale
'
;
import
FilteredSearchBoards
from
'
./filtered_search_boards
'
;
import
FilteredSearchBoards
from
'
./filtered_search_boards
'
;
...
@@ -25,8 +24,6 @@ import './components/new_list_dropdown';
...
@@ -25,8 +24,6 @@ import './components/new_list_dropdown';
import
'
./components/modal/index
'
;
import
'
./components/modal/index
'
;
import
'
../vue_shared/vue_resource_interceptor
'
;
import
'
../vue_shared/vue_resource_interceptor
'
;
Vue
.
use
(
VueResource
);
$
(()
=>
{
$
(()
=>
{
const
$boardApp
=
document
.
getElementById
(
'
board-app
'
);
const
$boardApp
=
document
.
getElementById
(
'
board-app
'
);
const
Store
=
gl
.
issueBoards
.
BoardsStore
;
const
Store
=
gl
.
issueBoards
.
BoardsStore
;
...
@@ -95,9 +92,9 @@ $(() => {
...
@@ -95,9 +92,9 @@ $(() => {
Store
.
disabled
=
this
.
disabled
;
Store
.
disabled
=
this
.
disabled
;
gl
.
boardService
.
all
()
gl
.
boardService
.
all
()
.
then
(
res
ponse
=>
response
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
((
resp
)
=>
{
.
then
((
data
)
=>
{
resp
.
forEach
((
board
)
=>
{
data
.
forEach
((
board
)
=>
{
const
list
=
Store
.
addList
(
board
,
this
.
defaultAvatar
);
const
list
=
Store
.
addList
(
board
,
this
.
defaultAvatar
);
if
(
list
.
type
===
'
closed
'
)
{
if
(
list
.
type
===
'
closed
'
)
{
...
@@ -112,7 +109,9 @@ $(() => {
...
@@ -112,7 +109,9 @@ $(() => {
Store
.
addBlankState
();
Store
.
addBlankState
();
this
.
loading
=
false
;
this
.
loading
=
false
;
})
})
.
catch
(()
=>
new
Flash
(
'
An error occurred. Please try again.
'
));
.
catch
(()
=>
{
Flash
(
'
An error occurred while fetching the board lists. Please try again.
'
);
});
},
},
methods
:
{
methods
:
{
updateTokens
()
{
updateTokens
()
{
...
@@ -123,7 +122,7 @@ $(() => {
...
@@ -123,7 +122,7 @@ $(() => {
if
(
sidebarInfoEndpoint
&&
newIssue
.
subscribed
===
undefined
)
{
if
(
sidebarInfoEndpoint
&&
newIssue
.
subscribed
===
undefined
)
{
newIssue
.
setFetchingState
(
'
subscriptions
'
,
true
);
newIssue
.
setFetchingState
(
'
subscriptions
'
,
true
);
BoardService
.
getIssueInfo
(
sidebarInfoEndpoint
)
BoardService
.
getIssueInfo
(
sidebarInfoEndpoint
)
.
then
(
res
=>
res
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
newIssue
.
setFetchingState
(
'
subscriptions
'
,
false
);
newIssue
.
setFetchingState
(
'
subscriptions
'
,
false
);
newIssue
.
updateData
({
newIssue
.
updateData
({
...
...
app/assets/javascripts/boards/components/board_blank_state.js
View file @
4ffc863a
...
@@ -65,7 +65,7 @@ export default {
...
@@ -65,7 +65,7 @@ export default {
// Save the labels
// Save the labels
gl
.
boardService
.
generateDefaultLists
()
gl
.
boardService
.
generateDefaultLists
()
.
then
(
res
p
=>
resp
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
data
.
forEach
((
listObj
)
=>
{
data
.
forEach
((
listObj
)
=>
{
const
list
=
Store
.
findList
(
'
title
'
,
listObj
.
title
);
const
list
=
Store
.
findList
(
'
title
'
,
listObj
.
title
);
...
...
app/assets/javascripts/boards/components/modal/index.js
View file @
4ffc863a
...
@@ -89,7 +89,7 @@ gl.issueBoards.IssuesModal = Vue.extend({
...
@@ -89,7 +89,7 @@ gl.issueBoards.IssuesModal = Vue.extend({
page
:
this
.
page
,
page
:
this
.
page
,
per
:
this
.
perPage
,
per
:
this
.
perPage
,
}))
}))
.
then
(
res
p
=>
resp
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
if
(
clearIssues
)
{
if
(
clearIssues
)
{
this
.
issues
=
[];
this
.
issues
=
[];
...
...
app/assets/javascripts/boards/models/list.js
View file @
4ffc863a
...
@@ -40,7 +40,7 @@ class List {
...
@@ -40,7 +40,7 @@ class List {
save
()
{
save
()
{
return
gl
.
boardService
.
createList
(
this
.
label
.
id
)
return
gl
.
boardService
.
createList
(
this
.
label
.
id
)
.
then
(
res
p
=>
resp
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
this
.
id
=
data
.
id
;
this
.
id
=
data
.
id
;
this
.
type
=
data
.
list_type
;
this
.
type
=
data
.
list_type
;
...
@@ -90,7 +90,7 @@ class List {
...
@@ -90,7 +90,7 @@ class List {
}
}
return
gl
.
boardService
.
getIssuesForList
(
this
.
id
,
data
)
return
gl
.
boardService
.
getIssuesForList
(
this
.
id
,
data
)
.
then
(
res
p
=>
resp
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
this
.
loading
=
false
;
this
.
loading
=
false
;
this
.
issuesSize
=
data
.
size
;
this
.
issuesSize
=
data
.
size
;
...
@@ -108,7 +108,7 @@ class List {
...
@@ -108,7 +108,7 @@ class List {
this
.
issuesSize
+=
1
;
this
.
issuesSize
+=
1
;
return
gl
.
boardService
.
newIssue
(
this
.
id
,
issue
)
return
gl
.
boardService
.
newIssue
(
this
.
id
,
issue
)
.
then
(
res
p
=>
resp
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
issue
.
id
=
data
.
id
;
issue
.
id
=
data
.
id
;
issue
.
iid
=
data
.
iid
;
issue
.
iid
=
data
.
iid
;
...
...
app/assets/javascripts/boards/services/board_service.js
View file @
4ffc863a
/* eslint-disable space-before-function-paren, comma-dangle, no-param-reassign, camelcase, max-len, no-unused-vars */
import
axios
from
'
../../lib/utils/axios_utils
'
;
import
{
mergeUrlParams
}
from
'
../../lib/utils/url_utility
'
;
import
Vue
from
'
vue
'
;
export
default
class
BoardService
{
export
default
class
BoardService
{
constructor
({
boardsEndpoint
,
listsEndpoint
,
bulkUpdatePath
,
boardId
})
{
constructor
({
boardsEndpoint
,
listsEndpoint
,
bulkUpdatePath
,
boardId
})
{
this
.
boards
=
Vue
.
resource
(
`
${
boardsEndpoint
}
{/id}.json`
,
{},
{
this
.
boardsEndpoint
=
boardsEndpoint
;
issues
:
{
this
.
boardId
=
boardId
;
method
:
'
GET
'
,
this
.
listsEndpoint
=
listsEndpoint
;
url
:
`
${
gon
.
relative_url_root
}
/-/boards/
${
boardId
}
/issues.json`
,
this
.
listsEndpointGenerate
=
`
${
listsEndpoint
}
/generate.json`
;
}
this
.
bulkUpdatePath
=
bulkUpdatePath
;
});
}
this
.
lists
=
Vue
.
resource
(
`
${
listsEndpoint
}
{/id}`
,
{},
{
generate
:
{
generateBoardsPath
(
id
)
{
method
:
'
POST
'
,
return
`
${
this
.
boardsEndpoint
}${
id
?
`/
${
id
}
`
:
''
}
.json`
;
url
:
`
${
listsEndpoint
}
/generate.json`
}
});
this
.
issue
=
Vue
.
resource
(
`
${
gon
.
relative_url_root
}
/-/boards/
${
boardId
}
/issues{/id}`
,
{});
this
.
issues
=
Vue
.
resource
(
`
${
listsEndpoint
}
{/id}/issues`
,
{},
{
bulkUpdate
:
{
method
:
'
POST
'
,
url
:
bulkUpdatePath
,
},
});
}
}
all
(
)
{
generateIssuesPath
(
id
)
{
return
this
.
lists
.
get
()
;
return
`
${
this
.
listsEndpoint
}${
id
?
`/
${
id
}
`
:
''
}
/issues`
;
}
}
generateDefaultLists
(
)
{
static
generateIssuePath
(
boardId
,
id
)
{
return
this
.
lists
.
generate
({})
;
return
`
${
gon
.
relative_url_root
}
/-/boards/
${
boardId
?
`/
${
boardId
}
`
:
''
}
/issues
${
id
?
`/
${
id
}
`
:
''
}
`
;
}
}
createList
(
label_id
)
{
all
()
{
return
this
.
lists
.
save
({},
{
return
axios
.
get
(
this
.
listsEndpoint
);
}
generateDefaultLists
()
{
return
axios
.
post
(
this
.
listsEndpointGenerate
,
{});
}
createList
(
labelId
)
{
return
axios
.
post
(
this
.
listsEndpoint
,
{
list
:
{
list
:
{
label_id
label_id
:
labelId
,
}
}
,
});
});
}
}
updateList
(
id
,
position
)
{
updateList
(
id
,
position
)
{
return
this
.
lists
.
update
({
id
}
,
{
return
axios
.
put
(
`
${
this
.
listsEndpoint
}
/
${
id
}
`
,
{
list
:
{
list
:
{
position
position
,
}
}
,
});
});
}
}
destroyList
(
id
)
{
destroyList
(
id
)
{
return
this
.
lists
.
delete
({
id
}
);
return
axios
.
delete
(
`
${
this
.
listsEndpoint
}
/
${
id
}
`
);
}
}
getIssuesForList
(
id
,
filter
=
{})
{
getIssuesForList
(
id
,
filter
=
{})
{
const
data
=
{
id
};
const
data
=
{
id
};
Object
.
keys
(
filter
).
forEach
((
key
)
=>
{
data
[
key
]
=
filter
[
key
];
});
Object
.
keys
(
filter
).
forEach
((
key
)
=>
{
data
[
key
]
=
filter
[
key
];
});
return
this
.
issues
.
get
(
data
);
return
axios
.
get
(
mergeUrlParams
(
data
,
this
.
generateIssuesPath
(
id
))
);
}
}
moveIssue
(
id
,
from_list_id
=
null
,
to_list_id
=
null
,
move_before_id
=
null
,
move_after_i
d
=
null
)
{
moveIssue
(
id
,
fromListId
=
null
,
toListId
=
null
,
moveBeforeId
=
null
,
moveAfterI
d
=
null
)
{
return
this
.
issue
.
update
({
id
}
,
{
return
axios
.
put
(
BoardService
.
generateIssuePath
(
this
.
boardId
,
id
)
,
{
from_list_id
,
from_list_id
:
fromListId
,
to_list_id
,
to_list_id
:
toListId
,
move_before_id
,
move_before_id
:
moveBeforeId
,
move_after_id
,
move_after_id
:
moveAfterId
,
});
});
}
}
newIssue
(
id
,
issue
)
{
newIssue
(
id
,
issue
)
{
return
this
.
issues
.
save
({
id
}
,
{
return
axios
.
post
(
this
.
generateIssuesPath
(
id
)
,
{
issue
issue
,
});
});
}
}
getBacklog
(
data
)
{
getBacklog
(
data
)
{
return
this
.
boards
.
issues
(
data
);
return
axios
.
get
(
mergeUrlParams
(
data
,
`
${
gon
.
relative_url_root
}
/-/boards/
${
this
.
boardId
}
/issues.json`
)
);
}
}
bulkUpdate
(
issueIds
,
extraData
=
{})
{
bulkUpdate
(
issueIds
,
extraData
=
{})
{
...
@@ -86,15 +83,15 @@ export default class BoardService {
...
@@ -86,15 +83,15 @@ export default class BoardService {
}),
}),
};
};
return
this
.
issues
.
bulkUpdate
(
data
);
return
axios
.
post
(
this
.
bulkUpdatePath
,
data
);
}
}
static
getIssueInfo
(
endpoint
)
{
static
getIssueInfo
(
endpoint
)
{
return
Vue
.
http
.
get
(
endpoint
);
return
axios
.
get
(
endpoint
);
}
}
static
toggleIssueSubscription
(
endpoint
)
{
static
toggleIssueSubscription
(
endpoint
)
{
return
Vue
.
http
.
post
(
endpoint
);
return
axios
.
post
(
endpoint
);
}
}
}
}
...
...
spec/javascripts/boards/board_blank_state_spec.js
View file @
4ffc863a
/* global BoardService */
/* global BoardService */
/* global mockBoardService */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
~/boards/stores/boards_store
'
;
import
boardBlankState
from
'
~/boards/components/board_blank_state
'
;
import
boardBlankState
from
'
~/boards/components/board_blank_state
'
;
import
'
./mock_data
'
;
import
{
mockBoardService
}
from
'
./mock_data
'
;
describe
(
'
Boards blank state
'
,
()
=>
{
describe
(
'
Boards blank state
'
,
()
=>
{
let
vm
;
let
vm
;
...
@@ -20,17 +19,15 @@ describe('Boards blank state', () => {
...
@@ -20,17 +19,15 @@ describe('Boards blank state', () => {
reject
();
reject
();
}
else
{
}
else
{
resolve
({
resolve
({
json
()
{
data
:
[{
return
[{
id
:
1
,
id
:
1
,
title
:
'
To Do
'
,
title
:
'
To Do
'
,
label
:
{
id
:
1
},
label
:
{
id
:
1
},
},
{
},
{
id
:
2
,
id
:
2
,
title
:
'
Doing
'
,
title
:
'
Doing
'
,
label
:
{
id
:
2
},
label
:
{
id
:
2
},
}],
}];
},
});
});
}
}
}));
}));
...
...
spec/javascripts/boards/board_card_spec.js
View file @
4ffc863a
/* global List */
/* global List */
/* global ListAssignee */
/* global ListAssignee */
/* global ListLabel */
/* global ListLabel */
/* global listObj */
/* global boardsMockInterceptor */
/* global BoardService */
/* global BoardService */
/* global mockBoardService */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
'
~/boards/models/assignee
'
;
import
'
~/boards/models/assignee
'
;
import
eventHub
from
'
~/boards/eventhub
'
;
import
eventHub
from
'
~/boards/eventhub
'
;
...
@@ -14,13 +13,15 @@ import '~/boards/models/list';
...
@@ -14,13 +13,15 @@ import '~/boards/models/list';
import
'
~/boards/models/label
'
;
import
'
~/boards/models/label
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
~/boards/stores/boards_store
'
;
import
boardCard
from
'
~/boards/components/board_card.vue
'
;
import
boardCard
from
'
~/boards/components/board_card.vue
'
;
import
'
./mock_data
'
;
import
{
listObj
,
boardsMockInterceptor
,
mockBoardService
}
from
'
./mock_data
'
;
describe
(
'
Board card
'
,
()
=>
{
describe
(
'
Board card
'
,
()
=>
{
let
vm
;
let
vm
;
let
mock
;
beforeEach
((
done
)
=>
{
beforeEach
((
done
)
=>
{
Vue
.
http
.
interceptors
.
push
(
boardsMockInterceptor
);
mock
=
new
MockAdapter
(
axios
);
mock
.
onAny
().
reply
(
boardsMockInterceptor
);
gl
.
boardService
=
mockBoardService
();
gl
.
boardService
=
mockBoardService
();
gl
.
issueBoards
.
BoardsStore
.
create
();
gl
.
issueBoards
.
BoardsStore
.
create
();
...
@@ -54,7 +55,7 @@ describe('Board card', () => {
...
@@ -54,7 +55,7 @@ describe('Board card', () => {
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
boardsMockInterceptor
);
mock
.
reset
(
);
});
});
it
(
'
returns false when detailIssue is empty
'
,
()
=>
{
it
(
'
returns false when detailIssue is empty
'
,
()
=>
{
...
...
spec/javascripts/boards/board_list_spec.js
View file @
4ffc863a
/* global BoardService */
/* global BoardService */
/* global boardsMockInterceptor */
/* global List */
/* global List */
/* global listObj */
/* global ListIssue */
/* global ListIssue */
/* global mockBoardService */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
_
from
'
underscore
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Sortable
from
'
vendor/Sortable
'
;
import
Sortable
from
'
vendor/Sortable
'
;
import
BoardList
from
'
~/boards/components/board_list
'
;
import
BoardList
from
'
~/boards/components/board_list
'
;
import
eventHub
from
'
~/boards/eventhub
'
;
import
eventHub
from
'
~/boards/eventhub
'
;
...
@@ -13,18 +11,20 @@ import '~/boards/mixins/sortable_default_options';
...
@@ -13,18 +11,20 @@ import '~/boards/mixins/sortable_default_options';
import
'
~/boards/models/issue
'
;
import
'
~/boards/models/issue
'
;
import
'
~/boards/models/list
'
;
import
'
~/boards/models/list
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
./mock_data
'
;
import
{
listObj
,
boardsMockInterceptor
,
mockBoardService
}
from
'
./mock_data
'
;
window
.
Sortable
=
Sortable
;
window
.
Sortable
=
Sortable
;
describe
(
'
Board list component
'
,
()
=>
{
describe
(
'
Board list component
'
,
()
=>
{
let
mock
;
let
component
;
let
component
;
beforeEach
((
done
)
=>
{
beforeEach
((
done
)
=>
{
const
el
=
document
.
createElement
(
'
div
'
);
const
el
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
el
);
document
.
body
.
appendChild
(
el
);
Vue
.
http
.
interceptors
.
push
(
boardsMockInterceptor
);
mock
=
new
MockAdapter
(
axios
);
mock
.
onAny
().
reply
(
boardsMockInterceptor
);
gl
.
boardService
=
mockBoardService
();
gl
.
boardService
=
mockBoardService
();
gl
.
issueBoards
.
BoardsStore
.
create
();
gl
.
issueBoards
.
BoardsStore
.
create
();
gl
.
IssueBoardsApp
=
new
Vue
();
gl
.
IssueBoardsApp
=
new
Vue
();
...
@@ -60,7 +60,7 @@ describe('Board list component', () => {
...
@@ -60,7 +60,7 @@ describe('Board list component', () => {
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
boardsMockInterceptor
);
mock
.
reset
(
);
});
});
it
(
'
renders component
'
,
()
=>
{
it
(
'
renders component
'
,
()
=>
{
...
...
spec/javascripts/boards/board_new_issue_spec.js
View file @
4ffc863a
/* global boardsMockInterceptor */
/* global BoardService */
/* global BoardService */
/* global List */
/* global List */
/* global listObj */
/* global mockBoardService */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
boardNewIssue
from
'
~/boards/components/board_new_issue
'
;
import
boardNewIssue
from
'
~/boards/components/board_new_issue
'
;
import
'
~/boards/models/list
'
;
import
'
~/boards/models/list
'
;
import
'
./mock_data
'
;
import
{
listObj
,
boardsMockInterceptor
,
mockBoardService
}
from
'
./mock_data
'
;
describe
(
'
Issue boards new issue form
'
,
()
=>
{
describe
(
'
Issue boards new issue form
'
,
()
=>
{
let
vm
;
let
vm
;
let
list
;
let
list
;
let
mock
;
let
newIssueMock
;
let
newIssueMock
;
const
promiseReturn
=
{
const
promiseReturn
=
{
json
()
{
data
:
{
return
{
iid
:
100
,
iid
:
100
,
};
},
},
};
};
...
@@ -35,7 +33,9 @@ describe('Issue boards new issue form', () => {
...
@@ -35,7 +33,9 @@ describe('Issue boards new issue form', () => {
const
BoardNewIssueComp
=
Vue
.
extend
(
boardNewIssue
);
const
BoardNewIssueComp
=
Vue
.
extend
(
boardNewIssue
);
Vue
.
http
.
interceptors
.
push
(
boardsMockInterceptor
);
mock
=
new
MockAdapter
(
axios
);
mock
.
onAny
().
reply
(
boardsMockInterceptor
);
gl
.
boardService
=
mockBoardService
();
gl
.
boardService
=
mockBoardService
();
gl
.
issueBoards
.
BoardsStore
.
create
();
gl
.
issueBoards
.
BoardsStore
.
create
();
gl
.
IssueBoardsApp
=
new
Vue
();
gl
.
IssueBoardsApp
=
new
Vue
();
...
@@ -56,7 +56,10 @@ describe('Issue boards new issue form', () => {
...
@@ -56,7 +56,10 @@ describe('Issue boards new issue form', () => {
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
afterEach
(()
=>
vm
.
$destroy
());
afterEach
(()
=>
{
vm
.
$destroy
();
mock
.
reset
();
});
it
(
'
calls submit if submit button is clicked
'
,
(
done
)
=>
{
it
(
'
calls submit if submit button is clicked
'
,
(
done
)
=>
{
spyOn
(
vm
,
'
submit
'
).
and
.
callFake
(
e
=>
e
.
preventDefault
());
spyOn
(
vm
,
'
submit
'
).
and
.
callFake
(
e
=>
e
.
preventDefault
());
...
...
spec/javascripts/boards/boards_store_spec.js
View file @
4ffc863a
/* eslint-disable comma-dangle, one-var, no-unused-vars */
/* eslint-disable comma-dangle, one-var, no-unused-vars */
/* global BoardService */
/* global BoardService */
/* global boardsMockInterceptor */
/* global listObj */
/* global listObjDuplicate */
/* global ListIssue */
/* global ListIssue */
/* global mockBoardService */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
'
js-cookie
'
;
import
'
~/boards/models/issue
'
;
import
'
~/boards/models/issue
'
;
...
@@ -15,11 +13,14 @@ import '~/boards/models/list';
...
@@ -15,11 +13,14 @@ import '~/boards/models/list';
import
'
~/boards/models/assignee
'
;
import
'
~/boards/models/assignee
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
./mock_data
'
;
import
{
listObj
,
listObjDuplicate
,
boardsMockInterceptor
,
mockBoardService
}
from
'
./mock_data
'
;
describe
(
'
Store
'
,
()
=>
{
describe
(
'
Store
'
,
()
=>
{
let
mock
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
boardsMockInterceptor
);
mock
=
new
MockAdapter
(
axios
);
mock
.
onAny
().
reply
(
boardsMockInterceptor
);
gl
.
boardService
=
mockBoardService
();
gl
.
boardService
=
mockBoardService
();
gl
.
issueBoards
.
BoardsStore
.
create
();
gl
.
issueBoards
.
BoardsStore
.
create
();
...
@@ -34,7 +35,7 @@ describe('Store', () => {
...
@@ -34,7 +35,7 @@ describe('Store', () => {
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
boardsMockInterceptor
);
mock
.
reset
(
);
});
});
it
(
'
starts with a blank state
'
,
()
=>
{
it
(
'
starts with a blank state
'
,
()
=>
{
...
...
spec/javascripts/boards/components/board_spec.js
View file @
4ffc863a
/* global mockBoardService */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/components/board
'
;
import
'
~/boards/components/board
'
;
import
'
~/boards/models/list
'
;
import
'
~/boards/models/list
'
;
import
'
../mock_data
'
;
import
{
mockBoardService
}
from
'
../mock_data
'
;
describe
(
'
Board component
'
,
()
=>
{
describe
(
'
Board component
'
,
()
=>
{
let
vm
;
let
vm
;
...
...
spec/javascripts/boards/issue_card_spec.js
View file @
4ffc863a
/* global ListAssignee */
/* global ListAssignee */
/* global ListLabel */
/* global ListLabel */
/* global listObj */
/* global ListIssue */
/* global ListIssue */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
...
@@ -11,7 +10,7 @@ import '~/boards/models/list';
...
@@ -11,7 +10,7 @@ import '~/boards/models/list';
import
'
~/boards/models/assignee
'
;
import
'
~/boards/models/assignee
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
~/boards/components/issue_card_inner
'
;
import
'
~/boards/components/issue_card_inner
'
;
import
'
./mock_data
'
;
import
{
listObj
}
from
'
./mock_data
'
;
describe
(
'
Issue card component
'
,
()
=>
{
describe
(
'
Issue card component
'
,
()
=>
{
const
user
=
new
ListAssignee
({
const
user
=
new
ListAssignee
({
...
...
spec/javascripts/boards/issue_spec.js
View file @
4ffc863a
/* eslint-disable comma-dangle */
/* eslint-disable comma-dangle */
/* global BoardService */
/* global BoardService */
/* global ListIssue */
/* global ListIssue */
/* global mockBoardService */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
'
~/boards/models/issue
'
;
import
'
~/boards/models/issue
'
;
...
@@ -10,7 +9,7 @@ import '~/boards/models/list';
...
@@ -10,7 +9,7 @@ import '~/boards/models/list';
import
'
~/boards/models/assignee
'
;
import
'
~/boards/models/assignee
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
./mock_data
'
;
import
{
mockBoardService
}
from
'
./mock_data
'
;
describe
(
'
Issue model
'
,
()
=>
{
describe
(
'
Issue model
'
,
()
=>
{
let
issue
;
let
issue
;
...
...
spec/javascripts/boards/list_spec.js
View file @
4ffc863a
/* eslint-disable comma-dangle */
/* eslint-disable comma-dangle */
/* global boardsMockInterceptor */
/* global BoardService */
/* global BoardService */
/* global mockBoardService */
/* global List */
/* global List */
/* global ListIssue */
/* global ListIssue */
/* global listObj */
/* global listObjDuplicate */
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
'
~/boards/models/issue
'
;
import
'
~/boards/models/issue
'
;
import
'
~/boards/models/label
'
;
import
'
~/boards/models/label
'
;
...
@@ -15,13 +12,15 @@ import '~/boards/models/list';
...
@@ -15,13 +12,15 @@ import '~/boards/models/list';
import
'
~/boards/models/assignee
'
;
import
'
~/boards/models/assignee
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
./mock_data
'
;
import
{
listObj
,
listObjDuplicate
,
boardsMockInterceptor
,
mockBoardService
}
from
'
./mock_data
'
;
describe
(
'
List model
'
,
()
=>
{
describe
(
'
List model
'
,
()
=>
{
let
list
;
let
list
;
let
mock
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
boardsMockInterceptor
);
mock
=
new
MockAdapter
(
axios
);
mock
.
onAny
().
reply
(
boardsMockInterceptor
);
gl
.
boardService
=
mockBoardService
({
gl
.
boardService
=
mockBoardService
({
bulkUpdatePath
:
'
/test/issue-boards/board/1/lists
'
,
bulkUpdatePath
:
'
/test/issue-boards/board/1/lists
'
,
});
});
...
@@ -31,7 +30,7 @@ describe('List model', () => {
...
@@ -31,7 +30,7 @@ describe('List model', () => {
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
boardsMockInterceptor
);
mock
.
reset
(
);
});
});
it
(
'
gets issues when created
'
,
(
done
)
=>
{
it
(
'
gets issues when created
'
,
(
done
)
=>
{
...
@@ -158,10 +157,8 @@ describe('List model', () => {
...
@@ -158,10 +157,8 @@ describe('List model', () => {
describe
(
'
newIssue
'
,
()
=>
{
describe
(
'
newIssue
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
spyOn
(
gl
.
boardService
,
'
newIssue
'
).
and
.
returnValue
(
Promise
.
resolve
({
spyOn
(
gl
.
boardService
,
'
newIssue
'
).
and
.
returnValue
(
Promise
.
resolve
({
json
()
{
data
:
{
return
{
id
:
42
,
id
:
42
,
};
},
},
}));
}));
});
});
...
...
spec/javascripts/boards/mock_data.js
View file @
4ffc863a
/* global BoardService */
/* global BoardService */
/* eslint-disable comma-dangle, no-unused-vars, quote-props */
/* eslint-disable comma-dangle, no-unused-vars, quote-props */
const
listObj
=
{
export
const
listObj
=
{
id
:
_
.
random
(
10000
)
,
id
:
300
,
position
:
0
,
position
:
0
,
title
:
'
Test
'
,
title
:
'
Test
'
,
list_type
:
'
label
'
,
list_type
:
'
label
'
,
label
:
{
label
:
{
id
:
_
.
random
(
10000
)
,
id
:
5000
,
title
:
'
Testing
'
,
title
:
'
Testing
'
,
color
:
'
red
'
,
color
:
'
red
'
,
description
:
'
testing;
'
description
:
'
testing;
'
}
}
};
};
const
listObjDuplicate
=
{
export
const
listObjDuplicate
=
{
id
:
listObj
.
id
,
id
:
listObj
.
id
,
position
:
1
,
position
:
1
,
title
:
'
Test
'
,
title
:
'
Test
'
,
...
@@ -27,9 +27,9 @@ const listObjDuplicate = {
...
@@ -27,9 +27,9 @@ const listObjDuplicate = {
}
}
};
};
const
BoardsMockData
=
{
export
const
BoardsMockData
=
{
'
GET
'
:
{
'
GET
'
:
{
'
/test/
boards/1{/id}/issues
'
:
{
'
/test/
-/boards/1/lists/300/issues?id=300&page=1&=
'
:
{
issues
:
[{
issues
:
[{
title
:
'
Testing
'
,
title
:
'
Testing
'
,
id
:
1
,
id
:
1
,
...
@@ -41,7 +41,7 @@ const BoardsMockData = {
...
@@ -41,7 +41,7 @@ const BoardsMockData = {
}
}
},
},
'
POST
'
:
{
'
POST
'
:
{
'
/test/
boards/1{/id}
'
:
listObj
'
/test/
-/boards/1/lists
'
:
listObj
},
},
'
PUT
'
:
{
'
PUT
'
:
{
'
/test/issue-boards/board/1/lists{/id}
'
:
{}
'
/test/issue-boards/board/1/lists{/id}
'
:
{}
...
@@ -51,17 +51,14 @@ const BoardsMockData = {
...
@@ -51,17 +51,14 @@ const BoardsMockData = {
}
}
};
};
const
boardsMockInterceptor
=
(
request
,
next
)
=>
{
export
const
boardsMockInterceptor
=
(
config
)
=>
{
const
body
=
BoardsMockData
[
request
.
method
][
request
.
url
];
const
body
=
BoardsMockData
[
config
.
method
.
toUpperCase
()][
config
.
url
];
return
[
200
,
body
];
next
(
request
.
respondWith
(
JSON
.
stringify
(
body
),
{
status
:
200
}));
};
};
const
mockBoardService
=
(
opts
=
{})
=>
{
export
const
mockBoardService
=
(
opts
=
{})
=>
{
const
boardsEndpoint
=
opts
.
boardsEndpoint
||
'
/test/issue-boards/board
'
;
const
boardsEndpoint
=
opts
.
boardsEndpoint
||
'
/test/issue-boards/board
s.json
'
;
const
listsEndpoint
=
opts
.
listsEndpoint
||
'
/test/
boards/1
'
;
const
listsEndpoint
=
opts
.
listsEndpoint
||
'
/test/
-/boards/1/lists
'
;
const
bulkUpdatePath
=
opts
.
bulkUpdatePath
||
''
;
const
bulkUpdatePath
=
opts
.
bulkUpdatePath
||
''
;
const
boardId
=
opts
.
boardId
||
'
1
'
;
const
boardId
=
opts
.
boardId
||
'
1
'
;
...
@@ -72,9 +69,3 @@ const mockBoardService = (opts = {}) => {
...
@@ -72,9 +69,3 @@ const mockBoardService = (opts = {}) => {
boardId
,
boardId
,
});
});
};
};
window
.
listObj
=
listObj
;
window
.
listObjDuplicate
=
listObjDuplicate
;
window
.
BoardsMockData
=
BoardsMockData
;
window
.
boardsMockInterceptor
=
boardsMockInterceptor
;
window
.
mockBoardService
=
mockBoardService
;
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