Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
d320090f
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
d320090f
编写于
4月 10, 2018
作者:
F
Filipa Lacerda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update state request from vue resource to axios
上级
9d220da8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
68 deletion
+35
-68
app/assets/javascripts/pipelines/components/stage.vue
app/assets/javascripts/pipelines/components/stage.vue
+8
-10
spec/javascripts/pipelines/stage_spec.js
spec/javascripts/pipelines/stage_spec.js
+27
-58
未找到文件。
app/assets/javascripts/pipelines/components/stage.vue
浏览文件 @
d320090f
...
...
@@ -13,16 +13,16 @@
* 3. Merge request widget
* 4. Commit widget
*/
import
axios
from
'
../../lib/utils/axios_utils
'
;
import
Flash
from
'
../../flash
'
;
import
i
con
from
'
../../vue_shared/components/icon.vue
'
;
import
l
oadingIcon
from
'
../../vue_shared/components/loading_icon.vue
'
;
import
I
con
from
'
../../vue_shared/components/icon.vue
'
;
import
L
oadingIcon
from
'
../../vue_shared/components/loading_icon.vue
'
;
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
export
default
{
components
:
{
l
oadingIcon
,
i
con
,
L
oadingIcon
,
I
con
,
},
directives
:
{
...
...
@@ -88,9 +88,8 @@
},
fetchJobs
()
{
this
.
$http
.
get
(
this
.
stage
.
dropdown_path
)
.
then
(
response
=>
response
.
json
())
.
then
((
data
)
=>
{
axios
.
get
(
this
.
stage
.
dropdown_path
)
.
then
(({
data
})
=>
{
this
.
dropdownContent
=
data
.
html
;
this
.
isLoading
=
false
;
})
...
...
@@ -98,8 +97,7 @@
this
.
closeDropdown
();
this
.
isLoading
=
false
;
const
flash
=
new
Flash
(
'
Something went wrong on our end.
'
);
return
flash
;
Flash
(
'
Something went wrong on our end.
'
);
});
},
...
...
spec/javascripts/pipelines/stage_spec.js
浏览文件 @
d320090f
import
_
from
'
underscore
'
;
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
stage
from
'
~/pipelines/components/stage.vue
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
describe
(
'
Pipelines stage component
'
,
()
=>
{
let
StageComponent
;
let
component
;
let
mock
;
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
StageComponent
=
Vue
.
extend
(
stage
);
component
=
new
StageComponent
({
propsData
:
{
stage
:
{
status
:
{
group
:
'
success
'
,
icon
:
'
icon_status_success
'
,
title
:
'
success
'
,
},
dropdown_path
:
'
foo
'
,
component
=
mountComponent
(
StageComponent
,
{
stage
:
{
status
:
{
group
:
'
success
'
,
icon
:
'
icon_status_success
'
,
title
:
'
success
'
,
},
updateDropdown
:
false
,
dropdown_path
:
'
path.json
'
,
},
}).
$mount
();
updateDropdown
:
false
,
});
});
afterEach
(()
=>
{
component
.
$destroy
();
mock
.
restore
();
});
it
(
'
should render a dropdown with the status icon
'
,
()
=>
{
...
...
@@ -31,23 +39,11 @@ describe('Pipelines stage component', () => {
});
describe
(
'
with successfull request
'
,
()
=>
{
const
interceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
({
html
:
'
foo
'
}),
{
status
:
200
,
}));
};
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
interceptor
);
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
interceptor
,
);
mock
.
onGet
(
'
path.json
'
).
reply
(
200
,
{
html
:
'
foo
'
});
});
it
(
'
should render the received data
'
,
(
done
)
=>
{
it
(
'
should render the received data
'
,
done
=>
{
component
.
$el
.
querySelector
(
'
button
'
).
click
();
setTimeout
(()
=>
{
...
...
@@ -60,20 +56,8 @@ describe('Pipelines stage component', () => {
});
describe
(
'
when request fails
'
,
()
=>
{
const
interceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
({}),
{
status
:
500
,
}));
};
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
interceptor
);
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
interceptor
,
);
mock
.
onGet
(
'
path.json
'
).
reply
(
500
);
});
it
(
'
should close the dropdown
'
,
()
=>
{
...
...
@@ -86,33 +70,18 @@ describe('Pipelines stage component', () => {
});
describe
(
'
update endpoint correctly
'
,
()
=>
{
const
updatedInterceptor
=
(
request
,
next
)
=>
{
if
(
request
.
url
===
'
bar
'
)
{
next
(
request
.
respondWith
(
JSON
.
stringify
({
html
:
'
this is the updated content
'
}),
{
status
:
200
,
}));
}
next
();
};
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
updatedInterceptor
);
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
updatedInterceptor
,
);
mock
.
onGet
(
'
bar.json
'
).
reply
(
200
,
{
html
:
'
this is the updated content
'
});
});
it
(
'
should update the stage to request the new endpoint provided
'
,
(
done
)
=>
{
it
(
'
should update the stage to request the new endpoint provided
'
,
done
=>
{
component
.
stage
=
{
status
:
{
group
:
'
running
'
,
icon
:
'
running
'
,
title
:
'
running
'
,
},
dropdown_path
:
'
bar
'
,
dropdown_path
:
'
bar
.json
'
,
};
Vue
.
nextTick
(()
=>
{
...
...
@@ -121,7 +90,7 @@ describe('Pipelines stage component', () => {
setTimeout
(()
=>
{
expect
(
component
.
$el
.
querySelector
(
'
.js-builds-dropdown-container ul
'
).
textContent
.
trim
(),
).
toEqual
(
'
this is the updated content
'
);
).
toEqual
(
'
this is the updated content
'
);
done
();
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录