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
ac9e65a9
Commit
ac9e65a9
authored
Dec 15, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch blob/notebook to Axios
parent
254c0754
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
39 deletions
+23
-39
app/assets/javascripts/blob/notebook/index.js
app/assets/javascripts/blob/notebook/index.js
+6
-8
spec/javascripts/blob/notebook/index_spec.js
spec/javascripts/blob/notebook/index_spec.js
+17
-31
No files found.
app/assets/javascripts/blob/notebook/index.js
View file @
ac9e65a9
/* eslint-disable no-new */
/* eslint-disable no-new */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
VueResource
from
'
vue-resource
'
;
import
axios
from
'
../../lib/utils/axios_utils
'
;
import
notebookLab
from
'
../../notebook/index.vue
'
;
import
notebookLab
from
'
../../notebook/index.vue
'
;
Vue
.
use
(
VueResource
);
export
default
()
=>
{
export
default
()
=>
{
const
el
=
document
.
getElementById
(
'
js-notebook-viewer
'
);
const
el
=
document
.
getElementById
(
'
js-notebook-viewer
'
);
...
@@ -50,14 +48,14 @@ export default () => {
...
@@ -50,14 +48,14 @@ export default () => {
`
,
`
,
methods
:
{
methods
:
{
loadFile
()
{
loadFile
()
{
this
.
$http
.
get
(
el
.
dataset
.
endpoint
)
axios
.
get
(
el
.
dataset
.
endpoint
)
.
then
(
res
ponse
=>
response
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
((
res
)
=>
{
.
then
((
data
)
=>
{
this
.
json
=
res
;
this
.
json
=
data
;
this
.
loading
=
false
;
this
.
loading
=
false
;
})
})
.
catch
((
e
)
=>
{
.
catch
((
e
)
=>
{
if
(
e
.
status
)
{
if
(
e
.
status
!==
200
)
{
this
.
loadError
=
true
;
this
.
loadError
=
true
;
}
}
...
...
spec/javascripts/blob/notebook/index_spec.js
View file @
ac9e65a9
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
renderNotebook
from
'
~/blob/notebook
'
;
import
renderNotebook
from
'
~/blob/notebook
'
;
describe
(
'
iPython notebook renderer
'
,
()
=>
{
describe
(
'
iPython notebook renderer
'
,
()
=>
{
...
@@ -17,8 +18,11 @@ describe('iPython notebook renderer', () => {
...
@@ -17,8 +18,11 @@ describe('iPython notebook renderer', () => {
});
});
describe
(
'
successful response
'
,
()
=>
{
describe
(
'
successful response
'
,
()
=>
{
const
response
=
(
request
,
next
)
=>
{
let
mock
;
next
(
request
.
respondWith
(
JSON
.
stringify
({
beforeEach
((
done
)
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
'
/test
'
).
reply
(
200
,
{
cells
:
[{
cells
:
[{
cell_type
:
'
markdown
'
,
cell_type
:
'
markdown
'
,
source
:
[
'
# test
'
],
source
:
[
'
# test
'
],
...
@@ -31,13 +35,7 @@ describe('iPython notebook renderer', () => {
...
@@ -31,13 +35,7 @@ describe('iPython notebook renderer', () => {
],
],
outputs
:
[],
outputs
:
[],
}],
}],
}),
{
});
status
:
200
,
}));
};
beforeEach
((
done
)
=>
{
Vue
.
http
.
interceptors
.
push
(
response
);
renderNotebook
();
renderNotebook
();
...
@@ -47,9 +45,7 @@ describe('iPython notebook renderer', () => {
...
@@ -47,9 +45,7 @@ describe('iPython notebook renderer', () => {
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
mock
.
reset
();
Vue
.
http
.
interceptors
,
response
,
);
});
});
it
(
'
does not show loading icon
'
,
()
=>
{
it
(
'
does not show loading icon
'
,
()
=>
{
...
@@ -86,14 +82,11 @@ describe('iPython notebook renderer', () => {
...
@@ -86,14 +82,11 @@ describe('iPython notebook renderer', () => {
});
});
describe
(
'
error in JSON response
'
,
()
=>
{
describe
(
'
error in JSON response
'
,
()
=>
{
const
response
=
(
request
,
next
)
=>
{
let
mock
;
next
(
request
.
respondWith
(
'
{ "cells": [{"cell_type": "markdown"} }
'
,
{
status
:
200
,
}));
};
beforeEach
((
done
)
=>
{
beforeEach
((
done
)
=>
{
Vue
.
http
.
interceptors
.
push
(
response
);
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
'
/test
'
).
reply
(()
=>
Promise
.
reject
({
status
:
200
,
data
:
'
{ "cells": [{"cell_type": "markdown"} }
'
}));
renderNotebook
();
renderNotebook
();
...
@@ -103,9 +96,7 @@ describe('iPython notebook renderer', () => {
...
@@ -103,9 +96,7 @@ describe('iPython notebook renderer', () => {
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
mock
.
reset
();
Vue
.
http
.
interceptors
,
response
,
);
});
});
it
(
'
does not show loading icon
'
,
()
=>
{
it
(
'
does not show loading icon
'
,
()
=>
{
...
@@ -122,14 +113,11 @@ describe('iPython notebook renderer', () => {
...
@@ -122,14 +113,11 @@ describe('iPython notebook renderer', () => {
});
});
describe
(
'
error getting file
'
,
()
=>
{
describe
(
'
error getting file
'
,
()
=>
{
const
response
=
(
request
,
next
)
=>
{
let
mock
;
next
(
request
.
respondWith
(
''
,
{
status
:
500
,
}));
};
beforeEach
((
done
)
=>
{
beforeEach
((
done
)
=>
{
Vue
.
http
.
interceptors
.
push
(
response
);
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
'
/test
'
).
reply
(
500
,
''
);
renderNotebook
();
renderNotebook
();
...
@@ -139,9 +127,7 @@ describe('iPython notebook renderer', () => {
...
@@ -139,9 +127,7 @@ describe('iPython notebook renderer', () => {
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
mock
.
reset
();
Vue
.
http
.
interceptors
,
response
,
);
});
});
it
(
'
does not show loading icon
'
,
()
=>
{
it
(
'
does not show loading icon
'
,
()
=>
{
...
...
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