GitLab steht Mittwoch, den 08. Juli, zwischen 09:00 und 13:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

user_searches_for_issues_spec.rb 1.88 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
require 'spec_helper'

describe 'User searches for issues', :js do
  let(:user) { create(:user) }
  let(:project) { create(:project, namespace: user.namespace) }
  let!(:issue1) { create(:issue, title: 'Foo', project: project) }
  let!(:issue2) { create(:issue, title: 'Bar', project: project) }

  context 'when signed in' do
    before do
11
      project.add_maintainer(user)
12 13 14 15 16 17 18 19 20
      sign_in(user)

      visit(search_path)
    end

    include_examples 'top right search form'

    it 'finds an issue' do
      fill_in('dashboard_search', with: issue1.title)
21
      find('.btn-search').click
22 23 24 25 26 27 28 29 30 31 32 33

      page.within('.search-filter') do
        click_link('Issues')
      end

      page.within('.results') do
        expect(find(:css, '.search-results')).to have_link(issue1.title).and have_no_link(issue2.title)
      end
    end

    context 'when on a project page' do
      it 'finds an issue' do
34
        find('.js-search-project-dropdown').click
35 36

        page.within('.project-filter') do
37
          click_link(project.full_name)
38 39 40
        end

        fill_in('dashboard_search', with: issue1.title)
41
        find('.btn-search').click
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

        page.within('.search-filter') do
          click_link('Issues')
        end

        page.within('.results') do
          expect(find(:css, '.search-results')).to have_link(issue1.title).and have_no_link(issue2.title)
        end
      end
    end
  end

  context 'when signed out' do
    let(:project) { create(:project, :public) }

    before do
      visit(search_path)
    end

    include_examples 'top right search form'

    it 'finds an issue' do
      fill_in('dashboard_search', with: issue1.title)
65
      find('.btn-search').click
66 67 68 69 70 71 72 73 74 75 76

      page.within('.search-filter') do
        click_link('Issues')
      end

      page.within('.results') do
        expect(find(:css, '.search-results')).to have_link(issue1.title).and have_no_link(issue2.title)
      end
    end
  end
end