Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
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
find
(
'.js-search-project-dropdown'
).
trigger
(
'click'
)
page
.
within
(
'.project-filter'
)
do
click_link
(
project
.
name_with_namespace
)
end
fill_in
(
'dashboard_search'
,
with:
'content'
)
find
(
'.btn-search'
).
trigger
(
'click'
)
page
.
within
(
'.search-filter'
)
do
click_link
(
'Wiki'
)
end
page
.
within
(
'.results'
)
do
expect
(
find
(
:css
,
'.search-results'
)).
to
have_link
(
wiki_page
.
title
)
end
end
end
spec/features/search/user_uses_header_search_field_spec.rb
0 → 100644
View file @
b3d79b1f
require
'spec_helper'
describe
'User uses header search field'
do
include
FilteredSearchHelpers
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_reporter
(
user
)
sign_in
(
user
)
visit
(
project_path
(
project
))
end
it
'starts searching by pressing the enter key'
,
:js
do
fill_in
(
'search'
,
with:
'gitlab'
)
find
(
'#search'
).
native
.
send_keys
(
:enter
)
page
.
within
(
'.breadcrumbs-sub-title'
)
do
expect
(
page
).
to
have_content
(
'Search'
)
end
end
it
'contains location badge'
do
expect
(
page
).
to
have_selector
(
'.has-location-badge'
)
end
context
'when clicking the search field'
,
:js
do
before
do
page
.
find
(
'#search'
).
click
end
it
'shows category search dropdown'
do
expect
(
page
).
to
have_selector
(
'.dropdown-header'
,
text:
/
#{
project
.
name
}
/i
)
end
context
'when clicking issues'
do
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
,
assignees:
[
user
])
}
it
'shows assigned issues'
do
find
(
'.dropdown-menu'
).
click_link
(
'Issues assigned to me'
)
expect
(
page
).
to
have_selector
(
'.filtered-search'
)
expect_tokens
([
assignee_token
(
user
.
name
)])
expect_filtered_search_input_empty
end
it
'shows created issues'
do
find
(
'.dropdown-menu'
).
click_link
(
"Issues I've created"
)
expect
(
page
).
to
have_selector
(
'.filtered-search'
)
expect_tokens
([
author_token
(
user
.
name
)])
expect_filtered_search_input_empty
end
end
context
'when clicking merge requests'
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
author:
user
,
assignee:
user
)
}
it
'shows assigned merge requests'
do
find
(
'.dropdown-menu'
).
click_link
(
'Merge requests assigned to me'
)
expect
(
page
).
to
have_selector
(
'.merge-requests-holder'
)
expect_tokens
([
assignee_token
(
user
.
name
)])
expect_filtered_search_input_empty
end
it
'shows created merge requests'
do
find
(
'.dropdown-menu'
).
click_link
(
"Merge requests I've created"
)
expect
(
page
).
to
have_selector
(
'.merge-requests-holder'
)
expect_tokens
([
author_token
(
user
.
name
)])
expect_filtered_search_input_empty
end
end
end
context
'when entering text into the search field'
,
:js
do
before
do
page
.
within
(
'.search-input-wrap'
)
do
fill_in
(
'search'
,
with:
project
.
name
[
0
..
3
])
end
end
it
'does not display the category search dropdown'
do
expect
(
page
).
not_to
have_selector
(
'.dropdown-header'
,
text:
/
#{
project
.
name
}
/i
)
end
end
end
spec/features/search/user_uses_search_filters_spec.rb
0 → 100644
View file @
b3d79b1f
require
'spec_helper'
describe
'User uses search filters'
,
:js
do
let
(
:group
)
{
create
(
:group
)
}
let!
(
:group_project
)
{
create
(
:project
,
group:
group
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_reporter
(
user
)
group
.
add_owner
(
user
)
sign_in
(
user
)
visit
(
search_path
)
end
context
' when filtering by group'
do
it
'shows group projects'
do
find
(
'.js-search-group-dropdown'
).
trigger
(
'click'
)
wait_for_requests
page
.
within
(
'.search-holder'
)
do
click_link
(
group
.
name
)
end
expect
(
find
(
'.js-search-group-dropdown'
)).
to
have_content
(
group
.
name
)
page
.
within
(
'.project-filter'
)
do
find
(
'.js-search-project-dropdown'
).
trigger
(
'click'
)
wait_for_requests
expect
(
page
).
to
have_link
(
group_project
.
name_with_namespace
)
end
end
end
context
' when filtering by project'
do
it
'shows a project'
do
page
.
within
(
'.project-filter'
)
do
find
(
'.js-search-project-dropdown'
).
trigger
(
'click'
)
wait_for_requests
click_link
(
project
.
name_with_namespace
)
end
expect
(
find
(
'.js-search-project-dropdown'
)).
to
have_content
(
project
.
name_with_namespace
)
end
end
end
spec/features/search_spec.rb
deleted
100644 → 0
View file @
20295b3d
require
'spec_helper'
describe
"Search"
do
include
FilteredSearchHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
assignees:
[
user
])
}
let!
(
:issue2
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
before
do
sign_in
(
user
)
project
.
team
<<
[
user
,
:reporter
]
visit
search_path
end
it
'does not show top right search form'
do
expect
(
page
).
not_to
have_selector
(
'.search'
)
end
context
'search filters'
,
js:
true
do
let
(
:group
)
{
create
(
:group
)
}
let!
(
:group_project
)
{
create
(
:project
,
group:
group
)
}
before
do
group
.
add_owner
(
user
)
end
it
'shows group name after filtering'
do
find
(
'.js-search-group-dropdown'
).
trigger
(
'click'
)
wait_for_requests
page
.
within
'.search-holder'
do
click_link
group
.
name
end
expect
(
find
(
'.js-search-group-dropdown'
)).
to
have_content
(
group
.
name
)
end
it
'filters by group projects after filtering by group'
do
find
(
'.js-search-group-dropdown'
).
trigger
(
'click'
)
wait_for_requests
page
.
within
'.search-holder'
do
click_link
group
.
name
end
expect
(
find
(
'.js-search-group-dropdown'
)).
to
have_content
(
group
.
name
)
page
.
within
(
'.project-filter'
)
do
find
(
'.js-search-project-dropdown'
).
trigger
(
'click'
)
wait_for_requests
expect
(
page
).
to
have_link
(
group_project
.
name_with_namespace
)
end
end
it
'shows project name after filtering'
do
page
.
within
(
'.project-filter'
)
do
find
(
'.js-search-project-dropdown'
).
trigger
(
'click'
)
wait_for_requests
click_link
project
.
name_with_namespace
end
expect
(
find
(
'.js-search-project-dropdown'
)).
to
have_content
(
project
.
name_with_namespace
)
end
end
describe
'searching for Projects'
do
it
'finds a project'
do
page
.
within
'.search-holder'
do
fill_in
"search"
,
with:
project
.
name
[
0
..
3
]
click_button
"Search"
end
expect
(
page
).
to
have_content
project
.
name
end
end
context
'search for comments'
do
context
'when comment belongs to a invalid commit'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:note
)
{
create
(
:note_on_commit
,
author:
user
,
project:
project
,
commit_id:
project
.
repository
.
commit
.
id
,
note:
'Bug here'
)
}
before
do
note
.
update_attributes
(
commit_id:
12345678
)
end
it
'finds comment'
do
visit
project_path
(
project
)
page
.
within
'.search'
do
fill_in
'search'
,
with:
note
.
note
click_button
'Go'
end
click_link
'Comments'
expect
(
page
).
to
have_text
(
"Commit deleted"
)
expect
(
page
).
to
have_text
(
"12345678"
)
end
end
it
'finds a snippet'
do
snippet
=
create
(
:project_snippet
,
:private
,
project:
project
,
author:
user
,
title:
'Some title'
)
note
=
create
(
:note
,
noteable:
snippet
,
author:
user
,
note:
'Supercalifragilisticexpialidocious'
,
project:
project
)
# Must visit project dashboard since global search won't search
# everything (e.g. comments, snippets, etc.)
visit
project_path
(
project
)
page
.
within
'.search'
do
fill_in
'search'
,
with:
note
.
note
click_button
'Go'
end
click_link
'Comments'
expect
(
page
).
to
have_link
(
snippet
.
title
)
end
it
'finds a commit'
do
project
=
create
(
:project
,
:repository
)
{
|
p
|
p
.
add_reporter
(
user
)
}
visit
project_path
(
project
)
page
.
within
'.search'
do
fill_in
'search'
,
with:
'add'
click_button
'Go'
end
click_link
"Commits"
expect
(
page
).
to
have_selector
(
'.commit-row-description'
)
end
it
'finds a code'
do
project
=
create
(
:project
,
:repository
)
{
|
p
|
p
.
add_reporter
(
user
)
}
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
end
describe
'Right header search field'
do
it
'allows enter key to search'
,
js:
true
do
visit
project_path
(
project
)
fill_in
'search'
,
with:
'gitlab'
find
(
'#search'
).
native
.
send_keys
(
:enter
)
page
.
within
'.breadcrumbs-sub-title'
do
expect
(
page
).
to
have_content
'Search'
end
end
describe
'Search in project page'
do
before
do
visit
project_path
(
project
)
end
it
'shows top right search form'
do
expect
(
page
).
to
have_selector
(
'#search'
)
end
it
'contains location badge in top right search form'
do
expect
(
page
).
to
have_selector
(
'.has-location-badge'
)
end
context
'clicking the search field'
,
js:
true
do
it
'shows category search dropdown'
do
page
.
find
(
'#search'
).
click
expect
(
page
).
to
have_selector
(
'.dropdown-header'
,
text:
/
#{
project
.
name
}
/i
)
end
end
context
'click the links in the category search dropdown'
,
js:
true
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
author:
user
,
assignee:
user
)
}
before
do
page
.
find
(
'#search'
).
click
end
it
'takes user to her issues page when issues assigned is clicked'
do
find
(
'.dropdown-menu'
).
click_link
'Issues assigned to me'
expect
(
page
).
to
have_selector
(
'.filtered-search'
)
expect_tokens
([
assignee_token
(
user
.
name
)])
expect_filtered_search_input_empty
end
it
'takes user to her issues page when issues authored is clicked'
do
find
(
'.dropdown-menu'
).
click_link
"Issues I've created"
expect
(
page
).
to
have_selector
(
'.filtered-search'
)
expect_tokens
([
author_token
(
user
.
name
)])
expect_filtered_search_input_empty
end
it
'takes user to her MR page when MR assigned is clicked'
do
find
(
'.dropdown-menu'
).
click_link
'Merge requests assigned to me'
expect
(
page
).
to
have_selector
(
'.merge-requests-holder'
)
expect_tokens
([
assignee_token
(
user
.
name
)])
expect_filtered_search_input_empty
end
it
'takes user to her MR page when MR authored is clicked'
do
find
(
'.dropdown-menu'
).
click_link
"Merge requests I've created"
expect
(
page
).
to
have_selector
(
'.merge-requests-holder'
)
expect_tokens
([
author_token
(
user
.
name
)])
expect_filtered_search_input_empty
end
end
context
'entering text into the search field'
,
js:
true
do
before
do
page
.
within
'.search-input-wrap'
do
fill_in
"search"
,
with:
project
.
name
[
0
..
3
]
end
end
it
'does not display the category search dropdown'
do
expect
(
page
).
not_to
have_selector
(
'.dropdown-header'
,
text:
/
#{
project
.
name
}
/i
)
end
end
end
end
describe
'search for commits'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
visit
search_path
(
project_id:
project
.
id
)
end
it
'redirects to commit page when search by sha and only commit found'
do
fill_in
'search'
,
with:
'6d394385cf567f80a8fd85055db1ab4c5295806f'
click_button
'Search'
expect
(
page
).
to
have_current_path
(
project_commit_path
(
project
,
'6d394385cf567f80a8fd85055db1ab4c5295806f'
))
end
it
'redirects to single commit regardless of query case'
do
fill_in
'search'
,
with:
'6D394385cf'
click_button
'Search'
expect
(
page
).
to
have_current_path
(
project_commit_path
(
project
,
'6d394385cf567f80a8fd85055db1ab4c5295806f'
))
end
it
'holds on /search page when the only commit is found by message'
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
'shows multiple matching 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
context
'anonymous user'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
before
do
sign_out
(
user
)
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/support/shared_examples/features/search_shared_examples.rb
0 → 100644
View file @
b3d79b1f
shared_examples
'top right search form'
do
it
'does not show top right search form'
do
expect
(
page
).
not_to
have_selector
(
'.search'
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment