diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2016-08-25 15:40:11 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2016-08-25 15:40:11 +0000 |
commit | 871514f498e6ce8245c3f3ba647dc84be8a7fdfe (patch) | |
tree | bfb97b6d6a55cc4722ffc2fdba414a0d9814d793 /spec | |
parent | 97c14167ba3685bcd2eba195d018aeb4012c3bf6 (diff) | |
parent | 33694a5a6465785c2fcd5c8217197070cbd7b316 (diff) | |
download | gitlab-ce-871514f498e6ce8245c3f3ba647dc84be8a7fdfe.tar.gz |
Merge branch 'standardize-cookie-paths' into 'master'
Ensure all javascripts use GitLab install directory as the cookie path.
## What does this MR do?
Fixes #20435 and standardizes all JavaScript-set cookies to use the same root url.
## Are there points in the code the reviewer needs to double check?
Nothing I can think of. This MR is pretty straight forward.
## Why was this MR needed?
Cookie paths were inconsistent across front-end scripts. Some would default to '/' and others had no set path and would end up tied to whatever page they were set on. Also as @connorshea noted, we cannot assume GitLab is installed at '/'.
Before:
![Screen_Shot_2016-08-02_at_10.01.18_AM](/uploads/fa0238e2edf67a8e8ff48f8ee9c8d955/Screen_Shot_2016-08-02_at_10.01.18_AM.png)
After:
![Screen_Shot_2016-08-02_at_10.03.03_AM](/uploads/f1b95936d6f95f2ef1d7db10b5fb09d1/Screen_Shot_2016-08-02_at_10.03.03_AM.png)
## What are the relevant issue numbers?
#20435
## Screenshots (if relevant)
see above
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- Tests
- [x] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
See merge request !5627
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/awards_handler_spec.js | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/spec/javascripts/awards_handler_spec.js b/spec/javascripts/awards_handler_spec.js index fa32d0d7da5..c1c12b57b53 100644 --- a/spec/javascripts/awards_handler_spec.js +++ b/spec/javascripts/awards_handler_spec.js @@ -11,7 +11,7 @@ /*= require ./fixtures/emoji_menu */ (function() { - var awardsHandler, lazyAssert; + var awardsHandler, lazyAssert, urlRoot; awardsHandler = null; @@ -27,6 +27,7 @@ }; gon.award_menu_url = '/emojis'; + urlRoot = gon.relative_url_root; lazyAssert = function(done, assertFn) { return setTimeout(function() { @@ -45,9 +46,14 @@ return cb(); }; })(this)); - return spyOn(jQuery, 'get').and.callFake(function(req, cb) { + spyOn(jQuery, 'get').and.callFake(function(req, cb) { return cb(window.emojiMenu); }); + spyOn(jQuery, 'cookie'); + }); + afterEach(function() { + // restore original url root value + gon.relative_url_root = urlRoot; }); describe('::showEmojiMenu', function() { it('should show emoji menu when Add emoji button clicked', function(done) { @@ -189,6 +195,28 @@ return expect($thumbsUpEmoji.data("original-title")).toBe('sam'); }); }); + describe('::addEmojiToFrequentlyUsedList', function() { + it('should set a cookie with the correct default path', function() { + gon.relative_url_root = ''; + awardsHandler.addEmojiToFrequentlyUsedList('sunglasses'); + expect(jQuery.cookie) + .toHaveBeenCalledWith('frequently_used_emojis', 'sunglasses', { + path: '/', + expires: 365 + }) + ; + }); + it('should set a cookie with the correct custom root path', function() { + gon.relative_url_root = '/gitlab/subdir'; + awardsHandler.addEmojiToFrequentlyUsedList('alien'); + expect(jQuery.cookie) + .toHaveBeenCalledWith('frequently_used_emojis', 'alien', { + path: '/gitlab/subdir', + expires: 365 + }) + ; + }); + }); describe('search', function() { return it('should filter the emoji', function() { $('.js-add-award').eq(0).click(); |