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
1fa18585
Commit
1fa18585
authored
May 14, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace vue resource with axios for environments
parent
ca9bce4a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
116 additions
and
216 deletions
+116
-216
app/assets/javascripts/environments/components/environments_app.vue
.../javascripts/environments/components/environments_app.vue
+1
-2
app/assets/javascripts/environments/mixins/environments_mixin.js
...ets/javascripts/environments/mixins/environments_mixin.js
+8
-12
app/assets/javascripts/environments/services/environments_service.js
...javascripts/environments/services/environments_service.js
+6
-9
spec/javascripts/environments/environments_app_spec.js
spec/javascripts/environments/environments_app_spec.js
+75
-137
spec/javascripts/environments/folder/environments_folder_view_spec.js
...ipts/environments/folder/environments_folder_view_spec.js
+25
-56
spec/javascripts/environments/mock_data.js
spec/javascripts/environments/mock_data.js
+1
-0
No files found.
app/assets/javascripts/environments/components/environments_app.vue
View file @
1fa18585
...
@@ -68,8 +68,7 @@
...
@@ -68,8 +68,7 @@
this
.
store
.
updateEnvironmentProp
(
folder
,
'
isLoadingFolderContent
'
,
showLoader
);
this
.
store
.
updateEnvironmentProp
(
folder
,
'
isLoadingFolderContent
'
,
showLoader
);
this
.
service
.
getFolderContent
(
folder
.
folder_path
)
this
.
service
.
getFolderContent
(
folder
.
folder_path
)
.
then
(
resp
=>
resp
.
json
())
.
then
(
response
=>
this
.
store
.
setfolderContent
(
folder
,
response
.
data
.
environments
))
.
then
(
response
=>
this
.
store
.
setfolderContent
(
folder
,
response
.
environments
))
.
then
(()
=>
this
.
store
.
updateEnvironmentProp
(
folder
,
'
isLoadingFolderContent
'
,
false
))
.
then
(()
=>
this
.
store
.
updateEnvironmentProp
(
folder
,
'
isLoadingFolderContent
'
,
false
))
.
catch
(()
=>
{
.
catch
(()
=>
{
Flash
(
s__
(
'
Environments|An error occurred while fetching the environments.
'
));
Flash
(
s__
(
'
Environments|An error occurred while fetching the environments.
'
));
...
...
app/assets/javascripts/environments/mixins/environments_mixin.js
View file @
1fa18585
...
@@ -6,7 +6,6 @@ import Visibility from 'visibilityjs';
...
@@ -6,7 +6,6 @@ import Visibility from 'visibilityjs';
import
Poll
from
'
../../lib/utils/poll
'
;
import
Poll
from
'
../../lib/utils/poll
'
;
import
{
import
{
getParameterByName
,
getParameterByName
,
parseQueryStringIntoObject
,
}
from
'
../../lib/utils/common_utils
'
;
}
from
'
../../lib/utils/common_utils
'
;
import
{
s__
}
from
'
../../locale
'
;
import
{
s__
}
from
'
../../locale
'
;
import
Flash
from
'
../../flash
'
;
import
Flash
from
'
../../flash
'
;
...
@@ -46,17 +45,14 @@ export default {
...
@@ -46,17 +45,14 @@ export default {
methods
:
{
methods
:
{
saveData
(
resp
)
{
saveData
(
resp
)
{
const
headers
=
resp
.
headers
;
return
resp
.
json
().
then
((
response
)
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
if
(
_
.
isEqual
(
parseQueryStringIntoObject
(
resp
.
url
.
split
(
'
?
'
)[
1
])
,
this
.
requestData
))
{
if
(
_
.
isEqual
(
resp
.
config
.
params
,
this
.
requestData
))
{
this
.
store
.
storeAvailableCount
(
response
.
available_count
);
this
.
store
.
storeAvailableCount
(
resp
.
data
.
available_count
);
this
.
store
.
storeStoppedCount
(
response
.
stopped_count
);
this
.
store
.
storeStoppedCount
(
resp
.
data
.
stopped_count
);
this
.
store
.
storeEnvironments
(
response
.
environments
);
this
.
store
.
storeEnvironments
(
resp
.
data
.
environments
);
this
.
store
.
setPagination
(
headers
);
this
.
store
.
setPagination
(
resp
.
headers
);
}
}
});
},
},
/**
/**
...
...
app/assets/javascripts/environments/services/environments_service.js
View file @
1fa18585
/* eslint-disable class-methods-use-this */
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Vue
from
'
vue
'
;
import
VueResource
from
'
vue-resource
'
;
Vue
.
use
(
VueResource
);
export
default
class
EnvironmentsService
{
export
default
class
EnvironmentsService
{
constructor
(
endpoint
)
{
constructor
(
endpoint
)
{
this
.
environments
=
Vue
.
resource
(
endpoint
)
;
this
.
environments
Endpoint
=
endpoint
;
this
.
folderResults
=
3
;
this
.
folderResults
=
3
;
}
}
get
(
options
=
{})
{
get
(
options
=
{})
{
const
{
scope
,
page
}
=
options
;
const
{
scope
,
page
}
=
options
;
return
this
.
environments
.
get
({
scope
,
page
});
return
axios
.
get
(
this
.
environmentsEndpoint
,
{
params
:
{
scope
,
page
}
});
}
}
// eslint-disable-next-line class-methods-use-this
postAction
(
endpoint
)
{
postAction
(
endpoint
)
{
return
Vue
.
http
.
post
(
endpoint
,
{},
{
emulateJSON
:
true
});
return
axios
.
post
(
endpoint
,
{},
{
emulateJSON
:
true
});
}
}
getFolderContent
(
folderUrl
)
{
getFolderContent
(
folderUrl
)
{
return
Vue
.
http
.
get
(
`
${
folderUrl
}
.json?per_page=
${
this
.
folderResults
}
`
);
return
axios
.
get
(
`
${
folderUrl
}
.json?per_page=
${
this
.
folderResults
}
`
);
}
}
}
}
spec/javascripts/environments/environments_app_spec.js
View file @
1fa18585
import
_
from
'
underscore
'
;
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
environmentsComponent
from
'
~/environments/components/environments_app.vue
'
;
import
environmentsComponent
from
'
~/environments/components/environments_app.vue
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
headersInterceptor
}
from
'
spec/helpers/vue_resource_helper
'
;
import
{
environment
,
folder
}
from
'
./mock_data
'
;
import
{
environment
,
folder
}
from
'
./mock_data
'
;
describe
(
'
Environment
'
,
()
=>
{
describe
(
'
Environment
'
,
()
=>
{
...
@@ -18,35 +18,32 @@ describe('Environment', () => {
...
@@ -18,35 +18,32 @@ describe('Environment', () => {
let
EnvironmentsComponent
;
let
EnvironmentsComponent
;
let
component
;
let
component
;
let
mock
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
EnvironmentsComponent
=
Vue
.
extend
(
environmentsComponent
);
mock
=
new
MockAdapter
(
axios
);
});
describe
(
'
successfull request
'
,
()
=>
{
describe
(
'
without environments
'
,
()
=>
{
const
environmentsEmptyResponseInterceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
([]),
{
status
:
200
,
}));
};
beforeEach
(()
=>
{
EnvironmentsComponent
=
Vue
.
extend
(
environmentsComponent
);
Vue
.
http
.
interceptors
.
push
(
environmentsEmptyResponseInterceptor
);
Vue
.
http
.
interceptors
.
push
(
headersInterceptor
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
component
.
$destroy
();
Vue
.
http
.
interceptors
,
environmentsEmptyResponseInterceptor
,
mock
.
restore
();
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
headersInterceptor
);
});
});
it
(
'
should render the empty state
'
,
(
done
)
=>
{
describe
(
'
successfull request
'
,
()
=>
{
describe
(
'
without environments
'
,
()
=>
{
beforeEach
((
done
)
=>
{
mock
.
onGet
(
mockData
.
endpoint
).
reply
(
200
,
{
environments
:
[]
});
component
=
mountComponent
(
EnvironmentsComponent
,
mockData
);
component
=
mountComponent
(
EnvironmentsComponent
,
mockData
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
done
();
},
0
);
});
it
(
'
should render the empty state
'
,
()
=>
{
expect
(
expect
(
component
.
$el
.
querySelector
(
'
.js-new-environment-button
'
).
textContent
,
component
.
$el
.
querySelector
(
'
.js-new-environment-button
'
).
textContent
,
).
toContain
(
'
New environment
'
);
).
toContain
(
'
New environment
'
);
...
@@ -54,67 +51,43 @@ describe('Environment', () => {
...
@@ -54,67 +51,43 @@ describe('Environment', () => {
expect
(
expect
(
component
.
$el
.
querySelector
(
'
.js-blank-state-title
'
).
textContent
,
component
.
$el
.
querySelector
(
'
.js-blank-state-title
'
).
textContent
,
).
toContain
(
'
You don
\'
t have any environments right now.
'
);
).
toContain
(
'
You don
\'
t have any environments right now.
'
);
done
();
},
0
);
});
});
});
});
describe
(
'
with paginated environments
'
,
()
=>
{
describe
(
'
with paginated environments
'
,
()
=>
{
let
backupInterceptors
;
beforeEach
((
done
)
=>
{
const
environmentsResponseInterceptor
=
(
request
,
next
)
=>
{
mock
.
onGet
(
mockData
.
endpoint
).
reply
(
200
,
{
next
((
response
)
=>
{
response
.
headers
.
set
(
'
X-nExt-pAge
'
,
'
2
'
);
});
next
(
request
.
respondWith
(
JSON
.
stringify
({
environments
:
[
environment
],
environments
:
[
environment
],
stopped_count
:
1
,
stopped_count
:
1
,
available_count
:
0
,
available_count
:
0
,
}),
{
},
{
status
:
200
,
headers
:
{
'
X-nExt-pAge
'
:
'
2
'
,
'
X-nExt-pAge
'
:
'
2
'
,
'
x-page
'
:
'
1
'
,
'
x-page
'
:
'
1
'
,
'
X-Per-Page
'
:
'
1
'
,
'
X-Per-Page
'
:
'
1
'
,
'
X-Prev-Page
'
:
''
,
'
X-Prev-Page
'
:
''
,
'
X-TOTAL
'
:
'
37
'
,
'
X-TOTAL
'
:
'
37
'
,
'
X-Total-Pages
'
:
'
2
'
,
'
X-Total-Pages
'
:
'
2
'
,
},
});
}));
};
beforeEach
(()
=>
{
backupInterceptors
=
Vue
.
http
.
interceptors
;
Vue
.
http
.
interceptors
=
[
environmentsResponseInterceptor
,
headersInterceptor
,
];
component
=
mountComponent
(
EnvironmentsComponent
,
mockData
);
component
=
mountComponent
(
EnvironmentsComponent
,
mockData
);
});
afterEach
(()
=>
{
setTimeout
(()
=>
{
Vue
.
http
.
interceptors
=
backupInterceptors
;
done
();
},
0
);
});
});
it
(
'
should render a table with environments
'
,
(
done
)
=>
{
it
(
'
should render a table with environments
'
,
()
=>
{
setTimeout
(()
=>
{
expect
(
component
.
$el
.
querySelectorAll
(
'
table
'
)).
not
.
toBeNull
();
expect
(
component
.
$el
.
querySelectorAll
(
'
table
'
)).
not
.
toBeNull
();
expect
(
expect
(
component
.
$el
.
querySelector
(
'
.environment-name
'
).
textContent
.
trim
(),
component
.
$el
.
querySelector
(
'
.environment-name
'
).
textContent
.
trim
(),
).
toEqual
(
environment
.
name
);
).
toEqual
(
environment
.
name
);
done
();
},
0
);
});
});
describe
(
'
pagination
'
,
()
=>
{
describe
(
'
pagination
'
,
()
=>
{
it
(
'
should render pagination
'
,
(
done
)
=>
{
it
(
'
should render pagination
'
,
()
=>
{
setTimeout
(()
=>
{
expect
(
expect
(
component
.
$el
.
querySelectorAll
(
'
.gl-pagination li
'
).
length
,
component
.
$el
.
querySelectorAll
(
'
.gl-pagination li
'
).
length
,
).
toEqual
(
5
);
).
toEqual
(
5
);
done
();
},
0
);
});
});
it
(
'
should make an API request when page is clicked
'
,
(
done
)
=>
{
it
(
'
should make an API request when page is clicked
'
,
(
done
)
=>
{
...
@@ -133,50 +106,39 @@ describe('Environment', () => {
...
@@ -133,50 +106,39 @@ describe('Environment', () => {
expect
(
component
.
updateContent
).
toHaveBeenCalledWith
({
scope
:
'
stopped
'
,
page
:
'
1
'
});
expect
(
component
.
updateContent
).
toHaveBeenCalledWith
({
scope
:
'
stopped
'
,
page
:
'
1
'
});
done
();
done
();
});
}
,
0
);
});
});
});
});
});
});
});
});
describe
(
'
unsuccessfull request
'
,
()
=>
{
describe
(
'
unsuccessfull request
'
,
()
=>
{
const
environmentsErrorResponseInterceptor
=
(
request
,
next
)
=>
{
beforeEach
((
done
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
([]),
{
mock
.
onGet
(
mockData
.
endpoint
).
reply
(
500
,
{});
status
:
500
,
}));
};
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
environmentsErrorResponseInterceptor
);
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
environmentsErrorResponseInterceptor
,
);
});
it
(
'
should render empty state
'
,
(
done
)
=>
{
component
=
mountComponent
(
EnvironmentsComponent
,
mockData
);
component
=
mountComponent
(
EnvironmentsComponent
,
mockData
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
done
();
},
0
);
});
it
(
'
should render empty state
'
,
()
=>
{
expect
(
expect
(
component
.
$el
.
querySelector
(
'
.js-blank-state-title
'
).
textContent
,
component
.
$el
.
querySelector
(
'
.js-blank-state-title
'
).
textContent
,
).
toContain
(
'
You don
\'
t have any environments right now.
'
);
).
toContain
(
'
You don
\'
t have any environments right now.
'
);
done
();
},
0
);
});
});
});
});
describe
(
'
expandable folders
'
,
()
=>
{
describe
(
'
expandable folders
'
,
()
=>
{
const
environmentsResponseInterceptor
=
(
request
,
next
)
=>
{
beforeEach
(()
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
({
mock
.
onGet
(
mockData
.
endpoint
).
reply
(
200
,
{
environments
:
[
folder
],
environments
:
[
folder
],
stopped_count
:
0
,
stopped_count
:
0
,
available_count
:
1
,
available_count
:
1
,
}),
{
},
status
:
200
,
{
headers
:
{
'
X-nExt-pAge
'
:
'
2
'
,
'
X-nExt-pAge
'
:
'
2
'
,
'
x-page
'
:
'
1
'
,
'
x-page
'
:
'
1
'
,
'
X-Per-Page
'
:
'
1
'
,
'
X-Per-Page
'
:
'
1
'
,
...
@@ -184,18 +146,11 @@ describe('Environment', () => {
...
@@ -184,18 +146,11 @@ describe('Environment', () => {
'
X-TOTAL
'
:
'
37
'
,
'
X-TOTAL
'
:
'
37
'
,
'
X-Total-Pages
'
:
'
2
'
,
'
X-Total-Pages
'
:
'
2
'
,
},
},
}));
);
};
beforeEach
(()
=>
{
mock
.
onGet
(
environment
.
folder_path
).
reply
(
200
,
{
environments
:
[
environment
]
});
Vue
.
http
.
interceptors
.
push
(
environmentsResponseInterceptor
);
component
=
mountComponent
(
EnvironmentsComponent
,
mockData
);
});
afterEach
(()
=>
{
component
=
mountComponent
(
EnvironmentsComponent
,
mockData
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
environmentsResponseInterceptor
,
);
});
});
it
(
'
should open a closed folder
'
,
(
done
)
=>
{
it
(
'
should open a closed folder
'
,
(
done
)
=>
{
...
@@ -211,7 +166,7 @@ describe('Environment', () => {
...
@@ -211,7 +166,7 @@ describe('Environment', () => {
).
not
.
toContain
(
'
display: none
'
);
).
not
.
toContain
(
'
display: none
'
);
done
();
done
();
});
});
});
}
,
0
);
});
});
it
(
'
should close an opened folder
'
,
(
done
)
=>
{
it
(
'
should close an opened folder
'
,
(
done
)
=>
{
...
@@ -233,7 +188,7 @@ describe('Environment', () => {
...
@@ -233,7 +188,7 @@ describe('Environment', () => {
done
();
done
();
});
});
});
});
});
}
,
0
);
});
});
it
(
'
should show children environments and a button to show all environments
'
,
(
done
)
=>
{
it
(
'
should show children environments and a button to show all environments
'
,
(
done
)
=>
{
...
@@ -242,49 +197,32 @@ describe('Environment', () => {
...
@@ -242,49 +197,32 @@ describe('Environment', () => {
component
.
$el
.
querySelector
(
'
.folder-name
'
).
click
();
component
.
$el
.
querySelector
(
'
.folder-name
'
).
click
();
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
const
folderInterceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
({
environments
:
[
environment
],
}),
{
status
:
200
}));
};
Vue
.
http
.
interceptors
.
push
(
folderInterceptor
);
// wait for next async request
// wait for next async request
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
component
.
$el
.
querySelectorAll
(
'
.js-child-row
'
).
length
).
toEqual
(
1
);
expect
(
component
.
$el
.
querySelectorAll
(
'
.js-child-row
'
).
length
).
toEqual
(
1
);
expect
(
component
.
$el
.
querySelector
(
'
.text-center > a.btn
'
).
textContent
).
toContain
(
'
Show all
'
);
expect
(
component
.
$el
.
querySelector
(
'
.text-center > a.btn
'
).
textContent
).
toContain
(
'
Show all
'
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
folderInterceptor
);
done
();
done
();
});
});
});
});
});
}
,
0
);
});
});
});
});
describe
(
'
methods
'
,
()
=>
{
describe
(
'
methods
'
,
()
=>
{
const
environmentsEmptyResponseInterceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
([]),
{
status
:
200
,
}));
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
environmentsEmptyResponseInterceptor
);
mock
.
onGet
(
mockData
.
endpoint
).
reply
(
200
,
Vue
.
http
.
interceptors
.
push
(
headersInterceptor
);
{
environments
:
[],
stopped_count
:
0
,
available_count
:
1
,
},
{},
);
component
=
mountComponent
(
EnvironmentsComponent
,
mockData
);
component
=
mountComponent
(
EnvironmentsComponent
,
mockData
);
spyOn
(
history
,
'
pushState
'
).
and
.
stub
();
spyOn
(
history
,
'
pushState
'
).
and
.
stub
();
});
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
environmentsEmptyResponseInterceptor
,
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
headersInterceptor
);
});
describe
(
'
updateContent
'
,
()
=>
{
describe
(
'
updateContent
'
,
()
=>
{
it
(
'
should set given parameters
'
,
(
done
)
=>
{
it
(
'
should set given parameters
'
,
(
done
)
=>
{
component
.
updateContent
({
scope
:
'
stopped
'
,
page
:
'
3
'
})
component
.
updateContent
({
scope
:
'
stopped
'
,
page
:
'
3
'
})
...
...
spec/javascripts/environments/folder/environments_folder_view_spec.js
View file @
1fa18585
import
_
from
'
underscore
'
;
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
environmentsFolderViewComponent
from
'
~/environments/folder/environments_folder_view.vue
'
;
import
environmentsFolderViewComponent
from
'
~/environments/folder/environments_folder_view.vue
'
;
import
{
headersInterceptor
}
from
'
spec/helpers/vue_resource_helper
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
environmentsList
}
from
'
../mock_data
'
;
import
{
environmentsList
}
from
'
../mock_data
'
;
describe
(
'
Environments Folder View
'
,
()
=>
{
describe
(
'
Environments Folder View
'
,
()
=>
{
let
Component
;
let
Component
;
let
component
;
let
component
;
let
mock
;
const
mockData
=
{
const
mockData
=
{
endpoint
:
'
environments.json
'
,
endpoint
:
'
environments.json
'
,
folderName
:
'
review
'
,
folderName
:
'
review
'
,
...
@@ -17,44 +19,33 @@ describe('Environments Folder View', () => {
...
@@ -17,44 +19,33 @@ describe('Environments Folder View', () => {
};
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
Component
=
Vue
.
extend
(
environmentsFolderViewComponent
);
Component
=
Vue
.
extend
(
environmentsFolderViewComponent
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
mock
.
restore
();
component
.
$destroy
();
component
.
$destroy
();
});
});
describe
(
'
successfull request
'
,
()
=>
{
describe
(
'
successfull request
'
,
()
=>
{
const
environmentsResponseInterceptor
=
(
request
,
next
)
=>
{
beforeEach
((
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
(
{
mock
.
onGet
(
mockData
.
endpoint
).
reply
(
200
,
{
environments
:
environmentsList
,
environments
:
environmentsList
,
stopped_count
:
1
,
stopped_count
:
1
,
available_count
:
0
,
available_count
:
0
,
}),
{
},
{
status
:
200
,
headers
:
{
'
X-nExt-pAge
'
:
'
2
'
,
'
X-nExt-pAge
'
:
'
2
'
,
'
x-page
'
:
'
1
'
,
'
x-page
'
:
'
1
'
,
'
X-Per-Page
'
:
'
2
'
,
'
X-Per-Page
'
:
'
2
'
,
'
X-Prev-Page
'
:
''
,
'
X-Prev-Page
'
:
''
,
'
X-TOTAL
'
:
'
20
'
,
'
X-TOTAL
'
:
'
20
'
,
'
X-Total-Pages
'
:
'
10
'
,
'
X-Total-Pages
'
:
'
10
'
,
},
}));
};
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
environmentsResponseInterceptor
);
Vue
.
http
.
interceptors
.
push
(
headersInterceptor
);
component
=
mountComponent
(
Component
,
mockData
);
});
});
afterEach
(()
=>
{
component
=
mountComponent
(
Component
,
mockData
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
environmentsResponseInterceptor
,
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
headersInterceptor
);
});
});
it
(
'
should render a table with environments
'
,
(
done
)
=>
{
it
(
'
should render a table with environments
'
,
(
done
)
=>
{
...
@@ -135,25 +126,15 @@ describe('Environments Folder View', () => {
...
@@ -135,25 +126,15 @@ describe('Environments Folder View', () => {
});
});
describe
(
'
unsuccessfull request
'
,
()
=>
{
describe
(
'
unsuccessfull request
'
,
()
=>
{
const
environmentsErrorResponseInterceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
([]),
{
status
:
500
,
}));
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
environmentsErrorResponseInterceptor
);
mock
.
onGet
(
mockData
.
endpoint
).
reply
(
500
,
{
environments
:
[],
});
});
afterEach
(()
=>
{
component
=
mountComponent
(
Component
,
mockData
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
environmentsErrorResponseInterceptor
,
);
});
});
it
(
'
should not render a table
'
,
(
done
)
=>
{
it
(
'
should not render a table
'
,
(
done
)
=>
{
component
=
mountComponent
(
Component
,
mockData
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
expect
(
component
.
$el
.
querySelector
(
'
table
'
),
component
.
$el
.
querySelector
(
'
table
'
),
...
@@ -190,27 +171,15 @@ describe('Environments Folder View', () => {
...
@@ -190,27 +171,15 @@ describe('Environments Folder View', () => {
});
});
describe
(
'
methods
'
,
()
=>
{
describe
(
'
methods
'
,
()
=>
{
const
environmentsEmptyResponseInterceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
([]),
{
status
:
200
,
}));
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
environmentsEmptyResponseInterceptor
);
mock
.
onGet
(
mockData
.
endpoint
).
reply
(
200
,
{
Vue
.
http
.
interceptors
.
push
(
headersInterceptor
);
environments
:
[],
});
component
=
mountComponent
(
Component
,
mockData
);
component
=
mountComponent
(
Component
,
mockData
);
spyOn
(
history
,
'
pushState
'
).
and
.
stub
();
spyOn
(
history
,
'
pushState
'
).
and
.
stub
();
});
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
environmentsEmptyResponseInterceptor
,
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
headersInterceptor
);
});
describe
(
'
updateContent
'
,
()
=>
{
describe
(
'
updateContent
'
,
()
=>
{
it
(
'
should set given parameters
'
,
(
done
)
=>
{
it
(
'
should set given parameters
'
,
(
done
)
=>
{
component
.
updateContent
({
scope
:
'
stopped
'
,
page
:
'
4
'
})
component
.
updateContent
({
scope
:
'
stopped
'
,
page
:
'
4
'
})
...
...
spec/javascripts/environments/mock_data.js
View file @
1fa18585
...
@@ -82,6 +82,7 @@ export const environment = {
...
@@ -82,6 +82,7 @@ export const environment = {
stop_path
:
'
/root/review-app/environments/7/stop
'
,
stop_path
:
'
/root/review-app/environments/7/stop
'
,
created_at
:
'
2017-01-31T10:53:46.894Z
'
,
created_at
:
'
2017-01-31T10:53:46.894Z
'
,
updated_at
:
'
2017-01-31T10:53:46.894Z
'
,
updated_at
:
'
2017-01-31T10:53:46.894Z
'
,
folder_path
:
'
/root/review-app/environments/7
'
,
},
},
};
};
...
...
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