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

issue_spec.js.coffee « javascripts « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f8e60565b9a0160e221742593bee2daf1d19e023 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#= require issue

describe 'Issue', ->
  describe 'task lists', ->
    fixture.preload('issues_show.html')

    beforeEach ->
      fixture.load('issues_show.html')
      @issue = new Issue()

    it 'modifies the Markdown field', ->
      spyOn(jQuery, 'ajax').and.stub()
      $('input[type=checkbox]').attr('checked', true).trigger('change')
      expect($('.js-task-list-field').val()).toBe('- [x] Task List Item')

    it 'submits an ajax request on tasklist:changed', ->
      spyOn(jQuery, 'ajax').and.callFake (req) ->
        expect(req.type).toBe('PATCH')
        expect(req.url).toBe('/foo')
        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
    
    # setup
    $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')

    # excerize
    $btnClose.trigger('click')
    
    # verify
    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)

    # teardown
  it 'reopens an issue', ->
    $.ajax = (obj) ->
      expect(obj.type).toBe('PUT')
      expect(obj.url).toBe('http://gitlab/issues/6/reopen')
      obj.success saved: true

    # setup
    $btnClose = $('a.btn-close')
    $btnReopen = $('a.btn-reopen')
    expect(typeof $btnReopen.prop('disabled')).toBe('undefined')
    expect($btnReopen.text()).toBe('Reopen')

    # excerize
    $btnReopen.trigger('click')

    # verify
    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)

    # teardown