Commit 65ae8681 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch '2682-cross-project-pipelines-are-broken' into 'master'

Resolve "Cross-project pipelines are broken"

Closes #2682

See merge request !2166
parents fadfe8e0 b0389471
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
return this.pipeline.triggered || []; return this.pipeline.triggered || [];
}, },
triggeredBy() { triggeredBy() {
return this.pipeline.triggeredBy || []; const response = this.pipeline.triggered_by;
return response ? [response] : [];
}, },
hasTriggered() { hasTriggered() {
return !!this.triggered.length; return !!this.triggered.length;
......
...@@ -38,7 +38,8 @@ export default { ...@@ -38,7 +38,8 @@ export default {
return this.mr.pipeline.triggered || []; return this.mr.pipeline.triggered || [];
}, },
triggeredBy() { triggeredBy() {
return this.mr.pipeline.triggered_by || []; const response = this.mr.pipeline.triggered_by;
return response ? [response] : [];
}, },
}, },
template: ` template: `
......
...@@ -7,7 +7,7 @@ const GraphComponent = Vue.extend(graphComponent); ...@@ -7,7 +7,7 @@ const GraphComponent = Vue.extend(graphComponent);
const pipelineJSON = Object.assign(graphJSON, { const pipelineJSON = Object.assign(graphJSON, {
triggered: linkedPipelineJSON.triggered, triggered: linkedPipelineJSON.triggered,
triggeredBy: linkedPipelineJSON.triggered_by, triggered_by: linkedPipelineJSON.triggered_by,
}); });
const defaultPropsData = { const defaultPropsData = {
...@@ -83,6 +83,10 @@ describe('graph component', function () { ...@@ -83,6 +83,10 @@ describe('graph component', function () {
}); });
describe('linked pipelines components', function () { describe('linked pipelines components', function () {
it('should coerce triggeredBy into a collection', function () {
expect(this.component.triggeredBy.length).toBe(1);
});
it('should render an upstream pipelines column', function () { it('should render an upstream pipelines column', function () {
expect(this.component.$el.querySelector('.linked-pipelines-column')).not.toBeNull(); expect(this.component.$el.querySelector('.linked-pipelines-column')).not.toBeNull();
expect(this.component.$el.innerHTML).toContain('Upstream'); expect(this.component.$el.innerHTML).toContain('Upstream');
...@@ -97,7 +101,7 @@ describe('graph component', function () { ...@@ -97,7 +101,7 @@ describe('graph component', function () {
describe('when linked pipelines are not present', function () { describe('when linked pipelines are not present', function () {
beforeEach(function () { beforeEach(function () {
const pipeline = Object.assign(graphJSON, { triggered: [], triggeredBy: [] }); const pipeline = Object.assign(graphJSON, { triggered: [], triggered_by: [] });
this.component = new GraphComponent({ this.component = new GraphComponent({
propsData: { pipeline, isLoading: false }, propsData: { pipeline, isLoading: false },
}).$mount(); }).$mount();
......
/* eslint-disable quote-props, quotes, comma-dangle */ /* eslint-disable quote-props, quotes, comma-dangle */
export default { export default {
"triggered_by": [{ "triggered_by": {
"id": 129, "id": 129,
"active": true, "active": true,
"path": "/gitlab-org/gitlab-ce/pipelines/129", "path": "/gitlab-org/gitlab-ce/pipelines/129",
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
"cancel_path": "/gitlab-org/gitlab-ce/pipelines/129/cancel", "cancel_path": "/gitlab-org/gitlab-ce/pipelines/129/cancel",
"created_at": "2017-05-24T14:46:20.090Z", "created_at": "2017-05-24T14:46:20.090Z",
"updated_at": "2017-05-24T14:46:29.906Z" "updated_at": "2017-05-24T14:46:29.906Z"
}], },
"triggered": [{ "triggered": [{
"id": 132, "id": 132,
"active": true, "active": true,
......
...@@ -130,6 +130,14 @@ describe('MRWidgetPipeline', () => { ...@@ -130,6 +130,14 @@ describe('MRWidgetPipeline', () => {
}); });
}); });
it('should set triggered to an empty array', () => {
expect(vm.triggered.length).toBe(0);
});
it('should set triggeredBy to an empty array', () => {
expect(vm.triggeredBy.length).toBe(0);
});
it('should not render upstream or downstream pipelines', () => { it('should not render upstream or downstream pipelines', () => {
expect(el.querySelector('.linked-pipeline-mini-list')).toBeNull(); expect(el.querySelector('.linked-pipeline-mini-list')).toBeNull();
}); });
...@@ -149,6 +157,10 @@ describe('MRWidgetPipeline', () => { ...@@ -149,6 +157,10 @@ describe('MRWidgetPipeline', () => {
}).$mount(); }).$mount();
}); });
it('should coerce triggeredBy into a collection', function () {
expect(this.vm.triggeredBy.length).toBe(1);
});
it('should render the linked pipelines mini list', function (done) { it('should render the linked pipelines mini list', function (done) {
Vue.nextTick(() => { Vue.nextTick(() => {
expect(this.vm.$el.querySelector('.linked-pipeline-mini-list.is-upstream')).not.toBeNull(); expect(this.vm.$el.querySelector('.linked-pipeline-mini-list.is-upstream')).not.toBeNull();
......
...@@ -9,7 +9,7 @@ describe('Linked pipeline mini list', () => { ...@@ -9,7 +9,7 @@ describe('Linked pipeline mini list', () => {
beforeEach(() => { beforeEach(() => {
this.component = new ListComponent({ this.component = new ListComponent({
propsData: { propsData: {
triggeredBy: mockData.triggered_by, triggeredBy: [mockData.triggered_by],
}, },
}).$mount(); }).$mount();
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment