issues_spec.rb 23.8 KB
Newer Older
gitlabhq's avatar
gitlabhq committed
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) }
gitlabhq's avatar
gitlabhq committed
10

Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
11 12 13 14 15 16 17
  shared_examples_for 'empty state with filters' do
    it 'user sees empty state with filters' do
      create(:issue, author: user, project: project)

      visit project_issues_path(project, milestone_title: "1.0")

      expect(page).to have_content('Sorry, your filter produced no results')
18
      expect(page).to have_content('To widen your search, change or remove filters above')
Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
19 20 21
    end
  end

22 23 24 25
  describe 'while user is signed out' do
    describe 'empty state' do
      it 'user sees empty state' do
        visit project_issues_path(project)
gitlabhq's avatar
gitlabhq committed
26

27 28 29 30
        expect(page).to have_content('Register / Sign In')
        expect(page).to have_content('The Issue Tracker is the place to add things that need to be improved or solved in a project.')
        expect(page).to have_content('You can register or sign in to create issues for this project.')
      end
31

Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
32
      it_behaves_like 'empty state with filters'
Riyad Preukschas's avatar
Riyad Preukschas committed
33
    end
34
  end
Riyad Preukschas's avatar
Riyad Preukschas committed
35

36
  describe 'while user is signed in' do
Nihad Abbasov's avatar
Nihad Abbasov committed
37
    before do
38 39
      sign_in(user)
      user2 = create(:user)
40

41 42
      project.add_developer(user)
      project.add_developer(user2)
43 44
    end

45 46 47
    describe 'empty state' do
      it 'user sees empty state' do
        visit project_issues_path(project)
48

49 50 51 52
        expect(page).to have_content('The Issue Tracker is the place to add things that need to be improved or solved in a project')
        expect(page).to have_content('Issues can be bugs, tasks or ideas to be discussed. Also, issues are searchable and filterable.')
        expect(page).to have_content('New issue')
      end
53

Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
54
      it_behaves_like 'empty state with filters'
55
    end
56

57 58 59 60 61 62 63
    describe 'Edit issue' do
      let!(:issue) do
        create(:issue,
               author: user,
               assignees: [user],
               project: project)
      end
64

65 66 67
      before do
        visit edit_project_issue_path(project, issue)
        find('.js-zen-enter').click
68 69
      end

70 71 72
      it 'opens new issue popup' do
        expect(page).to have_content("Issue ##{issue.iid}")
      end
73 74
    end

75 76 77 78 79 80
    describe 'Editing issue assignee' do
      let!(:issue) do
        create(:issue,
               author: user,
               assignees: [user],
               project: project)
81 82
      end

83 84
      it 'allows user to select unassigned', :js do
        visit edit_project_issue_path(project, issue)
85

86
        expect(page).to have_content "Assignee #{user.name}"
87

88 89
        first('.js-user-search').click
        click_link 'Unassigned'
90

91
        click_button 'Save changes'
92

93 94
        page.within('.assignee') do
          expect(page).to have_content 'No assignee - assign yourself'
95
        end
96 97

        expect(issue.reload.assignees).to be_empty
98 99 100
      end
    end

101 102 103 104 105
    describe 'due date', :js do
      context 'on new form' do
        before do
          visit new_project_issue_path(project)
        end
106

107 108
        it 'saves with due date' do
          date = Date.today.at_beginning_of_month
109

110 111 112
          fill_in 'issue_title', with: 'bug 345'
          fill_in 'issue_description', with: 'bug description'
          find('#issuable-due-date').click
113

114 115 116
          page.within '.pika-single' do
            click_button date.day
          end
117

118
          expect(find('#issuable-due-date').value).to eq date.to_s
119

120
          click_button 'Submit issue'
121

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

128 129
      context 'on edit form' do
        let(:issue) { create(:issue, author: user, project: project, due_date: Date.today.at_beginning_of_month.to_s) }
130

131 132
        before do
          visit edit_project_issue_path(project, issue)
133 134
        end

135 136
        it 'saves with due date' do
          date = Date.today.at_beginning_of_month
137

138
          expect(find('#issuable-due-date').value).to eq date.to_s
139

140
          date = date.tomorrow
141

142 143 144 145 146 147 148
          fill_in 'issue_title', with: 'bug 345'
          fill_in 'issue_description', with: 'bug description'
          find('#issuable-due-date').click

          page.within '.pika-single' do
            click_button date.day
          end
Phil Hughes's avatar
Phil Hughes committed
149

150
          expect(find('#issuable-due-date').value).to eq date.to_s
151

152
          click_button 'Save changes'
153

154 155 156 157
          page.within '.issuable-sidebar' do
            expect(page).to have_content date.to_s(:medium)
          end
        end
158

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

162 163
          fill_in 'issue_title', with: 'bug 345'
          fill_in 'issue_description', with: 'bug description'
164

165
          click_button 'Save changes'
166

167 168
          expect(page).to have_content 'Someone edited the issue the same time you did'
        end
169 170 171
      end
    end

172 173 174
    describe 'Issue info' do
      it 'links to current issue in breadcrubs' do
        issue = create(:issue, project: project)
Riyad Preukschas's avatar
Riyad Preukschas committed
175

176
        visit project_issue_path(project, issue)
177

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

181 182 183
      it 'excludes award_emoji from comment count' do
        issue = create(:issue, author: user, assignees: [user], project: project, title: 'foobar')
        create(:award_emoji, awardable: issue)
184

185
        visit project_issues_path(project, assignee_id: user.id)
186

187 188
        expect(page).to have_content 'foobar'
        expect(page.all('.no-comments').first.text).to eq "0"
189
      end
190 191
    end

192 193 194 195 196 197 198 199 200
    describe 'Filter issue' do
      before do
        %w(foobar barbaz gitlab).each do |title|
          create(:issue,
                 author: user,
                 assignees: [user],
                 project: project,
                 title: title)
        end
201

202 203 204 205 206
        @issue = Issue.find_by(title: 'foobar')
        @issue.milestone = create(:milestone, project: project)
        @issue.assignees = []
        @issue.save
      end
207

208
      let(:issue) { @issue }
209

210 211
      it 'allows filtering by issues with no specified assignee' do
        visit project_issues_path(project, assignee_id: IssuableFinder::NONE)
212

213 214 215
        expect(page).to have_content 'foobar'
        expect(page).not_to have_content 'barbaz'
        expect(page).not_to have_content 'gitlab'
216 217
      end

218 219
      it 'allows filtering by a specified assignee' do
        visit project_issues_path(project, assignee_id: user.id)
Rémy Coutable's avatar
Rémy Coutable committed
220

221 222 223
        expect(page).not_to have_content 'foobar'
        expect(page).to have_content 'barbaz'
        expect(page).to have_content 'gitlab'
224
      end
225
    end
226

227 228 229 230 231 232 233 234 235
    describe 'filter issue' do
      titles = %w[foo bar baz]
      titles.each_with_index do |title, index|
        let!(title.to_sym) do
          create(:issue, title: title,
                         project: project,
                         created_at: Time.now - (index * 60))
        end
      end
236 237
      let(:newer_due_milestone) { create(:milestone, project: project, due_date: '2013-12-11') }
      let(:later_due_milestone) { create(:milestone, project: project, due_date: '2013-12-12') }
Rémy Coutable's avatar
Rémy Coutable committed
238

239 240
      it 'sorts by newest' do
        visit project_issues_path(project, sort: sort_value_created_date)
Rémy Coutable's avatar
Rémy Coutable committed
241

242
        expect(first_issue).to include('foo')
243
        expect(last_issue).to include('baz')
244
      end
245

246 247 248 249
      it 'sorts by most recently updated' do
        baz.updated_at = Time.now + 100
        baz.save
        visit project_issues_path(project, sort: sort_value_recently_updated)
250

251 252 253 254
        expect(first_issue).to include('baz')
      end

      describe 'sorting by due date' do
255
        before do
256 257 258 259 260 261 262 263
          foo.update(due_date: 1.day.from_now)
          bar.update(due_date: 6.days.from_now)
        end

        it 'sorts by due date' do
          visit project_issues_path(project, sort: sort_value_due_date)

          expect(first_issue).to include('foo')
264
        end
265

266
        it 'sorts by due date by excluding nil due dates' do
267 268
          bar.update(due_date: nil)

269
          visit project_issues_path(project, sort: sort_value_due_date)
270 271 272

          expect(first_issue).to include('foo')
        end
273

274 275 276 277 278 279 280 281 282
        context 'with a filter on labels' do
          let(:label) { create(:label, project: project) }

          before do
            create(:label_link, label: label, target: foo)
          end

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

284
            visit project_issues_path(project, label_names: [label.name], sort: sort_value_due_date_later)
Rémy Coutable's avatar
Rémy Coutable committed
285

286 287
            expect(first_issue).to include('foo')
          end
Phil Hughes's avatar
Phil Hughes committed
288
        end
289 290
      end

291 292 293 294 295 296 297 298
      describe 'filtering by due date' do
        before do
          foo.update(due_date: 1.day.from_now)
          bar.update(due_date: 6.days.from_now)
        end

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

300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
          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
        end

        it 'filters by any' do
          visit project_issues_path(project, due_date: Issue::AnyDueDate.name)

          page.within '.issues-holder' do
            expect(page).to have_content('foo')
            expect(page).to have_content('bar')
            expect(page).to have_content('baz')
          end
Phil Hughes's avatar
Phil Hughes committed
315
        end
316

317 318 319 320
        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
321

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

324 325 326 327 328
          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
Phil Hughes's avatar
Phil Hughes committed
329
        end
330

331 332 333 334
        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
335

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

338 339 340 341 342
          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
Phil Hughes's avatar
Phil Hughes committed
343
        end
344

345 346 347 348
        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)
349

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

352 353 354 355 356
          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
Phil Hughes's avatar
Phil Hughes committed
357
        end
358 359 360 361 362 363 364 365 366 367 368 369 370 371

        it 'filters by due next month and previous two weeks' do
          foo.update(due_date: Date.today - 4.weeks)
          bar.update(due_date: (Date.today + 2.months).beginning_of_month)
          baz.update(due_date: Date.yesterday)

          visit project_issues_path(project, due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name)

          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
        end
Rémy Coutable's avatar
Rémy Coutable committed
372
      end
373

374 375 376 377 378 379 380
      describe 'sorting by milestone' do
        before do
          foo.milestone = newer_due_milestone
          foo.save
          bar.milestone = later_due_milestone
          bar.save
        end
381

382 383
        it 'sorts by milestone' do
          visit project_issues_path(project, sort: sort_value_milestone)
384

385 386 387
          expect(first_issue).to include('foo')
          expect(last_issue).to include('baz')
        end
388 389
      end

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

393 394 395 396 397 398
        before do
          foo.assignees << user2
          foo.save
          bar.assignees << user2
          bar.save
        end
399

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

403 404 405 406
          expect(first_issue).to include('foo')
          expect(last_issue).to include('bar')
          expect(page).not_to have_content('baz')
        end
407 408
      end
    end
409

410 411 412
    describe 'when I want to reset my incoming email token' do
      let(:project1) { create(:project, namespace: user.namespace) }
      let!(:issue) { create(:issue, project: project1) }
413

414 415
      before do
        stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab")
416
        project1.add_maintainer(user)
417 418
        visit namespace_project_issues_path(user.namespace, project1)
      end
419

420 421 422 423
      it 'changes incoming email address token', :js do
        find('.issuable-email-modal-btn').click
        previous_token = find('input#issuable_email').value
        find('.incoming-email-token-reset').click
424

425
        wait_for_requests
426

427 428 429 430 431 432 433
        expect(page).to have_no_field('issuable_email', with: previous_token)
        new_token = project1.new_issuable_address(user.reload, 'issue')
        expect(page).to have_field(
          'issuable_email',
          with: new_token
        )
      end
434 435
    end

436 437 438
    describe 'update labels from issue#show', :js do
      let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
      let!(:label) { create(:label, project: project) }
439

440 441 442
      before do
        visit project_issue_path(project, issue)
      end
443

444 445 446
      it 'will not send ajax request when no data is changed' do
        page.within '.labels' do
          click_link 'Edit'
447

448
          find('.dropdown-menu-close', match: :first).click
449

450 451
          expect(page).not_to have_selector('.block-loading')
        end
452 453 454
      end
    end

455 456
    describe 'update assignee from issue#show' do
      let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
457

458 459 460
      context 'by authorized user' do
        it 'allows user to select unassigned', :js do
          visit project_issue_path(project, issue)
461

462 463
          page.within('.assignee') do
            expect(page).to have_content "#{user.name}"
464

465 466 467 468 469
            click_link 'Edit'
            click_link 'Unassigned'
            first('.title').click
            expect(page).to have_content 'No assignee'
          end
470

471 472
          # wait_for_requests does not work with vue-resource at the moment
          sleep 1
473

474 475
          expect(issue.reload.assignees).to be_empty
        end
476

477 478 479
        it 'allows user to select an assignee', :js do
          issue2 = create(:issue, project: project, author: user)
          visit project_issue_path(project, issue2)
480

481 482 483
          page.within('.assignee') do
            expect(page).to have_content "No assignee"
          end
484

485 486 487
          page.within '.assignee' do
            click_link 'Edit'
          end
Phil Hughes's avatar
Phil Hughes committed
488

489 490 491
          page.within '.dropdown-menu-user' do
            click_link user.name
          end
492

493 494 495
          page.within('.assignee') do
            expect(page).to have_content user.name
          end
496
        end
497

498 499 500
        it 'allows user to unselect themselves', :js do
          issue2 = create(:issue, project: project, author: user)
          visit project_issue_path(project, issue2)
501

502 503 504
          page.within '.assignee' do
            click_link 'Edit'
            click_link user.name
505

506 507 508
            page.within '.value .author' do
              expect(page).to have_content user.name
            end
509

510 511
            click_link 'Edit'
            click_link user.name
512

513 514 515
            page.within '.value .assign-yourself' do
              expect(page).to have_content "No assignee"
            end
516 517 518
          end
        end
      end
519

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

523
        before do
524
          project.add_guest(guest)
525
        end
526

527 528 529
        it 'shows assignee text', :js do
          sign_out(:user)
          sign_in(guest)
530

531 532 533
          visit project_issue_path(project, issue)
          expect(page).to have_content issue.assignees.first.name
        end
534 535 536
      end
    end

537 538 539
    describe 'update milestone from issue#show' do
      let!(:issue) { create(:issue, project: project, author: user) }
      let!(:milestone) { create(:milestone, project: project) }
540

541 542 543
      context 'by authorized user' do
        it 'allows user to select unassigned', :js do
          visit project_issue_path(project, issue)
544

545 546 547
          page.within('.milestone') do
            expect(page).to have_content "None"
          end
548

549 550 551 552 553 554 555 556 557
          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
558 559
        end

560 561
        it 'allows user to de-select milestone', :js do
          visit project_issue_path(project, issue)
562

563 564 565
          page.within('.milestone') do
            click_link 'Edit'
            click_link milestone.title
566

567 568 569
            page.within '.value' do
              expect(page).to have_content milestone.title
            end
570

571 572
            click_link 'Edit'
            click_link milestone.title
573

574 575 576
            page.within '.value' do
              expect(page).to have_content 'None'
            end
577 578 579
          end
        end
      end
580

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

584
        before do
585
          project.add_guest(guest)
586 587 588
          issue.milestone = milestone
          issue.save
        end
589

590 591 592
        it 'shows milestone text', :js do
          sign_out(:user)
          sign_in(guest)
593

594 595 596
          visit project_issue_path(project, issue)
          expect(page).to have_content milestone.title
        end
597 598 599
      end
    end

600 601
    describe 'new issue' do
      let!(:issue) { create(:issue, project: project) }
602

603 604 605 606
      context 'by unauthenticated user' do
        before do
          sign_out(:user)
        end
607

608 609
        it 'redirects to signin then back to new issue after signin' do
          visit project_issues_path(project)
610

611 612 613
          page.within '.nav-controls' do
            click_link 'New issue'
          end
614

615
          expect(current_path).to eq new_user_session_path
616

617
          gitlab_sign_in(create(:user))
618

619 620
          expect(current_path).to eq new_project_issue_path(project)
        end
621 622
      end

623
      it 'clears local storage after creating a new issue', :js do
624
        2.times do
625 626 627 628 629 630 631 632 633 634 635 636
          visit new_project_issue_path(project)
          wait_for_requests

          expect(page).to have_field('Title', with: '')

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

          click_button 'Submit issue'
        end
      end

637 638 639 640
      context 'dropzone upload file', :js do
        before do
          visit new_project_issue_path(project)
        end
641

642 643
        it 'uploads file when dragging into textarea' do
          dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
644

645 646
          expect(page.find_field("issue_description").value).to have_content 'banana_sample'
        end
647

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

651 652
          expect(page.find_field("issue_description").value).not_to match /\n\n$/
        end
653

654 655 656
        it "cancels a file upload correctly" do
          slow_requests do
            dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')], 0, false)
657

658 659
            click_button 'Cancel'
          end
660

661 662 663 664
          expect(page).to have_button('Attach a file')
          expect(page).not_to have_button('Cancel')
          expect(page).not_to have_selector('.uploading-progress-container', visible: true)
        end
665
      end
666

667 668
      context 'form filled by URL parameters' do
        let(:project) { create(:project, :public, :repository) }
669

670 671 672 673 674 675 676 677 678 679
        before do
          project.repository.create_file(
            user,
            '.gitlab/issue_templates/bug.md',
            'this is a test "bug" template',
            message: 'added issue template',
            branch_name: 'master')

          visit new_project_issue_path(project, issuable_template: 'bug')
        end
680

681 682 683
        it 'fills in template' do
          expect(find('.js-issuable-selector .dropdown-toggle-text')).to have_content('bug')
        end
684
      end
685 686 687 688 689 690 691 692 693 694 695 696

      context 'suggestions', :js do
        it 'displays list of related issues' do
          create(:issue, project: project, title: 'test issue')

          visit new_project_issue_path(project)

          fill_in 'issue_title', with: issue.title

          expect(page).to have_selector('.suggestion-item', count: 1)
        end
      end
697
    end
698

699 700 701
    describe 'new issue by email' do
      shared_examples 'show the email in the modal' do
        let(:issue) { create(:issue, project: project) }
702

703 704 705
        before do
          project.issues << issue
          stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab")
706

707 708 709
          visit project_issues_path(project)
          click_button('Email a new issue')
        end
710

711 712 713
        it 'click the button to show modal for the new email' do
          page.within '#issuable-email-modal' do
            email = project.new_issuable_address(user, 'issue')
714

715 716
            expect(page).to have_selector("input[value='#{email}']")
          end
717 718
        end
      end
719

720 721
      context 'with existing issues' do
        let!(:issue) { create(:issue, project: project, author: user) }
722

723 724
        it_behaves_like 'show the email in the modal'
      end
725

726 727 728
      context 'without existing issues' do
        it_behaves_like 'show the email in the modal'
      end
729
    end
730

731 732 733
    describe 'due date' do
      context 'update due on issue#show', :js do
        let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
Phil Hughes's avatar
Phil Hughes committed
734

735 736 737
        before do
          visit project_issue_path(project, issue)
        end
Phil Hughes's avatar
Phil Hughes committed
738

739 740
        it 'adds due date to issue' do
          date = Date.today.at_beginning_of_month + 2.days
Mike Greiling's avatar
Mike Greiling committed
741

742 743
          page.within '.due_date' do
            click_link 'Edit'
Phil Hughes's avatar
Phil Hughes committed
744

745 746 747
            page.within '.pika-single' do
              click_button date.day
            end
Phil Hughes's avatar
Phil Hughes committed
748

749
            wait_for_requests
750

751 752
            expect(find('.value').text).to have_content date.strftime('%b %-d, %Y')
          end
Phil Hughes's avatar
Phil Hughes committed
753 754
        end

755 756
        it 'removes due date from issue' do
          date = Date.today.at_beginning_of_month + 2.days
757

758 759
          page.within '.due_date' do
            click_link 'Edit'
Phil Hughes's avatar
Phil Hughes committed
760

761 762 763
            page.within '.pika-single' do
              click_button date.day
            end
Phil Hughes's avatar
Phil Hughes committed
764

765
            wait_for_requests
766

767
            expect(page).to have_no_content 'No due date'
Phil Hughes's avatar
Phil Hughes committed
768

769 770 771
            click_link 'remove due date'
            expect(page).to have_content 'No due date'
          end
Phil Hughes's avatar
Phil Hughes committed
772 773 774
        end
      end
    end
Regis Boudinot's avatar
Regis Boudinot committed
775

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

780
        visit project_issue_path(project, issue)
Regis Boudinot's avatar
Regis Boudinot committed
781

782
        expect(page).to have_text("new title")
Regis Boudinot's avatar
Regis Boudinot committed
783

784
        issue.update(title: "updated title")
Regis Boudinot's avatar
Regis Boudinot committed
785

786 787 788
        wait_for_requests
        expect(page).to have_text("updated title")
      end
Regis Boudinot's avatar
Regis Boudinot committed
789
    end
790

791 792 793
    describe 'confidential issue#show', :js do
      it 'shows confidential sibebar information as confidential and can be turned off' do
        issue = create(:issue, :confidential, project: project)
794

795
        visit project_issue_path(project, issue)
796

797 798 799
        expect(page).to have_css('.issuable-note-warning')
        expect(find('.issuable-sidebar-item.confidentiality')).to have_css('.is-active')
        expect(find('.issuable-sidebar-item.confidentiality')).not_to have_css('.not-active')
800

801 802
        find('.confidential-edit').click
        expect(page).to have_css('.sidebar-item-warning-message')
803

804 805 806
        within('.sidebar-item-warning-message') do
          find('.btn-close').click
        end
807

808
        wait_for_requests
809

810
        visit project_issue_path(project, issue)
811

812 813
        expect(page).not_to have_css('.is-active')
      end
814 815
    end
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
816
end