summaryrefslogtreecommitdiff
path: root/spec/features
diff options
context:
space:
mode:
authorthe-undefined <joe@joejames.io>2016-11-15 07:10:43 +0000
committerthe-undefined <joe@joejames.io>2016-11-16 06:52:43 +0000
commitdbf5c8abfe44ce8bf4a9517a8acead961edb3e3e (patch)
tree039f405d4c0364a954b81a299b0e30184ee07623 /spec/features
parentf27f9803833f72d7f62534c195539dcdef2e3ccd (diff)
downloadgitlab-ce-dbf5c8abfe44ce8bf4a9517a8acead961edb3e3e.tar.gz
Move 'Search Snippets' Spinach feature to Rspec
This commit moves the `search_snippets.feature` Spinach test to a Rspec feature, as part of deprecating the Spinach test suite. - Remove Spinach discover snippets feature and steps - Remove unused `SharedSearch` module - Add Rspec feature scenarios
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/snippets/search_snippets_spec.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/features/snippets/search_snippets_spec.rb b/spec/features/snippets/search_snippets_spec.rb
new file mode 100644
index 00000000000..146cd3af848
--- /dev/null
+++ b/spec/features/snippets/search_snippets_spec.rb
@@ -0,0 +1,66 @@
+require 'rails_helper'
+
+feature 'Search Snippets', feature: true do
+ scenario 'User searches for snippets by title' do
+ public_snippet = create(:personal_snippet, :public, title: 'Beginning and Middle')
+ private_snippet = create(:personal_snippet, :private, title: 'Middle and End')
+
+ login_as private_snippet.author
+ visit dashboard_snippets_path
+
+ page.within '.search' do
+ fill_in 'search', with: 'Middle'
+ click_button 'Go'
+ end
+
+ click_link 'Titles and Filenames'
+
+ expect(page).to have_link(public_snippet.title)
+ expect(page).to have_link(private_snippet.title)
+ end
+
+ scenario 'User searches for snippet contents' do
+ create(:personal_snippet,
+ :public,
+ title: 'Many lined snippet',
+ content: <<-CONTENT.strip_heredoc
+ |line one
+ |line two
+ |line three
+ |line four
+ |line five
+ |line six
+ |line seven
+ |line eight
+ |line nine
+ |line ten
+ |line eleven
+ |line twelve
+ |line thirteen
+ |line fourteen
+ CONTENT
+ )
+
+ login_as create(:user)
+ visit dashboard_snippets_path
+
+ page.within '.search' do
+ fill_in 'search', with: 'line seven'
+ click_button 'Go'
+ end
+
+ expect(page).to have_content('line seven')
+
+ # 3 lines before the matched line should be visible
+ expect(page).to have_content('line six')
+ expect(page).to have_content('line five')
+ expect(page).to have_content('line four')
+ expect(page).not_to have_content('line three')
+
+ # 3 lines after the matched line should be visible
+ expect(page).to have_content('line eight')
+ expect(page).to have_content('line nine')
+ expect(page).to have_content('line ten')
+ expect(page).not_to have_content('line eleven')
+ end
+end