summaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorCharles Bushong <bushong1@gmail.com>2014-09-05 13:30:55 -0400
committerCharles Bushong <bushong1@gmail.com>2014-09-05 13:30:55 -0400
commit858dbd084253d2920d7007babe0471469eb459e7 (patch)
tree9ac2119b4b6b81af2c3a420628d8f20d06053f74 /features
parentb1411e90f81ea87ad45dee324b13881095e031ea (diff)
downloadgitlab-ce-858dbd084253d2920d7007babe0471469eb459e7.tar.gz
Updating to persist a params snippets variable
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.rb8
-rw-r--r--features/steps/snippet_search.rb56
4 files changed, 95 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..5f89a3ccf65 100644
--- a/features/steps/shared/snippet.rb
+++ b/features/steps/shared/snippet.rb
@@ -18,4 +18,12 @@ 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: "line one\nline two\nline three\nline four\nline five\nline six\nline seven\nline eight\nline nine\nline ten\nline eleven\nline twelve\nline thirteen\nline fourteen",
+ 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..eb7d56c5f3f
--- /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