summaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-09 10:31:21 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-09 10:31:21 +0300
commit9e4a40982e25b31c0654b295fdf16d9aab2013f5 (patch)
tree9762e29c430952db283b577e001ea6d8f490d371 /features
parent002ce69e8fb1b1767967017175c7cfe66ec9d0ae (diff)
parent4561a09c69b9769ebdbbf7cb9a3ed8f8cc03651b (diff)
downloadgitlab-ce-9e4a40982e25b31c0654b295fdf16d9aab2013f5.tar.gz
Merge pull request #7646 from bushong1/snippet-search3
Adding in snippet search functionality
Diffstat (limited to 'features')
-rw-r--r--features/snippet_search.feature20
-rw-r--r--features/steps/shared/search.rb11
-rw-r--r--features/steps/shared/snippet.rb23
-rw-r--r--features/steps/snippet_search.rb56
4 files changed, 110 insertions, 0 deletions
diff --git a/features/snippet_search.feature b/features/snippet_search.feature
new file mode 100644
index 00000000000..834bd3b2376
--- /dev/null
+++ b/features/snippet_search.feature
@@ -0,0 +1,20 @@
+@dashboard
+Feature: Snippet Search
+ Background:
+ Given I sign in as a user
+ And I have public "Personal snippet one" snippet
+ And I have private "Personal snippet private" snippet
+ And I have a public many lined snippet
+
+ Scenario: I should see my public and private snippets
+ When I search for "snippet" in snippet titles
+ Then I should see "Personal snippet one" in results
+ And I should see "Personal snippet private" in results
+
+ Scenario: I should see three surrounding lines on either side of a matching snippet line
+ When I search for "line seven" in snippet contents
+ Then I should see "line four" in results
+ And I should see "line seven" in results
+ And I should see "line ten" in results
+ And I should not see "line three" in results
+ And I should not see "line eleven" in results
diff --git a/features/steps/shared/search.rb b/features/steps/shared/search.rb
new file mode 100644
index 00000000000..6c3d601763d
--- /dev/null
+++ b/features/steps/shared/search.rb
@@ -0,0 +1,11 @@
+module SharedSearch
+ include Spinach::DSL
+
+ def search_snippet_contents(query)
+ visit "/search?search=#{URI::encode(query)}&snippets=true&scope=snippet_blobs"
+ end
+
+ def search_snippet_titles(query)
+ visit "/search?search=#{URI::encode(query)}&snippets=true&scope=snippet_titles"
+ end
+end
diff --git a/features/steps/shared/snippet.rb b/features/steps/shared/snippet.rb
index 543e43196a5..c64299ae6f3 100644
--- a/features/steps/shared/snippet.rb
+++ b/features/steps/shared/snippet.rb
@@ -18,4 +18,27 @@ module SharedSnippet
private: true,
author: current_user)
end
+ And 'I have a public many lined snippet' do
+ create(:personal_snippet,
+ title: 'Many lined snippet',
+ content: <<-END.gsub(/^\s+\|/, ''),
+ |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
+ END
+ file_name: 'many_lined_snippet.rb',
+ private: true,
+ author: current_user)
+ end
end
diff --git a/features/steps/snippet_search.rb b/features/steps/snippet_search.rb
new file mode 100644
index 00000000000..fe03b847c56
--- /dev/null
+++ b/features/steps/snippet_search.rb
@@ -0,0 +1,56 @@
+class Spinach::Features::SnippetSearch < Spinach::FeatureSteps
+ include SharedAuthentication
+ include SharedPaths
+ include SharedSnippet
+ include SharedUser
+ include SharedSearch
+
+ step 'I search for "snippet" in snippet titles' do
+ search_snippet_titles 'snippet'
+ end
+
+ step 'I search for "snippet private" in snippet titles' do
+ search_snippet_titles 'snippet private'
+ end
+
+ step 'I search for "line seven" in snippet contents' do
+ search_snippet_contents 'line seven'
+ end
+
+ step 'I should see "line seven" in results' do
+ page.should have_content 'line seven'
+ end
+
+ step 'I should see "line four" in results' do
+ page.should have_content 'line four'
+ end
+
+ step 'I should see "line ten" in results' do
+ page.should have_content 'line ten'
+ end
+
+ step 'I should not see "line eleven" in results' do
+ page.should_not have_content 'line eleven'
+ end
+
+ step 'I should not see "line three" in results' do
+ page.should_not have_content 'line three'
+ end
+
+ Then 'I should see "Personal snippet one" in results' do
+ page.should have_content 'Personal snippet one'
+ end
+
+ And 'I should see "Personal snippet private" in results' do
+ page.should have_content 'Personal snippet private'
+ end
+
+ Then 'I should not see "Personal snippet one" in results' do
+ page.should_not have_content 'Personal snippet one'
+ end
+
+ And 'I should not see "Personal snippet private" in results' do
+ page.should_not have_content 'Personal snippet private'
+ end
+
+end