Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSteffen Rauh <steffen.rauh@gmx.de>2016-11-17 15:05:32 +0300
committerSteffen Rauh <steffen.rauh@gmx.de>2016-12-04 00:40:18 +0300
commit0966c6d2c674f288be3f1adf576a2fa2aada3691 (patch)
treeaebe3209d3537154df58a9fe54d39a6632abd895 /spec
parent0819d093e9b4aa9d5af1f6bdde147462f0c7cb48 (diff)
Fix compatibility with Internet Explorer 11 for merge requests
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/lib/utils/common_utils_spec.js.es632
-rw-r--r--spec/javascripts/merge_request_tabs_spec.js13
2 files changed, 44 insertions, 1 deletions
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js.es6 b/spec/javascripts/lib/utils/common_utils_spec.js.es6
new file mode 100644
index 00000000000..ef75f600898
--- /dev/null
+++ b/spec/javascripts/lib/utils/common_utils_spec.js.es6
@@ -0,0 +1,32 @@
+//= require lib/utils/common_utils
+
+(() => {
+ describe('common_utils', () => {
+ describe('gl.utils.parseUrl', () => {
+ it('returns an anchor tag with url', () => {
+ expect(gl.utils.parseUrl('/some/absolute/url').pathname).toContain('some/absolute/url');
+ });
+ it('url is escaped', () => {
+ // IE11 will return a relative pathname while other browsers will return a full pathname.
+ // parseUrl uses an anchor element for parsing an url. With relative urls, the anchor
+ // element will create an absolute url relative to the current execution context.
+ // The JavaScript test suite is executed at '/teaspoon' which will lead to an absolute
+ // url starting with '/teaspoon'.
+ expect(gl.utils.parseUrl('" test="asf"').pathname).toEqual('/teaspoon/%22%20test=%22asf%22');
+ });
+ });
+ describe('gl.utils.parseUrlPathname', () => {
+ beforeEach(() => {
+ spyOn(gl.utils, 'parseUrl').and.callFake(url => ({
+ pathname: url,
+ }));
+ });
+ it('returns an absolute url when given an absolute url', () => {
+ expect(gl.utils.parseUrlPathname('/some/absolute/url')).toEqual('/some/absolute/url');
+ });
+ it('returns an absolute url when given a relative url', () => {
+ expect(gl.utils.parseUrlPathname('some/relative/url')).toEqual('/some/relative/url');
+ });
+ });
+ });
+})();
diff --git a/spec/javascripts/merge_request_tabs_spec.js b/spec/javascripts/merge_request_tabs_spec.js
index 65e4177ecfe..4facc42c5b4 100644
--- a/spec/javascripts/merge_request_tabs_spec.js
+++ b/spec/javascripts/merge_request_tabs_spec.js
@@ -2,6 +2,8 @@
/*= require merge_request_tabs */
//= require breakpoints
+//= require lib/utils/common_utils
+//= require jquery.scrollTo
(function () {
describe('MergeRequestTabs', function () {
@@ -21,13 +23,13 @@
setLocation();
this.spies = {
- ajax: spyOn($, 'ajax').and.callFake(function () {}),
history: spyOn(window.history, 'replaceState').and.callFake(function () {})
};
});
describe('#activateTab', function () {
beforeEach(function () {
+ spyOn($, 'ajax').and.callFake(function() {});
fixture.load('merge_request_tabs.html');
this.subject = this.class.activateTab;
});
@@ -51,6 +53,7 @@
describe('#setCurrentAction', function () {
beforeEach(function () {
+ spyOn($, 'ajax').and.callFake(function() {});
this.subject = this.class.setCurrentAction;
});
it('changes from commits', function () {
@@ -107,5 +110,13 @@
expect(this.subject('show')).toBe('/foo/bar/merge_requests/1');
});
});
+ describe('#loadDiff', function() {
+ it('requires an absolute pathname', function() {
+ spyOn($, 'ajax').and.callFake(function(options) {
+ expect(options.url).toEqual('/foo/bar/merge_requests/1/diffs.json');
+ });
+ this.class.loadDiff('/foo/bar/merge_requests/1/diffs');
+ });
+ });
});
}).call(this);