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
iv
gitlab-ce
Commits
edc18e77
Commit
edc18e77
authored
Feb 03, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bug/filtering' into 'master'
Bug in issue and merge request filtering Fixes #1006
parents
6addb15b
6a87daed
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
150 additions
and
9 deletions
+150
-9
app/services/filtering_service.rb
app/services/filtering_service.rb
+24
-9
features/public/public_projects.feature
features/public/public_projects.feature
+37
-0
features/steps/public/projects_feature.rb
features/steps/public/projects_feature.rb
+89
-0
No files found.
app/services/filtering_service.rb
View file @
edc18e77
...
@@ -24,7 +24,8 @@ class FilteringService
...
@@ -24,7 +24,8 @@ class FilteringService
@current_user
=
current_user
@current_user
=
current_user
@params
=
params
@params
=
params
items
=
by_scope
items
=
init_collection
items
=
by_scope
(
items
)
items
=
by_state
(
items
)
items
=
by_state
(
items
)
items
=
by_group
(
items
)
items
=
by_group
(
items
)
items
=
by_project
(
items
)
items
=
by_project
(
items
)
...
@@ -37,20 +38,30 @@ class FilteringService
...
@@ -37,20 +38,30 @@ class FilteringService
private
private
def
by_scope
def
init_collection
table_name
=
klass
.
table_name
table_name
=
klass
.
table_name
return
klass
.
of_projects
(
Project
.
public_only
)
unless
current_user
if
project
if
current_user
.
can?
(
:read_project
,
project
)
project
.
send
(
table_name
)
else
[]
end
else
klass
.
of_projects
(
current_user
.
authorized_projects
)
end
end
def
by_scope
(
items
)
case
params
[
:scope
]
case
params
[
:scope
]
when
'created-by-me'
,
'authored'
then
when
'created-by-me'
,
'authored'
then
current_user
.
send
(
table_name
)
klass
.
where
(
author_id:
current_user
.
id
)
when
'all'
then
when
'all'
then
if
current_user
klass
klass
.
of_projects
(
current_user
.
authorized_projects
.
pluck
(
:id
))
else
klass
.
of_projects
(
Project
.
public_only
)
end
when
'assigned-to-me'
then
when
'assigned-to-me'
then
current_user
.
send
(
"assigned_
#{
table_name
}
"
)
klass
.
where
(
assignee_id:
current_user
.
id
)
else
else
raise
'You must specify default scope'
raise
'You must specify default scope'
end
end
...
@@ -120,4 +131,8 @@ class FilteringService
...
@@ -120,4 +131,8 @@ class FilteringService
items
items
end
end
def
project
Project
.
where
(
id:
params
[
:project_id
]).
first
if
params
[
:project_id
].
present?
end
end
end
features/public/public_projects.feature
View file @
edc18e77
...
@@ -62,3 +62,40 @@ Feature: Public Projects Feature
...
@@ -62,3 +62,40 @@ Feature: Public Projects Feature
Given
public empty project
"Empty Public Project"
Given
public empty project
"Empty Public Project"
When
I visit empty project page
When
I visit empty project page
Then
I should see empty public project details
Then
I should see empty public project details
Scenario
:
I
visit public project issues page as a non authorized user
Given
I visit project
"Community"
page
And
I visit
"Community"
issues page
Then
I should see list of issues for
"Community"
project
Scenario
:
I
visit public project issues page as authorized user
Given
I sign in as a user
Given
I visit project
"Community"
page
And
I visit
"Community"
issues page
Then
I should see list of issues for
"Community"
project
Scenario
:
I
visit internal project issues page as authorized user
Given
I sign in as a user
Given
I visit project
"Internal"
page
And
I visit
"Internal"
issues page
Then
I should see list of issues for
"Internal"
project
Scenario
:
I
visit public project merge requests page as an authorized user
Given
I sign in as a user
Given
I visit project
"Community"
page
And
I visit
"Community"
merge requests page
And
project
"Community"
has
"Bug fix"
open merge request
Then
I should see list of merge requests for
"Community"
project
Scenario
:
I
visit public project merge requests page as a non authorized user
Given
I visit project
"Community"
page
And
I visit
"Community"
merge requests page
And
project
"Community"
has
"Bug fix"
open merge request
Then
I should see list of merge requests for
"Community"
project
Scenario
:
I
visit internal project merge requests page as an authorized user
Given
I sign in as a user
Given
I visit project
"Internal"
page
And
I visit
"Internal"
merge requests page
And
project
"Internal"
has
"Feature implemented"
open merge request
Then
I should see list of merge requests for
"Internal"
project
features/steps/public/projects_feature.rb
View file @
edc18e77
...
@@ -107,5 +107,94 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
...
@@ -107,5 +107,94 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
project
=
Project
.
find_by
(
name:
'Community'
)
project
=
Project
.
find_by
(
name:
'Community'
)
page
.
should
have_field
(
'project_clone'
,
with:
project
.
url_to_repo
)
page
.
should
have_field
(
'project_clone'
,
with:
project
.
url_to_repo
)
end
end
step
'I visit "Community" issues page'
do
create
(
:issue
,
title:
"Bug"
,
project:
public_project
)
create
(
:issue
,
title:
"New feature"
,
project:
public_project
)
visit
project_issues_path
(
public_project
)
end
step
'I should see list of issues for "Community" project'
do
page
.
should
have_content
"Bug"
page
.
should
have_content
public_project
.
name
page
.
should
have_content
"New feature"
end
step
'I visit "Internal" issues page'
do
create
(
:issue
,
title:
"Internal Bug"
,
project:
internal_project
)
create
(
:issue
,
title:
"New internal feature"
,
project:
internal_project
)
visit
project_issues_path
(
internal_project
)
end
step
'I should see list of issues for "Internal" project'
do
page
.
should
have_content
"Internal Bug"
page
.
should
have_content
internal_project
.
name
page
.
should
have_content
"New internal feature"
end
step
'I visit "Community" merge requests page'
do
visit
project_merge_requests_path
(
public_project
)
end
step
'project "Community" has "Bug fix" open merge request'
do
create
(
:merge_request
,
title:
"Bug fix for public project"
,
source_project:
public_project
,
target_project:
public_project
,
)
end
step
'I should see list of merge requests for "Community" project'
do
page
.
should
have_content
public_project
.
name
page
.
should
have_content
public_merge_request
.
source_project
.
name
end
step
'I visit "Internal" merge requests page'
do
visit
project_merge_requests_path
(
internal_project
)
end
step
'project "Internal" has "Feature implemented" open merge request'
do
create
(
:merge_request
,
title:
"Feature implemented"
,
source_project:
internal_project
,
target_project:
internal_project
)
end
step
'I should see list of merge requests for "Internal" project'
do
page
.
should
have_content
internal_project
.
name
page
.
should
have_content
internal_merge_request
.
source_project
.
name
end
def
internal_project
@internal_project
||=
Project
.
find_by!
(
name:
'Internal'
)
end
def
public_project
@public_project
||=
Project
.
find_by!
(
name:
'Community'
)
end
def
internal_merge_request
@internal_merge_request
||=
MergeRequest
.
find_by!
(
title:
'Feature implemented'
)
end
def
public_merge_request
@public_merge_request
||=
MergeRequest
.
find_by!
(
title:
'Bug fix for public project'
)
end
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