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 @@
return this.pipeline.triggered || [];
},
triggeredBy() {
return this.pipeline.triggeredBy || [];
const response = this.pipeline.triggered_by;
return response ? [response] : [];
},
hasTriggered() {
return !!this.triggered.length;
......
......@@ -38,7 +38,8 @@ export default {
return this.mr.pipeline.triggered || [];
},
triggeredBy() {
return this.mr.pipeline.triggered_by || [];
const response = this.mr.pipeline.triggered_by;
return response ? [response] : [];
},
},
template: `
......
......@@ -7,7 +7,7 @@ const GraphComponent = Vue.extend(graphComponent);
const pipelineJSON = Object.assign(graphJSON, {
triggered: linkedPipelineJSON.triggered,
triggeredBy: linkedPipelineJSON.triggered_by,
triggered_by: linkedPipelineJSON.triggered_by,
});
const defaultPropsData = {
......@@ -83,6 +83,10 @@ describe('graph component', 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 () {
expect(this.component.$el.querySelector('.linked-pipelines-column')).not.toBeNull();
expect(this.component.$el.innerHTML).toContain('Upstream');
......@@ -97,7 +101,7 @@ describe('graph component', function () {
describe('when linked pipelines are not present', function () {
beforeEach(function () {
const pipeline = Object.assign(graphJSON, { triggered: [], triggeredBy: [] });
const pipeline = Object.assign(graphJSON, { triggered: [], triggered_by: [] });
this.component = new GraphComponent({
propsData: { pipeline, isLoading: false },
}).$mount();
......
/* eslint-disable quote-props, quotes, comma-dangle */
export default {
"triggered_by": [{
"triggered_by": {
"id": 129,
"active": true,
"path": "/gitlab-org/gitlab-ce/pipelines/129",
......@@ -56,7 +56,7 @@ export default {
"cancel_path": "/gitlab-org/gitlab-ce/pipelines/129/cancel",
"created_at": "2017-05-24T14:46:20.090Z",
"updated_at": "2017-05-24T14:46:29.906Z"
}],
},
"triggered": [{
"id": 132,
"active": true,
......
......@@ -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', () => {
expect(el.querySelector('.linked-pipeline-mini-list')).toBeNull();
});
......@@ -149,6 +157,10 @@ describe('MRWidgetPipeline', () => {
}).$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) {
Vue.nextTick(() => {
expect(this.vm.$el.querySelector('.linked-pipeline-mini-list.is-upstream')).not.toBeNull();
......
......@@ -9,7 +9,7 @@ describe('Linked pipeline mini list', () => {
beforeEach(() => {
this.component = new ListComponent({
propsData: {
triggeredBy: mockData.triggered_by,
triggeredBy: [mockData.triggered_by],
},
}).$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