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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
657eb7ba
Commit
657eb7ba
authored
Feb 10, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bug/filtering_service' into 'master'
Fix wrong issues appears at Dashboard#issues page Fixes #1028
parents
c10a35c4
5e30f4d5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
10 deletions
+31
-10
app/controllers/dashboard_controller.rb
app/controllers/dashboard_controller.rb
+2
-2
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+5
-5
app/services/filtering_service.rb
app/services/filtering_service.rb
+3
-3
spec/features/atom/dashboard_issues_spec.rb
spec/features/atom/dashboard_issues_spec.rb
+5
-0
spec/services/filtering_service_spec.rb
spec/services/filtering_service_spec.rb
+16
-0
No files found.
app/controllers/dashboard_controller.rb
View file @
657eb7ba
...
@@ -54,12 +54,12 @@ class DashboardController < ApplicationController
...
@@ -54,12 +54,12 @@ class DashboardController < ApplicationController
def
merge_requests
def
merge_requests
@merge_requests
=
FilteringService
.
new
.
execute
(
MergeRequest
,
current_user
,
params
)
@merge_requests
=
FilteringService
.
new
.
execute
(
MergeRequest
,
current_user
,
params
)
@merge_requests
=
@merge_requests
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
end
end
def
issues
def
issues
@issues
=
FilteringService
.
new
.
execute
(
Issue
,
current_user
,
params
)
@issues
=
FilteringService
.
new
.
execute
(
Issue
,
current_user
,
params
)
@issues
=
@issues
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
includes
(
:author
,
:project
)
@issues
=
@issues
.
includes
(
:author
,
:project
)
respond_to
do
|
format
|
respond_to
do
|
format
|
...
...
app/models/concerns/issuable.rb
View file @
657eb7ba
...
@@ -48,13 +48,13 @@ module Issuable
...
@@ -48,13 +48,13 @@ module Issuable
def
sort
(
method
)
def
sort
(
method
)
case
method
.
to_s
case
method
.
to_s
when
'newest'
then
reorder
(
'created_at DESC'
)
when
'newest'
then
reorder
(
"
#{
table_name
}
.created_at DESC"
)
when
'oldest'
then
reorder
(
'created_at ASC'
)
when
'oldest'
then
reorder
(
"
#{
table_name
}
.created_at ASC"
)
when
'recently_updated'
then
reorder
(
'updated_at DESC'
)
when
'recently_updated'
then
reorder
(
"
#{
table_name
}
.updated_at DESC"
)
when
'last_updated'
then
reorder
(
'updated_at ASC'
)
when
'last_updated'
then
reorder
(
"
#{
table_name
}
.updated_at ASC"
)
when
'milestone_due_soon'
then
joins
(
:milestone
).
reorder
(
"milestones.due_date ASC"
)
when
'milestone_due_soon'
then
joins
(
:milestone
).
reorder
(
"milestones.due_date ASC"
)
when
'milestone_due_later'
then
joins
(
:milestone
).
reorder
(
"milestones.due_date DESC"
)
when
'milestone_due_later'
then
joins
(
:milestone
).
reorder
(
"milestones.due_date DESC"
)
else
reorder
(
'created_at DESC'
)
else
reorder
(
"
#{
table_name
}
.created_at DESC"
)
end
end
end
end
end
end
...
...
app/services/filtering_service.rb
View file @
657eb7ba
...
@@ -57,11 +57,11 @@ class FilteringService
...
@@ -57,11 +57,11 @@ class FilteringService
def
by_scope
(
items
)
def
by_scope
(
items
)
case
params
[
:scope
]
case
params
[
:scope
]
when
'created-by-me'
,
'authored'
then
when
'created-by-me'
,
'authored'
then
klas
s
.
where
(
author_id:
current_user
.
id
)
item
s
.
where
(
author_id:
current_user
.
id
)
when
'all'
then
when
'all'
then
klas
s
item
s
when
'assigned-to-me'
then
when
'assigned-to-me'
then
klas
s
.
where
(
assignee_id:
current_user
.
id
)
item
s
.
where
(
assignee_id:
current_user
.
id
)
else
else
raise
'You must specify default scope'
raise
'You must specify default scope'
end
end
...
...
spec/features/atom/dashboard_issues_spec.rb
View file @
657eb7ba
...
@@ -8,6 +8,11 @@ describe "Dashboard Issues Feed" do
...
@@ -8,6 +8,11 @@ describe "Dashboard Issues Feed" do
let!
(
:issue1
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project1
)
}
let!
(
:issue1
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project1
)
}
let!
(
:issue2
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project2
)
}
let!
(
:issue2
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project2
)
}
before
do
project1
.
team
<<
[
user
,
:master
]
project2
.
team
<<
[
user
,
:master
]
end
describe
"atom feed"
do
describe
"atom feed"
do
it
"should render atom feed via private token"
do
it
"should render atom feed via private token"
do
visit
issues_dashboard_path
(
:atom
,
private_token:
user
.
private_token
)
visit
issues_dashboard_path
(
:atom
,
private_token:
user
.
private_token
)
...
...
spec/services/filtering_service_spec.rb
View file @
657eb7ba
...
@@ -15,6 +15,7 @@ describe FilteringService do
...
@@ -15,6 +15,7 @@ describe FilteringService do
before
do
before
do
project1
.
team
<<
[
user
,
:master
]
project1
.
team
<<
[
user
,
:master
]
project2
.
team
<<
[
user
,
:developer
]
project2
.
team
<<
[
user
,
:developer
]
project2
.
team
<<
[
user2
,
:developer
]
end
end
describe
'merge requests'
do
describe
'merge requests'
do
...
@@ -61,5 +62,20 @@ describe FilteringService do
...
@@ -61,5 +62,20 @@ describe FilteringService do
issues
=
FilteringService
.
new
.
execute
(
Issue
,
user
,
params
)
issues
=
FilteringService
.
new
.
execute
(
Issue
,
user
,
params
)
issues
.
size
.
should
==
1
issues
.
size
.
should
==
1
end
end
it
'should be empty for unauthorized user'
do
params
=
{
scope:
"all"
,
state:
'opened'
}
issues
=
FilteringService
.
new
.
execute
(
Issue
,
nil
,
params
)
issues
.
size
.
should
be_zero
end
it
'should not include unauthorized issues'
do
params
=
{
scope:
"all"
,
state:
'opened'
}
issues
=
FilteringService
.
new
.
execute
(
Issue
,
user2
,
params
)
issues
.
size
.
should
==
2
issues
.
should_not
include
(
issue1
)
issues
.
should
include
(
issue2
)
issues
.
should
include
(
issue3
)
end
end
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