diff options
author | Jacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home> | 2015-12-21 13:06:09 -0500 |
---|---|---|
committer | Jacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home> | 2015-12-21 13:06:09 -0500 |
commit | 70dfa3a721700cf0151a7d097933d75684e69fc9 (patch) | |
tree | f683e0e75e10bda55e7b5596635c471e8379a9f5 /spec | |
parent | 4b4cbf0ce4925e22a635e4432e7ac8602199fa5b (diff) | |
download | gitlab-ce-70dfa3a721700cf0151a7d097933d75684e69fc9.tar.gz |
open and close issue via ajax request. With tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/fixtures/issues_show.html.haml | 5 | ||||
-rw-r--r-- | spec/javascripts/issue_spec.js.coffee | 36 |
2 files changed, 40 insertions, 1 deletions
diff --git a/spec/javascripts/fixtures/issues_show.html.haml b/spec/javascripts/fixtures/issues_show.html.haml index 8447dfdda32..6c985a32966 100644 --- a/spec/javascripts/fixtures/issues_show.html.haml +++ b/spec/javascripts/fixtures/issues_show.html.haml @@ -1,4 +1,7 @@ -%a.btn-close +.issue-box.issue-box-open Open +.issue-box.issue-box-closed.hidden Closed +%a.btn-close{"data-url" => "http://gitlab/issues/6/close"} Close +%a.btn-reopen.hidden{"data-url" => "http://gitlab/issues/6/reopen"} Reopen .detail-page-description .description.js-task-list-container diff --git a/spec/javascripts/issue_spec.js.coffee b/spec/javascripts/issue_spec.js.coffee index 268e4c68c31..60df3a8878b 100644 --- a/spec/javascripts/issue_spec.js.coffee +++ b/spec/javascripts/issue_spec.js.coffee @@ -20,3 +20,39 @@ describe 'Issue', -> expect(req.data.issue.description).not.toBe(null) $('.js-task-list-field').trigger('tasklist:changed') +describe 'reopen/close issue', -> + fixture.preload('issues_show.html') + beforeEach -> + fixture.load('issues_show.html') + @issue = new Issue() + it 'closes an issue', -> + $.ajax = (obj) -> + expect(obj.type).toBe('PUT') + expect(obj.url).toBe('http://gitlab/issues/6/close') + obj.success saved: true + $btnClose = $('a.btn-close') + $btnReopen = $('a.btn-reopen') + expect($btnReopen.hasClass('hidden')).toBe(true) + expect($btnClose.text()).toBe('Close') + expect(typeof $btnClose.prop('disabled')).toBe('undefined') + $btnClose.trigger('click') + expect($btnClose.hasClass('hidden')).toBe(true) + expect($btnReopen.hasClass('hidden')).toBe(false) + expect($btnClose.prop('disabled')).toBe(false) + expect($('div.issue-box-open').hasClass('hidden')).toBe(true) + expect($('div.issue-box-closed').hasClass('hidden')).toBe(false) + it 'reopens an issue', -> + $.ajax = (obj) -> + expect(obj.type).toBe('PUT') + expect(obj.url).toBe('http://gitlab/issues/6/reopen') + obj.success saved: true + $btnClose = $('a.btn-close') + $btnReopen = $('a.btn-reopen') + expect(typeof $btnReopen.prop('disabled')).toBe('undefined') + expect($btnReopen.text()).toBe('Reopen') + $btnReopen.trigger('click') + expect($btnReopen.hasClass('hidden')).toBe(true) + expect($btnClose.hasClass('hidden')).toBe(false) + expect($btnReopen.prop('disabled')).toBe(false) + expect($('div.issue-box-open').hasClass('hidden')).toBe(false) + expect($('div.issue-box-closed').hasClass('hidden')).toBe(true)
\ No newline at end of file |