issues_spec.rb 19.6 KB
Newer Older
1
2
require 'spec_helper'

3
describe 'Issues' do
4
  include DropzoneHelper
5
  include IssueHelpers
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
6
7
  include SortingHelper

8
  let(:user) { create(:user) }
9
  let(:project) { create(:project, :public) }
10
11

  before do
12
    sign_in(user)
13
14
    user2 = create(:user)

15
    project.team << [[user, user2], :developer]
16
17
  end

Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
18
  describe 'Edit issue' do
19
20
    let!(:issue) do
      create(:issue,
21
22
             author: user,
             assignees: [user],
23
24
25
26
             project: project)
    end

    before do
27
      visit edit_project_issue_path(project, issue)
Jacob Schatz's avatar
Jacob Schatz committed
28
      find('.js-zen-enter').click
29
30
    end

31
    it 'opens new issue popup' do
32
      expect(page).to have_content("Issue ##{issue.iid}")
33
    end
34
35
  end

Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
36
  describe 'Editing issue assignee' do
37
38
    let!(:issue) do
      create(:issue,
39
40
             author: user,
             assignees: [user],
41
42
43
             project: project)
    end

44
    it 'allows user to select unassigned', js: true do
45
      visit edit_project_issue_path(project, issue)
46

47
      expect(page).to have_content "Assignee #{user.name}"
48

49
50
      first('.js-user-search').click
      click_link 'Unassigned'
51

Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
52
      click_button 'Save changes'
53

54
      page.within('.assignee') do
Jacob Schatz's avatar
Jacob Schatz committed
55
        expect(page).to have_content 'No assignee - assign yourself'
56
57
      end

58
      expect(issue.reload.assignees).to be_empty
59
    end
60
61
  end

Phil Hughes's avatar
Phil Hughes committed
62
63
64
  describe 'due date', js: true do
    context 'on new form' do
      before do
65
        visit new_project_issue_path(project)
Phil Hughes's avatar
Phil Hughes committed
66
67
      end

68
      it 'saves with due date' do
Phil Hughes's avatar
Phil Hughes committed
69
70
71
72
        date = Date.today.at_beginning_of_month

        fill_in 'issue_title', with: 'bug 345'
        fill_in 'issue_description', with: 'bug description'
Phil Hughes's avatar
Phil Hughes committed
73
        find('#issuable-due-date').click
Phil Hughes's avatar
Phil Hughes committed
74

Phil Hughes's avatar
Phil Hughes committed
75
76
        page.within '.pika-single' do
          click_button date.day
Phil Hughes's avatar
Phil Hughes committed
77
78
        end

Phil Hughes's avatar
Phil Hughes committed
79
        expect(find('#issuable-due-date').value).to eq date.to_s
Phil Hughes's avatar
Phil Hughes committed
80
81
82
83
84
85
86
87
88
89

        click_button 'Submit issue'

        page.within '.issuable-sidebar' do
          expect(page).to have_content date.to_s(:medium)
        end
      end
    end

    context 'on edit form' do
90
      let(:issue) { create(:issue, author: user, project: project, due_date: Date.today.at_beginning_of_month.to_s) }
Phil Hughes's avatar
Phil Hughes committed
91
92

      before do
93
        visit edit_project_issue_path(project, issue)
Phil Hughes's avatar
Phil Hughes committed
94
95
      end

96
      it 'saves with due date' do
Phil Hughes's avatar
Phil Hughes committed
97
98
        date = Date.today.at_beginning_of_month

Phil Hughes's avatar
Phil Hughes committed
99
        expect(find('#issuable-due-date').value).to eq date.to_s
Phil Hughes's avatar
Phil Hughes committed
100
101
102
103
104

        date = date.tomorrow

        fill_in 'issue_title', with: 'bug 345'
        fill_in 'issue_description', with: 'bug description'
Phil Hughes's avatar
Phil Hughes committed
105
        find('#issuable-due-date').click
Phil Hughes's avatar
Phil Hughes committed
106

Phil Hughes's avatar
Phil Hughes committed
107
108
        page.within '.pika-single' do
          click_button date.day
Phil Hughes's avatar
Phil Hughes committed
109
110
        end

Phil Hughes's avatar
Phil Hughes committed
111
        expect(find('#issuable-due-date').value).to eq date.to_s
Phil Hughes's avatar
Phil Hughes committed
112
113
114
115
116
117
118

        click_button 'Save changes'

        page.within '.issuable-sidebar' do
          expect(page).to have_content date.to_s(:medium)
        end
      end
119
120
121
122
123
124
125
126
127
128
129

      it 'warns about version conflict' do
        issue.update(title: "New title")

        fill_in 'issue_title', with: 'bug 345'
        fill_in 'issue_description', with: 'bug description'

        click_button 'Save changes'

        expect(page).to have_content 'Someone edited the issue the same time you did'
      end
Phil Hughes's avatar
Phil Hughes committed
130
131
132
    end
  end

133
  describe 'Issue info' do
134
135
136
137
138
139
140
141
    it 'links to current issue in breadcrubs' do
      issue = create(:issue, project: project)

      visit project_issue_path(project, issue)

      expect(find('.breadcrumbs-sub-title a')[:href]).to end_with(issue_path(issue))
    end

142
    it 'excludes award_emoji from comment count' do
143
      issue = create(:issue, author: user, assignees: [user], project: project, title: 'foobar')
144
      create(:award_emoji, awardable: issue)
145

146
      visit project_issues_path(project, assignee_id: user.id)
147
148

      expect(page).to have_content 'foobar'
Luke Bennett's avatar
Luke Bennett committed
149
      expect(page.all('.no-comments').first.text).to eq "0"
150
151
152
    end
  end

Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
153
  describe 'Filter issue' do
154
    before do
Douwe Maan's avatar
Douwe Maan committed
155
      %w(foobar barbaz gitlab).each do |title|
156
        create(:issue,
157
158
               author: user,
               assignees: [user],
159
160
161
162
               project: project,
               title: title)
      end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
163
      @issue = Issue.find_by(title: 'foobar')
164
      @issue.milestone = create(:milestone, project: project)
165
      @issue.assignees = []
166
167
168
169
170
      @issue.save
    end

    let(:issue) { @issue }

171
    it 'allows filtering by issues with no specified assignee' do
172
      visit project_issues_path(project, assignee_id: IssuableFinder::NONE)
173

174
175
176
      expect(page).to have_content 'foobar'
      expect(page).not_to have_content 'barbaz'
      expect(page).not_to have_content 'gitlab'
177
178
    end

179
    it 'allows filtering by a specified assignee' do
180
      visit project_issues_path(project, assignee_id: user.id)
181

182
183
184
      expect(page).not_to have_content 'foobar'
      expect(page).to have_content 'barbaz'
      expect(page).to have_content 'gitlab'
185
186
    end
  end
187
188

  describe 'filter issue' do
Rémy Coutable's avatar
Rémy Coutable committed
189
    titles = %w[foo bar baz]
190
    titles.each_with_index do |title, index|
Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
191
192
193
194
195
      let!(title.to_sym) do
        create(:issue, title: title,
                       project: project,
                       created_at: Time.now - (index * 60))
      end
196
    end
197
198
    let(:newer_due_milestone) { create(:milestone, due_date: '2013-12-11') }
    let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') }
199
200

    it 'sorts by newest' do
201
      visit project_issues_path(project, sort: sort_value_created_date)
202

203
204
      expect(first_issue).to include('foo')
      expect(last_issue).to include('baz')
205
206
207
208
209
    end

    it 'sorts by most recently updated' do
      baz.updated_at = Time.now + 100
      baz.save
210
      visit project_issues_path(project, sort: sort_value_recently_updated)
211

Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
212
      expect(first_issue).to include('baz')
213
214
    end

215
    describe 'sorting by due date' do
216
      before do
Rémy Coutable's avatar
Rémy Coutable committed
217
218
        foo.update(due_date: 1.day.from_now)
        bar.update(due_date: 6.days.from_now)
219
220
      end

221
222
      it 'sorts by due date' do
        visit project_issues_path(project, sort: sort_value_due_date)
Rémy Coutable's avatar
Rémy Coutable committed
223

224
225
226
        expect(first_issue).to include('foo')
      end

227
      it 'sorts by due date by excluding nil due dates' do
228
        bar.update(due_date: nil)
Rémy Coutable's avatar
Rémy Coutable committed
229

230
        visit project_issues_path(project, sort: sort_value_due_date)
Rémy Coutable's avatar
Rémy Coutable committed
231

232
233
        expect(first_issue).to include('foo')
      end
234
235
236

      context 'with a filter on labels' do
        let(:label) { create(:label, project: project) }
237
238
239
240

        before do
          create(:label_link, label: label, target: foo)
        end
241
242
243
244

        it 'sorts by least recently due date by excluding nil due dates' do
          bar.update(due_date: nil)

245
          visit project_issues_path(project, label_names: [label.name], sort: sort_value_due_date_later)
246
247
248
249

          expect(first_issue).to include('foo')
        end
      end
250
251
252
    end

    describe 'filtering by due date' do
Rémy Coutable's avatar
Rémy Coutable committed
253
254
255
      before do
        foo.update(due_date: 1.day.from_now)
        bar.update(due_date: 6.days.from_now)
256
257
258
      end

      it 'filters by none' do
259
        visit project_issues_path(project, due_date: Issue::NoDueDate.name)
Rémy Coutable's avatar
Rémy Coutable committed
260

Phil Hughes's avatar
Phil Hughes committed
261
262
263
264
265
        page.within '.issues-holder' do
          expect(page).not_to have_content('foo')
          expect(page).not_to have_content('bar')
          expect(page).to have_content('baz')
        end
266
267
268
      end

      it 'filters by any' do
269
        visit project_issues_path(project, due_date: Issue::AnyDueDate.name)
Rémy Coutable's avatar
Rémy Coutable committed
270

Phil Hughes's avatar
Phil Hughes committed
271
272
273
274
275
        page.within '.issues-holder' do
          expect(page).to have_content('foo')
          expect(page).to have_content('bar')
          expect(page).to have_content('baz')
        end
276
277
      end

278
279
280
281
      it 'filters by due this week' do
        foo.update(due_date: Date.today.beginning_of_week + 2.days)
        bar.update(due_date: Date.today.end_of_week)
        baz.update(due_date: Date.today - 8.days)
Rémy Coutable's avatar
Rémy Coutable committed
282

283
        visit project_issues_path(project, due_date: Issue::DueThisWeek.name)
Rémy Coutable's avatar
Rémy Coutable committed
284

Phil Hughes's avatar
Phil Hughes committed
285
286
287
288
289
        page.within '.issues-holder' do
          expect(page).to have_content('foo')
          expect(page).to have_content('bar')
          expect(page).not_to have_content('baz')
        end
290
291
      end

292
293
294
295
      it 'filters by due this month' do
        foo.update(due_date: Date.today.beginning_of_month + 2.days)
        bar.update(due_date: Date.today.end_of_month)
        baz.update(due_date: Date.today - 50.days)
Rémy Coutable's avatar
Rémy Coutable committed
296

297
        visit project_issues_path(project, due_date: Issue::DueThisMonth.name)
Rémy Coutable's avatar
Rémy Coutable committed
298

Phil Hughes's avatar
Phil Hughes committed
299
300
301
302
303
        page.within '.issues-holder' do
          expect(page).to have_content('foo')
          expect(page).to have_content('bar')
          expect(page).not_to have_content('baz')
        end
304
305
      end

306
307
308
309
      it 'filters by overdue' do
        foo.update(due_date: Date.today + 2.days)
        bar.update(due_date: Date.today + 20.days)
        baz.update(due_date: Date.yesterday)
Rémy Coutable's avatar
Rémy Coutable committed
310

311
        visit project_issues_path(project, due_date: Issue::Overdue.name)
Rémy Coutable's avatar
Rémy Coutable committed
312

Phil Hughes's avatar
Phil Hughes committed
313
314
315
316
317
        page.within '.issues-holder' do
          expect(page).not_to have_content('foo')
          expect(page).not_to have_content('bar')
          expect(page).to have_content('baz')
        end
318
      end
319
320
    end

321
    describe 'sorting by milestone' do
Rémy Coutable's avatar
Rémy Coutable committed
322
      before do
323
324
325
326
327
328
        foo.milestone = newer_due_milestone
        foo.save
        bar.milestone = later_due_milestone
        bar.save
      end

329
330
      it 'sorts by milestone' do
        visit project_issues_path(project, sort: sort_value_milestone)
331

Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
332
        expect(first_issue).to include('foo')
333
        expect(last_issue).to include('baz')
334
335
336
337
338
339
      end
    end

    describe 'combine filter and sort' do
      let(:user2) { create(:user) }

Rémy Coutable's avatar
Rémy Coutable committed
340
      before do
341
        foo.assignees << user2
342
        foo.save
343
        bar.assignees << user2
344
345
346
347
        bar.save
      end

      it 'sorts with a filter applied' do
348
        visit project_issues_path(project, sort: sort_value_created_date, assignee_id: user2.id)
349

350
351
352
        expect(first_issue).to include('foo')
        expect(last_issue).to include('bar')
        expect(page).not_to have_content('baz')
353
354
355
      end
    end
  end
356

357
  describe 'when I want to reset my incoming email token' do
358
    let(:project1) { create(:project, namespace: user.namespace) }
359
    let!(:issue) { create(:issue, project: project1) }
360
361

    before do
362
      stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab")
363
364
      project1.team << [user, :master]
      visit namespace_project_issues_path(user.namespace, project1)
365
366
367
368
369
    end

    it 'changes incoming email address token', js: true do
      find('.issue-email-modal-btn').click
      previous_token = find('input#issue_email').value
Felipe Artur's avatar
Felipe Artur committed
370
371
      find('.incoming-email-token-reset').trigger('click')

372
      wait_for_requests
373

374
      expect(page).to have_no_field('issue_email', with: previous_token)
375
      new_token = project1.new_issue_address(user.reload)
376
377
378
379
      expect(page).to have_field(
        'issue_email',
        with: new_token
      )
380
381
382
    end
  end

383
  describe 'update labels from issue#show', js: true do
384
    let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
385
386
387
    let!(:label) { create(:label, project: project) }

    before do
388
      visit project_issue_path(project, issue)
389
390
391
392
393
    end

    it 'will not send ajax request when no data is changed' do
      page.within '.labels' do
        click_link 'Edit'
Nur Rony's avatar
Nur Rony committed
394
395

        find('.dropdown-menu-close', match: :first).click
396
397
398
399
400
401

        expect(page).not_to have_selector('.block-loading')
      end
    end
  end

402
  describe 'update assignee from issue#show' do
403
    let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
404

405
    context 'by authorized user' do
Jacob Schatz's avatar
Jacob Schatz committed
406
      it 'allows user to select unassigned', js: true do
407
        visit project_issue_path(project, issue)
408

Jacob Schatz's avatar
Jacob Schatz committed
409
        page.within('.assignee') do
410
          expect(page).to have_content "#{user.name}"
411

Phil Hughes's avatar
Phil Hughes committed
412
413
          click_link 'Edit'
          click_link 'Unassigned'
414
          first('.title').click
Jacob Schatz's avatar
Jacob Schatz committed
415
416
417
          expect(page).to have_content 'No assignee'
        end

418
        # wait_for_requests does not work with vue-resource at the moment
419
420
421
        sleep 1

        expect(issue.reload.assignees).to be_empty
422
      end
423
424

      it 'allows user to select an assignee', js: true do
425
        issue2 = create(:issue, project: project, author: user)
426
        visit project_issue_path(project, issue2)
427
428
429
430
431
432
433
434

        page.within('.assignee') do
          expect(page).to have_content "No assignee"
        end

        page.within '.assignee' do
          click_link 'Edit'
        end
Phil Hughes's avatar
Phil Hughes committed
435

436
        page.within '.dropdown-menu-user' do
437
          click_link user.name
438
439
440
        end

        page.within('.assignee') do
441
          expect(page).to have_content user.name
442
443
        end
      end
444
445

      it 'allows user to unselect themselves', js: true do
446
        issue2 = create(:issue, project: project, author: user)
447
        visit project_issue_path(project, issue2)
448
449
450

        page.within '.assignee' do
          click_link 'Edit'
451
          click_link user.name
452

453
          page.within '.value .author' do
454
            expect(page).to have_content user.name
455
456
457
          end

          click_link 'Edit'
458
          click_link user.name
459

460
          page.within '.value .assign-yourself' do
461
462
463
464
            expect(page).to have_content "No assignee"
          end
        end
      end
465
466
467
468
    end

    context 'by unauthorized user' do
      let(:guest) { create(:user) }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
469

Rémy Coutable's avatar
Rémy Coutable committed
470
      before do
471
472
473
        project.team << [[guest], :guest]
      end

Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
474
      it 'shows assignee text', js: true do
475
476
        sign_out(:user)
        sign_in(guest)
477

478
        visit project_issue_path(project, issue)
479
        expect(page).to have_content issue.assignees.first.name
480
481
482
483
484
      end
    end
  end

  describe 'update milestone from issue#show' do
485
    let!(:issue) { create(:issue, project: project, author: user) }
486
487
488
    let!(:milestone) { create(:milestone, project: project) }

    context 'by authorized user' do
Jacob Schatz's avatar
Jacob Schatz committed
489
      it 'allows user to select unassigned', js: true do
490
        visit project_issue_path(project, issue)
491

492
        page.within('.milestone') do
Jacob Schatz's avatar
Jacob Schatz committed
493
          expect(page).to have_content "None"
494
495
        end

Jacob Schatz's avatar
Jacob Schatz committed
496
497
498
499
500
501
502
503
504
        find('.block.milestone .edit-link').click
        sleep 2 # wait for ajax stuff to complete
        first('.dropdown-content li').click
        sleep 2
        page.within('.milestone') do
          expect(page).to have_content 'None'
        end

        expect(issue.reload.milestone).to be_nil
505
      end
506
507

      it 'allows user to de-select milestone', js: true do
508
        visit project_issue_path(project, issue)
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525

        page.within('.milestone') do
          click_link 'Edit'
          click_link milestone.title

          page.within '.value' do
            expect(page).to have_content milestone.title
          end

          click_link 'Edit'
          click_link milestone.title

          page.within '.value' do
            expect(page).to have_content 'None'
          end
        end
      end
526
527
528
529
    end

    context 'by unauthorized user' do
      let(:guest) { create(:user) }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
530

Rémy Coutable's avatar
Rémy Coutable committed
531
      before do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
532
        project.team << [guest, :guest]
533
534
535
536
        issue.milestone = milestone
        issue.save
      end

Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
537
      it 'shows milestone text', js: true do
538
539
        sign_out(:user)
        sign_in(guest)
540

541
        visit project_issue_path(project, issue)
542
        expect(page).to have_content milestone.title
543
544
545
546
      end
    end
  end

547
  describe 'new issue' do
548
549
    let!(:issue) { create(:issue, project: project) }

550
551
    context 'by unauthenticated user' do
      before do
552
        sign_out(:user)
553
554
555
      end

      it 'redirects to signin then back to new issue after signin' do
556
        visit project_issues_path(project)
557

Phil Hughes's avatar
Phil Hughes committed
558
        page.within '.nav-controls' do
Phil Hughes's avatar
Phil Hughes committed
559
560
          click_link 'New issue'
        end
561
562
563

        expect(current_path).to eq new_user_session_path

564
        gitlab_sign_in(create(:user))
565

566
        expect(current_path).to eq new_project_issue_path(project)
567
568
569
      end
    end

570
571
    context 'dropzone upload file', js: true do
      before do
572
        visit new_project_issue_path(project)
573
574
      end

575
      it 'uploads file when dragging into textarea' do
576
        dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
577
578
579

        expect(page.find_field("issue_description").value).to have_content 'banana_sample'
      end
580

581
      it "doesn't add double newline to end of a single attachment markdown" do
582
        dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
583

584
        expect(page.find_field("issue_description").value).not_to match /\n\n$/
585
      end
586
    end
587
588

    context 'form filled by URL parameters' do
589
590
      let(:project) { create(:project, :public, :repository) }

591
      before do
592
        project.repository.create_file(
593
          user,
594
595
596
597
598
          '.gitlab/issue_templates/bug.md',
          'this is a test "bug" template',
          message: 'added issue template',
          branch_name: 'master')

599
        visit new_project_issue_path(project, issuable_template: 'bug')
600
601
602
603
604
605
      end

      it 'fills in template' do
        expect(find('.js-issuable-selector .dropdown-toggle-text')).to have_content('bug')
      end
    end
606
607
  end

608
  describe 'new issue by email' do
609
    shared_examples 'show the email in the modal' do
610
611
      let(:issue) { create(:issue, project: project) }

612
      before do
613
        project.issues << issue
614
615
        stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab")

616
        visit project_issues_path(project)
617
618
619
        click_button('Email a new issue')
      end

620
      it 'click the button to show modal for the new email' do
621
        page.within '#issue-email-modal' do
622
          email = project.new_issue_address(user)
623
624
625
626
627

          expect(page).to have_selector("input[value='#{email}']")
        end
      end
    end
628
629

    context 'with existing issues' do
630
      let!(:issue) { create(:issue, project: project, author: user) }
631
632
633
634
635
636
637

      it_behaves_like 'show the email in the modal'
    end

    context 'without existing issues' do
      it_behaves_like 'show the email in the modal'
    end
638
639
  end

Phil Hughes's avatar
Phil Hughes committed
640
641
  describe 'due date' do
    context 'update due on issue#show', js: true do
642
      let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
Phil Hughes's avatar
Phil Hughes committed
643
644

      before do
645
        visit project_issue_path(project, issue)
Phil Hughes's avatar
Phil Hughes committed
646
647
      end

648
      it 'adds due date to issue' do
Mike Greiling's avatar
Mike Greiling committed
649
650
        date = Date.today.at_beginning_of_month + 2.days

Phil Hughes's avatar
Phil Hughes committed
651
652
653
        page.within '.due_date' do
          click_link 'Edit'

Phil Hughes's avatar
Phil Hughes committed
654
655
          page.within '.pika-single' do
            click_button date.day
Phil Hughes's avatar
Phil Hughes committed
656
657
          end

658
          wait_for_requests
659

Mike Greiling's avatar
Mike Greiling committed
660
          expect(find('.value').text).to have_content date.strftime('%b %-d, %Y')
Phil Hughes's avatar
Phil Hughes committed
661
662
663
        end
      end

664
      it 'removes due date from issue' do
Phil Hughes's avatar
Phil Hughes committed
665
        date = Date.today.at_beginning_of_month + 2.days
Felipe Artur's avatar
Felipe Artur committed
666

Phil Hughes's avatar
Phil Hughes committed
667
        page.within '.due_date' do
Phil Hughes's avatar
Phil Hughes committed
668
          click_link 'Edit'
Phil Hughes's avatar
Phil Hughes committed
669

Phil Hughes's avatar
Phil Hughes committed
670
671
          page.within '.pika-single' do
            click_button date.day
Phil Hughes's avatar
Phil Hughes committed
672
673
          end

674
          wait_for_requests
675

Phil Hughes's avatar
Phil Hughes committed
676
          expect(page).to have_no_content 'No due date'
Phil Hughes's avatar
Phil Hughes committed
677
678

          click_link 'remove due date'
Phil Hughes's avatar
Phil Hughes committed
679
          expect(page).to have_content 'No due date'
Phil Hughes's avatar
Phil Hughes committed
680
681
682
683
        end
      end
    end
  end
Regis Boudinot's avatar
Regis Boudinot committed
684
685
686

  describe 'title issue#show', js: true do
    it 'updates the title', js: true do
687
      issue = create(:issue, author: user, assignees: [user], project: project, title: 'new title')
Regis Boudinot's avatar
Regis Boudinot committed
688

689
      visit project_issue_path(project, issue)
Regis Boudinot's avatar
Regis Boudinot committed
690
691
692
693
694

      expect(page).to have_text("new title")

      issue.update(title: "updated title")

695
      wait_for_requests
Regis Boudinot's avatar
Regis Boudinot committed
696
697
698
      expect(page).to have_text("updated title")
    end
  end
699
700

  describe 'confidential issue#show', js: true do
701
    it 'shows confidential sibebar information as confidential and can be turned off' do
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
      issue = create(:issue, :confidential, project: project)

      visit project_issue_path(project, issue)

      expect(page).to have_css('.confidential-issue-warning')
      expect(page).to have_css('.is-confidential')
      expect(page).not_to have_css('.is-not-confidential')

      find('.confidential-edit').click
      expect(page).to have_css('.confidential-warning-message')

      within('.confidential-warning-message') do
        find('.btn-close').click
      end

      wait_for_requests

      visit project_issue_path(project, issue)

      expect(page).not_to have_css('.is-confidential')
    end
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
724
end