diff options
author | Luke Bennett <lukeeeebennettplus@gmail.com> | 2016-10-07 23:10:06 +0100 |
---|---|---|
committer | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-10-14 11:07:01 +0200 |
commit | 58368fbc53bfe7c2a9b425626819eae576afff09 (patch) | |
tree | a66e1cad72a4fd959e06c54b628a49aad2e4547a /spec/javascripts | |
parent | fa58068b2894b900d4b2519825411e0710557fc6 (diff) | |
download | gitlab-ce-58368fbc53bfe7c2a9b425626819eae576afff09.tar.gz |
Moved ci_status environments logic to new action ci_envrionments_status and set up frontend polling
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/merge_request_widget_spec.js | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/spec/javascripts/merge_request_widget_spec.js b/spec/javascripts/merge_request_widget_spec.js index 75ef10939de..7b20572742c 100644 --- a/spec/javascripts/merge_request_widget_spec.js +++ b/spec/javascripts/merge_request_widget_spec.js @@ -8,6 +8,7 @@ window.notify = function() {}; this.opts = { ci_status_url: "http://sampledomain.local/ci/getstatus", + ci_environments_status_url: "http://sampledomain.local/ci/getenvironmentsstatus", ci_status: "", ci_message: { normal: "Build {{status}} for \"{{title}}\"", @@ -21,15 +22,45 @@ builds_path: "http://sampledomain.local/sampleBuildsPath" }; this["class"] = new window.gl.MergeRequestWidget(this.opts); - return this.ciStatusData = { - "title": "Sample MR title", - "sha": "12a34bc5", - "status": "success", - "coverage": 98 - }; }); + + describe('getCIEnvironmentsStatus', function() { + beforeEach(function() { + this.ciEnvironmentsStatusData = { + created_at: '2016-09-12T13:38:30.636Z', + environment_id: 1, + environment_name: 'env1', + external_url: 'https://test-url.com', + external_url_formatted: 'test-url.com' + }; + + spyOn(jQuery, 'getJSON').and.callFake((req, cb) => { + cb(this.ciEnvironmentsStatusData); + }); + }); + + it('should call renderEnvironments when the environments property is set', function() { + const spy = spyOn(this.class, 'renderEnvironments').and.stub(); + this.class.getCIEnvironmentsStatus(); + expect(spy).toHaveBeenCalledWith(this.ciEnvironmentsStatusData); + }); + + it('should not call renderEnvironments when the environments property is not set', function() { + const spy = spyOn(this.class, 'renderEnvironments').and.stub(); + this.class.getCIEnvironmentsStatus(); + expect(spy).not.toHaveBeenCalled(); + }); + }); + return describe('getCIStatus', function() { beforeEach(function() { + this.ciStatusData = { + "title": "Sample MR title", + "sha": "12a34bc5", + "status": "success", + "coverage": 98 + }; + spyOn(jQuery, 'getJSON').and.callFake((function(_this) { return function(req, cb) { return cb(_this.ciStatusData); @@ -68,23 +99,6 @@ this["class"].getCIStatus(true); return expect(spy).not.toHaveBeenCalled(); }); - it('should call renderEnvironments when the environments property is set', function() { - this.ciStatusData.environments = [{ - created_at: '2016-09-12T13:38:30.636Z', - environment_id: 1, - environment_name: 'env1', - external_url: 'https://test-url.com', - external_url_formatted: 'test-url.com' - }]; - var spy = spyOn(this['class'], 'renderEnvironments').and.stub(); - this['class'].getCIStatus(false); - expect(spy).toHaveBeenCalledWith(this.ciStatusData.environments); - }); - it('should not call renderEnvironments when the environments property is not set', function() { - var spy = spyOn(this['class'], 'renderEnvironments').and.stub(); - this['class'].getCIStatus(false); - expect(spy).not.toHaveBeenCalled(); - }); }); }); |