diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-10-27 16:28:40 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-10-27 16:28:40 +0300 |
commit | f879319840949c1d4b363742cb9573d89abd1296 (patch) | |
tree | 7138a0edfb88cc4cb86a078bc0a3e2f93df64125 /spec/javascripts/right_sidebar_spec.js | |
parent | 337c5ded7ed46f69efc9d1c47114d3b5a18dceba (diff) | |
parent | f610f69ab92827c49e9cbb528cacc26af10be081 (diff) |
Merge branch 'add-todo-toggle-event' into 'master'
Add todo toggle event
## What does this MR do?
Adds a custom jQuery event `todo:toggle` to detect when a new todo is added so that the respective todo counters (header navigation and sidebar) can update as needed
## Are there points in the code the reviewer needs to double check?
* I wasn't sure whether each `spec` should be modularized based on the html templates or whether they should be separated based on function. There are some crossovers between the `dashboard_spec` and the `header_spec`.
* The naming conventions for `sidebar` and `right_sidebar` were a little confusing since they were named the opposite in their `specs`. I made a few assumptions and named a few files based on what I thought they should be named. I'd be happy to change it to something else though :smile:
## Why was this MR needed?
This resolves an existing issue where the todo count on the sidebar would not update (until refresh) and refactors the existing methods that are used to update the todo counters (header navigation and sidebar)
## What are the relevant issue numbers?
Closes #20140
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- 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 !5724
Diffstat (limited to 'spec/javascripts/right_sidebar_spec.js')
-rw-r--r-- | spec/javascripts/right_sidebar_spec.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/javascripts/right_sidebar_spec.js b/spec/javascripts/right_sidebar_spec.js index c191e42dff7..ef03d1147de 100644 --- a/spec/javascripts/right_sidebar_spec.js +++ b/spec/javascripts/right_sidebar_spec.js @@ -4,6 +4,8 @@ /*= require jquery */ /*= require js.cookie */ +/*= require extensions/jquery.js */ + (function() { var $aside, $icon, $labelsIcon, $page, $toggle, assertSidebarState; @@ -56,12 +58,27 @@ $labelsIcon.click(); return assertSidebarState('expanded'); }); - return it('should collapse when the icon arrow clicked while it is floating on page', function() { + it('should collapse when the icon arrow clicked while it is floating on page', function() { $labelsIcon.click(); assertSidebarState('expanded'); $toggle.click(); return assertSidebarState('collapsed'); }); + + it('should broadcast todo:toggle event when add todo clicked', function() { + spyOn(jQuery, 'ajax').and.callFake(function() { + var d = $.Deferred(); + var response = fixture.load('todos.json'); + d.resolve(response); + return d.promise(); + }); + + var todoToggleSpy = spyOnEvent(document, 'todo:toggle'); + + $('.js-issuable-todo').click(); + + expect(todoToggleSpy.calls.count()).toEqual(1); + }) }); }).call(this); |