BigW Consortium Gitlab

search.rb 2.72 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
class Spinach::Features::Search < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedPaths
  include SharedProject

  step 'I search for "Sho"' do
    fill_in "dashboard_search", with: "Sho"
    click_button "Search"
  end

  step 'I search for "Foo"' do
    fill_in "dashboard_search", with: "Foo"
    click_button "Search"
  end

  step 'I search for "rspec"' do
    fill_in "dashboard_search", with: "rspec"
    click_button "Search"
  end

21 22 23 24 25
  step 'I search for "Wiki content"' do
    fill_in "dashboard_search", with: "content"
    click_button "Search"
  end

26
  step 'I click "Issues" link' do
27
    page.within '.search-filter' do
28 29 30 31 32
      click_link 'Issues'
    end
  end

  step 'I click project "Shop" link' do
33
    page.within '.project-filter' do
34 35 36 37 38
      click_link project.name_with_namespace
    end
  end

  step 'I click "Merge requests" link' do
39
    page.within '.search-filter' do
40 41 42 43
      click_link 'Merge requests'
    end
  end

44 45 46 47 48 49
  step 'I click "Milestones" link' do
    page.within '.search-filter' do
      click_link 'Milestones'
    end
  end

50
  step 'I click "Wiki" link' do
51
    page.within '.search-filter' do
52 53 54 55
      click_link 'Wiki'
    end
  end

56
  step 'I should see "Shop" project link' do
57
    expect(page).to have_link "Shop"
58 59 60
  end

  step 'I should see code results for project "Shop"' do
Robert Speicher committed
61 62 63
    page.within('.results') do
      page.should have_content 'Update capybara, rspec-rails, poltergeist to recent versions'
    end
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
  end

  step 'I search for "Contibuting"' do
    fill_in "dashboard_search", with: "Contibuting"
    click_button "Search"
  end

  step 'project has issues' do
    create(:issue, title: "Foo", project: project)
    create(:issue, title: "Bar", project: project)
  end

  step 'project has merge requests' do
    create(:merge_request, title: "Foo", source_project: project, target_project: project)
    create(:merge_request, :simple, title: "Bar", source_project: project, target_project: project)
  end

81 82 83 84 85
  step 'project has milestones' do
    create(:milestone, title: "Foo", project: project)
    create(:milestone, title: "Bar", project: project)
  end

86
  step 'I should see "Foo" link in the search results' do
Robert Speicher committed
87 88 89
    page.within('.results') do
      find(:css, '.search-results').should have_link 'Foo'
    end
90 91
  end

92
  step 'I should not see "Bar" link in the search results' do
93
    expect(find(:css, '.search-results')).not_to have_link 'Bar'
94
  end
95 96

  step 'I should see "test_wiki" link in the search results' do
Robert Speicher committed
97 98 99
    page.within('.results') do
      find(:css, '.search-results').should have_link 'test_wiki.md'
    end
100 101 102 103 104 105
  end

  step 'project has Wiki content' do
    @wiki = ::ProjectWiki.new(project, current_user)
    @wiki.create_page("test_wiki", "Some Wiki content", :markdown, "first commit")
  end
106
end