summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2017-12-19 13:20:06 +0100
committerWinnie Hellmann <winnie@gitlab.com>2017-12-20 22:00:46 +0100
commit408b56bd948edc80b212cd8025bbbee921c69d6b (patch)
treeabe7781875c65595643a119f6e4e83f3bf765007
parente0a27ee419b55509204ba2bfbdbfbab3c7c331bc (diff)
downloadgitlab-ce-408b56bd948edc80b212cd8025bbbee921c69d6b.tar.gz
Fix racing condition in Ajax call of merge_request_tabs_spec.jswinh-fix-transient-loadDiff-failure
-rw-r--r--spec/javascripts/merge_request_tabs_spec.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/spec/javascripts/merge_request_tabs_spec.js b/spec/javascripts/merge_request_tabs_spec.js
index 050f0ea9ebd..a6be474805b 100644
--- a/spec/javascripts/merge_request_tabs_spec.js
+++ b/spec/javascripts/merge_request_tabs_spec.js
@@ -290,15 +290,18 @@ import 'vendor/jquery.scrollTo';
$('body').removeAttr('data-page');
});
- it('requires an absolute pathname', function () {
- spyOn($, 'ajax').and.callFake(function (options) {
- expect(options.url).toEqual('/foo/bar/merge_requests/1/diffs.json');
+ it('triggers Ajax request to JSON endpoint', function (done) {
+ const url = '/foo/bar/merge_requests/1/diffs';
+ spyOn(this.class, 'ajaxGet').and.callFake((options) => {
+ expect(options.url).toEqual(`${url}.json`);
+ done();
});
- this.class.loadDiff('/foo/bar/merge_requests/1/diffs');
+ this.class.loadDiff(url);
});
- it('triggers scroll event when diff already loaded', function () {
+ it('triggers scroll event when diff already loaded', function (done) {
+ spyOn(this.class, 'ajaxGet').and.callFake(() => done.fail());
spyOn(document, 'dispatchEvent');
this.class.diffsLoaded = true;
@@ -307,6 +310,7 @@ import 'vendor/jquery.scrollTo';
expect(
document.dispatchEvent,
).toHaveBeenCalledWith(new CustomEvent('scroll'));
+ done();
});
describe('with inline diff', () => {