BigW Consortium Gitlab

user_searches_for_milestones_spec.rb 1.33 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
require 'spec_helper'

describe 'User searches for milestones', :js do
  let(:user) { create(:user) }
  let(:project) { create(:project, namespace: user.namespace) }
  let!(:milestone1) { create(:milestone, title: 'Foo', project: project) }
  let!(:milestone2) { create(:milestone, title: 'Bar', project: project) }

  before do
    project.add_master(user)
    sign_in(user)

    visit(search_path)
  end

  include_examples 'top right search form'

  it 'finds a milestone' do
    fill_in('dashboard_search', with: milestone1.title)
20
    find('.btn-search').click
21 22 23 24 25 26 27 28 29 30 31 32

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

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

  context 'when on a project page' do
    it 'finds a milestone' do
33
      find('.js-search-project-dropdown').click
34 35 36 37 38 39

      page.within('.project-filter') do
        click_link(project.name_with_namespace)
      end

      fill_in('dashboard_search', with: milestone1.title)
40
      find('.btn-search').click
41 42 43 44 45 46 47 48 49 50 51

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

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