Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GitLab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
projects.thm.de
GitLab
Commits
b3d79b1f
Commit
b3d79b1f
authored
Sep 16, 2017
by
Vitaliy @blackst0ne Klachkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace the 'search.feature' spinach test with an rspec analog
parent
20295b3d
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
564 additions
and
526 deletions
+564
-526
changelogs/unreleased/replace_search-feature.yml
changelogs/unreleased/replace_search-feature.yml
+5
-0
features/search.feature
features/search.feature
+0
-100
features/steps/search.rb
features/steps/search.rb
+0
-116
spec/features/search/user_searches_for_code_spec.rb
spec/features/search/user_searches_for_code_spec.rb
+67
-0
spec/features/search/user_searches_for_comments_spec.rb
spec/features/search/user_searches_for_comments_spec.rb
+47
-0
spec/features/search/user_searches_for_commits_spec.rb
spec/features/search/user_searches_for_commits_spec.rb
+49
-0
spec/features/search/user_searches_for_issues_spec.rb
spec/features/search/user_searches_for_issues_spec.rb
+76
-0
spec/features/search/user_searches_for_merge_requests_spec.rb
.../features/search/user_searches_for_merge_requests_spec.rb
+51
-0
spec/features/search/user_searches_for_milestones_spec.rb
spec/features/search/user_searches_for_milestones_spec.rb
+51
-0
spec/features/search/user_searches_for_projects_spec.rb
spec/features/search/user_searches_for_projects_spec.rb
+36
-0
spec/features/search/user_searches_for_wiki_pages_spec.rb
spec/features/search/user_searches_for_wiki_pages_spec.rb
+35
-0
spec/features/search/user_uses_header_search_field_spec.rb
spec/features/search/user_uses_header_search_field_spec.rb
+90
-0
spec/features/search/user_uses_search_filters_spec.rb
spec/features/search/user_uses_search_filters_spec.rb
+52
-0
spec/features/search_spec.rb
spec/features/search_spec.rb
+0
-310
spec/support/shared_examples/features/search_shared_examples.rb
...upport/shared_examples/features/search_shared_examples.rb
+5
-0
No files found.
changelogs/unreleased/replace_search-feature.yml
0 → 100644
View file @
b3d79b1f
---
title
:
Replace the 'search.feature' spinach test with an rspec analog
merge_request
:
14248
author
:
Vitaliy @blackst0ne Klachkov
type
:
other
features/search.feature
deleted
100644 → 0
View file @
20295b3d
@dashboard
Feature
:
Search
Background
:
Given
I sign in as a user
And
I own project
"Shop"
And
I visit dashboard search page
Scenario
:
I
should see project I am looking for
Given
I search for
"Sho"
Then
I should see
"Shop"
project link
@javascript
Scenario
:
I
should see issues I am looking for
And
project has issues
When
I search for
"Foo"
And
I click
"Issues"
link
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
@javascript
Scenario
:
I
should see merge requests I am looking for
And
project has merge requests
When
I search for
"Foo"
When
I click
"Merge requests"
link
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
@javascript
Scenario
:
I
should see milestones I am looking for
And
project has milestones
When
I search for
"Foo"
When
I click
"Milestones"
link
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
@javascript
Scenario
:
I
should see project code I am looking for
When
I click project
"Shop"
link
And
I search for
"rspec"
Then
I should see code results for project
"Shop"
@javascript
Scenario
:
I
should see project issues
And
project has issues
When
I click project
"Shop"
link
And
I search for
"Foo"
And
I click
"Issues"
link
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
@javascript
Scenario
:
I
should see project merge requests
And
project has merge requests
When
I click project
"Shop"
link
And
I search for
"Foo"
And
I click
"Merge requests"
link
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
@javascript
Scenario
:
I
should see project milestones
And
project has milestones
When
I click project
"Shop"
link
And
I search for
"Foo"
And
I click
"Milestones"
link
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
@javascript
Scenario
:
I
should see Wiki blobs
And
project has Wiki content
When
I click project
"Shop"
link
And
I search for
"Wiki content"
And
I click
"Wiki"
link
Then
I should see
"test_wiki"
link in the search results
Scenario
:
I
logout and should see project I am looking for
Given
project
"Shop"
is public
And
I logout directly
And
I visit dashboard search page
And
I search for
"Sho"
Then
I should see
"Shop"
project link
@javascript
Scenario
:
I
logout and should see issues I am looking for
Given
project
"Shop"
is public
And
I logout directly
And
I visit dashboard search page
And
project has issues
When
I search for
"Foo"
And
I click
"Issues"
link
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
Scenario
:
I
logout and should see project code I am looking for
Given
project
"Shop"
is public
And
I logout directly
When
I visit project
"Shop"
page
And
I search for
"rspec"
on project page
Then
I should see code results for project
"Shop"
features/steps/search.rb
deleted
100644 → 0
View file @
20295b3d
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"
find
(
'.btn-search'
).
trigger
(
'click'
)
end
step
'I search for "rspec"'
do
fill_in
"dashboard_search"
,
with:
"rspec"
find
(
'.btn-search'
).
trigger
(
'click'
)
end
step
'I search for "rspec" on project page'
do
fill_in
"search"
,
with:
"rspec"
click_button
"Go"
end
step
'I search for "Wiki content"'
do
fill_in
"dashboard_search"
,
with:
"content"
find
(
'.btn-search'
).
trigger
(
'click'
)
end
step
'I click "Issues" link'
do
page
.
within
'.search-filter'
do
click_link
'Issues'
end
end
step
'I click project "Shop" link'
do
find
(
'.js-search-project-dropdown'
).
trigger
(
'click'
)
page
.
within
'.project-filter'
do
click_link
project
.
name_with_namespace
end
end
step
'I click "Merge requests" link'
do
page
.
within
'.search-filter'
do
click_link
'Merge requests'
end
end
step
'I click "Milestones" link'
do
page
.
within
'.search-filter'
do
click_link
'Milestones'
end
end
step
'I click "Wiki" link'
do
page
.
within
'.search-filter'
do
click_link
'Wiki'
end
end
step
'I should see "Shop" project link'
do
expect
(
page
).
to
have_link
"Shop"
end
step
'I should see code results for project "Shop"'
do
page
.
within
(
'.results'
)
do
page
.
should
have_content
'Update capybara, rspec-rails, poltergeist to recent versions'
end
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
step
'project has milestones'
do
create
(
:milestone
,
title:
"Foo"
,
project:
project
)
create
(
:milestone
,
title:
"Bar"
,
project:
project
)
end
step
'I should see "Foo" link in the search results'
do
page
.
within
(
'.results'
)
do
find
(
:css
,
'.search-results'
).
should
have_link
'Foo'
end
end
step
'I should not see "Bar" link in the search results'
do
expect
(
find
(
:css
,
'.search-results'
)).
not_to
have_link
'Bar'
end
step
'I should see "test_wiki" link in the search results'
do
page
.
within
(
'.results'
)
do
expect
(
find
(
:css
,
'.search-results'
)).
to
have_link
'test_wiki'
end
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
step
'project "Shop" is public'
do
project
.
update_attributes
(
visibility_level:
Project
::
PUBLIC
)
end
end
spec/features/search/user_searches_for_code_spec.rb
0 → 100644
View file @
b3d79b1f
require
'spec_helper'
describe
'User searches for code'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
user
.
namespace
)
}
context
'when signed in'
do
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
end
it
'finds a file'
do
visit
(
project_path
(
project
))
page
.
within
(
'.search'
)
do
fill_in
(
'search'
,
with:
'application.js'
)
click_button
(
'Go'
)
end
click_link
(
'Code'
)
expect
(
page
).
to
have_selector
(
'.file-content .code'
)
expect
(
page
).
to
have_selector
(
"span.line[lang='javascript']"
)
end
context
'when on a project page'
,
:js
do
before
do
visit
(
search_path
)
end
include_examples
'top right search form'
it
'finds code'
do
find
(
'.js-search-project-dropdown'
).
trigger
(
'click'
)
page
.
within
(
'.project-filter'
)
do
click_link
(
project
.
name_with_namespace
)
end
fill_in
(
'dashboard_search'
,
with:
'rspec'
)
find
(
'.btn-search'
).
trigger
(
'click'
)
page
.
within
(
'.results'
)
do
expect
(
find
(
:css
,
'.search-results'
)).
to
have_content
(
'Update capybara, rspec-rails, poltergeist to recent versions'
)
end
end
end
end
context
'when signed out'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
before
do
visit
(
project_path
(
project
))
end
it
'finds code'
do
fill_in
(
'search'
,
with:
'rspec'
)
click_button
(
'Go'
)
page
.
within
(
'.results'
)
do
expect
(
find
(
:css
,
'.search-results'
)).
to
have_content
(
'Update capybara, rspec-rails, poltergeist to recent versions'
)
end
end
end
end
spec/features/search/user_searches_for_comments_spec.rb
0 → 100644
View file @
b3d79b1f
require
'spec_helper'
describe
'User searches for comments'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_reporter
(
user
)
sign_in
(
user
)
visit
(
project_path
(
project
))
end
context
'when a comment is in commits'
do
context
'when comment belongs to an invalid commit'
do
let
(
:comment
)
{
create
(
:note_on_commit
,
author:
user
,
project:
project
,
commit_id:
12345678
,
note:
'Bug here'
)
}
it
'finds a commit'
do
page
.
within
(
'.search'
)
do
fill_in
(
'search'
,
with:
comment
.
note
)
click_button
(
'Go'
)
end
click_link
(
'Comments'
)
expect
(
page
).
to
have_text
(
'Commit deleted'
)
expect
(
page
).
to
have_text
(
'12345678'
)
end
end
end
context
'when a comment is in a snippet'
do
let
(
:snippet
)
{
create
(
:project_snippet
,
:private
,
project:
project
,
author:
user
,
title:
'Some title'
)
}
let
(
:comment
)
{
create
(
:note
,
noteable:
snippet
,
author:
user
,
note:
'Supercalifragilisticexpialidocious'
,
project:
project
)
}
it
'finds a snippet'
do
page
.
within
(
'.search'
)
do
fill_in
(
'search'
,
with:
comment
.
note
)
click_button
(
'Go'
)
end
click_link
(
'Comments'
)
expect
(
page
).
to
have_link
(
snippet
.
title
)
end
end
end
spec/features/search/user_searches_for_commits_spec.rb
0 → 100644
View file @
b3d79b1f
require
'spec_helper'
describe
'User searches for commits'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:sha
)
{
'6d394385cf567f80a8fd85055db1ab4c5295806f'
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_reporter
(
user
)
sign_in
(
user
)
visit
(
search_path
(
project_id:
project
.
id
))
end
context
'when searching by SHA'
do
it
'finds a commit and redirects to its page'
do
fill_in
(
'search'
,
with:
sha
)
click_button
(
'Search'
)
expect
(
page
).
to
have_current_path
(
project_commit_path
(
project
,
sha
))
end
it
'finds a commit in uppercase and redirects to its page'
do
fill_in
(
'search'
,
with:
sha
.
upcase
)
click_button
(
'Search'
)
expect
(
page
).
to
have_current_path
(
project_commit_path
(
project
,
sha
))
end
end
context
'when searching by message'
do
it
'finds a commit and holds on /search page'
do
create_commit
(
'Message referencing another sha: "deadbeef"'
,
project
,
user
,
'master'
)
fill_in
(
'search'
,
with:
'deadbeef'
)
click_button
(
'Search'
)
expect
(
page
).
to
have_current_path
(
'/search'
,
only_path:
true
)
end
it
'finds multiple commits'
do
fill_in
(
'search'
,
with:
'See merge request'
)
click_button
(
'Search'
)
click_link
(
'Commits'
)
expect
(
page
).
to
have_selector
(
'.commit-row-description'
,
count:
9
)
end
end
end
spec/features/search/user_searches_for_issues_spec.rb
0 → 100644
View file @
b3d79b1f
require
'spec_helper'
describe
'User searches for issues'
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:issue1
)
{
create
(
:issue
,
title:
'Foo'
,
project:
project
)
}
let!
(
:issue2
)
{
create
(
:issue
,
title:
'Bar'
,
project:
project
)
}
context
'when signed in'
do
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
search_path
)
end
include_examples
'top right search form'
it
'finds an issue'
do
fill_in
(
'dashboard_search'
,
with:
issue1
.
title
)
find
(
'.btn-search'
).
trigger
(
'click'
)
page
.
within
(
'.search-filter'
)
do
click_link
(
'Issues'
)
end
page
.
within
(
'.results'
)
do
expect
(
find
(
:css
,
'.search-results'
)).
to
have_link
(
issue1
.
title
).
and
have_no_link
(
issue2
.
title
)
end
end
context
'when on a project page'
do
it
'finds an issue'
do
find
(
'.js-search-project-dropdown'
).
trigger
(
'click'
)
page
.
within
(
'.project-filter'
)
do
click_link
(
project
.
name_with_namespace
)
end
fill_in
(
'dashboard_search'
,
with:
issue1
.
title
)
find
(
'.btn-search'
).
trigger
(
'click'
)
page
.
within
(
'.search-filter'
)
do
click_link
(
'Issues'
)
end
page
.
within
(
'.results'
)
do
expect
(
find
(
:css
,
'.search-results'
)).
to
have_link
(
issue1
.
title
).
and
have_no_link
(
issue2
.
title
)
end
end
end
end
context
'when signed out'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
before
do
visit
(
search_path
)
end
include_examples
'top right search form'
it
'finds an issue'
do
fill_in
(
'dashboard_search'
,
with:
issue1
.
title
)
find
(
'.btn-search'
).
trigger
(
'click'
)
page
.
within
(
'.search-filter'
)
do
click_link
(
'Issues'
)
end
page
.
within
(
'.results'
)
do
expect
(
find
(
:css
,
'.search-results'
)).
to
have_link
(
issue1
.
title
).
and
have_no_link
(
issue2
.
title
)
end
end
end
end
spec/features/search/user_searches_for_merge_requests_spec.rb
0 → 100644
View file @
b3d79b1f
require
'spec_helper'
describe
'User searches for merge requests'
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:merge_request1
)
{
create
(
:merge_request
,
title:
'Foo'
,
source_project:
project
,
target_project:
project
)
}
let!
(
:merge_request2
)
{
create
(
:merge_request
,
:simple
,
title:
'Bar'
,
source_project:
project
,
target_project:
project
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
search_path
)
end
include_examples
'top right search form'
it
'finds a merge request'
do
fill_in
(
'dashboard_search'
,
with:
merge_request1
.
title
)
find
(
'.btn-search'
).
trigger
(
'click'
)
page
.
within
(
'.search-filter'
)
do
click_link
(
'Merge requests'
)
end
page
.
within
(
'.results'
)
do
expect
(
find
(
:css
,
'.search-results'
)).
to
have_link
(
merge_request1
.
title
).
and
have_no_link
(
merge_request2
.
title
)
end
end
context
'when on a project page'
do
it
'finds a merge request'
do
find
(
'.js-search-project-dropdown'
).
trigger
(
'click'
)
page
.
within
(
'.project-filter'
)
do
click_link
(
project
.
name_with_namespace
)
end
fill_in
(
'dashboard_search'
,
with:
merge_request1
.
title
)
find
(
'.btn-search'
).
trigger
(
'click'
)
page
.
within
(
'.search-filter'
)
do
click_link
(
'Merge requests'
)
end
page
.
within
(
'.results'
)
do
expect
(
find
(
:css
,
'.search-results'
)).
to
have_link
(
merge_request1
.
title
).
and
have_no_link
(
merge_request2
.
title
)
end
end
end
end
spec/features/search/user_searches_for_milestones_spec.rb
0 → 100644
View file @
b3d79b1f
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
)
find
(
'.btn-search'
).
trigger
(
'click'
)
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
find
(
'.js-search-project-dropdown'
).
trigger
(
'click'
)
page
.
within
(
'.project-filter'
)
do
click_link
(
project
.
name_with_namespace
)
end
fill_in
(
'dashboard_search'
,
with:
milestone1
.
title
)
find
(
'.btn-search'
).
trigger
(
'click'
)
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
spec/features/search/user_searches_for_projects_spec.rb
0 → 100644
View file @
b3d79b1f
require
'spec_helper'
describe
'User searches for projects'
do
let!
(
:project
)
{
create
(
:project
,
:public
,
name:
'Shop'
)
}
context
'when signed out'
do
include_examples
'top right search form'
it
'finds a project'
do
visit
(
search_path
)
fill_in
(
'dashboard_search'
,
with:
project
.
name
[
0
..
3
])
click_button
(
'Search'
)
expect
(
page
).
to
have_link
(
project
.
name
)
end
it
'preserves the group being searched in'
do
visit
(
search_path
(
group_id:
project
.
namespace
.
id
))
fill_in
(
'search'
,
with:
'foo'
)
click_button
(
'Search'
)
expect
(
find
(
'#group_id'
,
visible:
false
).
value
).
to
eq
(
project
.
namespace
.
id
.
to_s
)
end
it
'preserves the project being searched in'
do
visit
(
search_path
(
project_id:
project
.
id
))
fill_in
(
'search'
,
with:
'foo'
)
click_button
(
'Search'
)
expect
(
find
(
'#project_id'
,
visible:
false
).
value
).
to
eq
(
project
.
id
.
to_s
)
end
end
end
spec/features/search/user_searches_for_wiki_pages_spec.rb
0 → 100644
View file @
b3d79b1f
require
'spec_helper'
describe
'User searches for wiki pages'
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:wiki_page
)
{
create
(
:wiki_page
,
wiki:
project
.
wiki
,
attrs:
{
title:
'test_wiki'
,
content:
'Some Wiki content'
})
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
search_path
)
end
include_examples
'top right search form'
it
'finds a page'
do