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
Boxiang Sun
gitlab-ce
Commits
9823d00e
Commit
9823d00e
authored
Feb 17, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to see and sort on vote count from Issues and MR lists
parent
943bed68
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
247 additions
and
3 deletions
+247
-3
CHANGELOG
CHANGELOG
+1
-0
app/assets/stylesheets/pages/issues.scss
app/assets/stylesheets/pages/issues.scss
+1
-1
app/assets/stylesheets/pages/merge_requests.scss
app/assets/stylesheets/pages/merge_requests.scss
+2
-2
app/helpers/sorting_helper.rb
app/helpers/sorting_helper.rb
+18
-0
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+25
-0
app/views/projects/issues/_issue.html.haml
app/views/projects/issues/_issue.html.haml
+19
-0
app/views/projects/merge_requests/_merge_request.html.haml
app/views/projects/merge_requests/_merge_request.html.haml
+19
-0
app/views/shared/_sort_dropdown.html.haml
app/views/shared/_sort_dropdown.html.haml
+4
-0
features/project/issues/issues.feature
features/project/issues/issues.feature
+10
-0
features/project/merge_requests.feature
features/project/merge_requests.feature
+11
-0
features/steps/project/issues/issues.rb
features/steps/project/issues/issues.rb
+57
-0
features/steps/project/merge_requests.rb
features/steps/project/merge_requests.rb
+50
-0
features/steps/shared/issuable.rb
features/steps/shared/issuable.rb
+16
-0
spec/factories/notes.rb
spec/factories/notes.rb
+14
-0
No files found.
CHANGELOG
View file @
9823d00e
...
...
@@ -62,6 +62,7 @@ v 8.5.0 (unreleased)
- Replaces "Create merge request" link with one to the "Merge Request" when one exists
- Fix CI builds badge, add a new link to builds badge, deprecate the old one
- Fix broken link to project in build notification emails
- Ability to see and sort on vote count from Issues and MR lists
v 8.4.4
- Update omniauth-saml gem to 1.4.2
...
...
app/assets/stylesheets/pages/issues.scss
View file @
9823d00e
...
...
@@ -24,7 +24,7 @@
display
:
inline-block
;
}
.issue-no-comments
{
.issue-no-comments
,
.issue-no-votes
{
opacity
:
0
.5
;
}
}
...
...
app/assets/stylesheets/pages/merge_requests.scss
View file @
9823d00e
...
...
@@ -163,7 +163,7 @@
display
:
inline-block
;
}
.merge-request-no-comments
{
.merge-request-no-comments
,
.merge-request-no-votes
{
opacity
:
0
.5
;
}
}
...
...
@@ -236,4 +236,4 @@
}
}
}
}
\ No newline at end of file
}
app/helpers/sorting_helper.rb
View file @
9823d00e
...
...
@@ -11,6 +11,8 @@ module SortingHelper
sort_value_largest_repo
=>
sort_title_largest_repo
,
sort_value_recently_signin
=>
sort_title_recently_signin
,
sort_value_oldest_signin
=>
sort_title_oldest_signin
,
sort_value_downvotes
=>
sort_title_downvotes
,
sort_value_upvotes
=>
sort_title_upvotes
}
end
...
...
@@ -54,6 +56,14 @@ module SortingHelper
'Oldest sign in'
end
def
sort_title_downvotes
'Least popular'
end
def
sort_title_upvotes
'Most popular'
end
def
sort_value_oldest_updated
'updated_asc'
end
...
...
@@ -93,4 +103,12 @@ module SortingHelper
def
sort_value_oldest_signin
'oldest_sign_in'
end
def
sort_value_downvotes
'downvotes_desc'
end
def
sort_value_upvotes
'upvotes_desc'
end
end
app/models/concerns/issuable.rb
View file @
9823d00e
...
...
@@ -69,10 +69,35 @@ module Issuable
case
method
.
to_s
when
'milestone_due_asc'
then
order_milestone_due_asc
when
'milestone_due_desc'
then
order_milestone_due_desc
when
'downvotes_desc'
then
order_downvotes_desc
when
'upvotes_desc'
then
order_upvotes_desc
else
order_by
(
method
)
end
end
def
order_downvotes_desc
order_votes_desc
(
'thumbsdown'
)
end
def
order_upvotes_desc
order_votes_desc
(
'thumbsup'
)
end
def
order_votes_desc
(
award_emoji_name
)
issuable_table
=
self
.
arel_table
note_table
=
Note
.
arel_table
join_clause
=
issuable_table
.
join
(
note_table
,
Arel
::
Nodes
::
OuterJoin
).
on
(
note_table
[
:noteable_id
].
eq
(
issuable_table
[
:id
]).
and
(
note_table
[
:noteable_type
].
eq
(
self
.
name
).
and
(
note_table
[
:is_award
].
eq
(
true
).
and
(
note_table
[
:note
].
eq
(
award_emoji_name
))
)
)
).
join_sources
joins
(
join_clause
).
group
(
issuable_table
[
:id
]).
reorder
(
"COUNT(notes.id) DESC"
)
end
end
def
today?
...
...
app/views/projects/issues/_issue.html.haml
View file @
9823d00e
...
...
@@ -15,6 +15,25 @@
%li
=
link_to_member
(
@project
,
issue
.
assignee
,
name:
false
,
title:
"Assigned to :name"
)
-
upvotes
,
downvotes
=
issue
.
upvotes
,
issue
.
downvotes
-
if
upvotes
>
0
||
downvotes
>
0
%li
=
icon
(
'thumbs-up'
)
=
upvotes
-
else
%li
{
class:
'issue-no-votes'
}
=
icon
(
'thumbs-up'
)
=
upvotes
-
if
upvotes
>
0
||
downvotes
>
0
%li
=
icon
(
'thumbs-down'
)
=
downvotes
-
else
%li
{
class:
'issue-no-votes'
}
=
icon
(
'thumbs-down'
)
=
downvotes
-
note_count
=
issue
.
notes
.
user
.
count
-
if
note_count
>
0
%li
...
...
app/views/projects/merge_requests/_merge_request.html.haml
View file @
9823d00e
...
...
@@ -24,6 +24,25 @@
%li
=
link_to_member
(
merge_request
.
source_project
,
merge_request
.
assignee
,
name:
false
,
title:
"Assigned to :name"
)
-
upvotes
,
downvotes
=
merge_request
.
upvotes
,
merge_request
.
downvotes
-
if
upvotes
>
0
||
downvotes
>
0
%li
=
icon
(
'thumbs-up'
)
=
upvotes
-
else
%li
{
class:
'merge-request-no-votes'
}
=
icon
(
'thumbs-up'
)
=
upvotes
-
if
upvotes
>
0
||
downvotes
>
0
%li
=
icon
(
'thumbs-down'
)
=
downvotes
-
else
%li
{
class:
'merge-request-no-votes'
}
=
icon
(
'thumbs-down'
)
=
downvotes
-
note_count
=
merge_request
.
mr_and_commit_notes
.
user
.
count
-
if
note_count
>
0
%li
...
...
app/views/shared/_sort_dropdown.html.haml
View file @
9823d00e
...
...
@@ -20,3 +20,7 @@
=
sort_title_milestone_soon
=
link_to
page_filter_path
(
sort:
sort_value_milestone_later
)
do
=
sort_title_milestone_later
=
link_to
page_filter_path
(
sort:
sort_value_upvotes
)
do
=
sort_title_upvotes
=
link_to
page_filter_path
(
sort:
sort_value_downvotes
)
do
=
sort_title_downvotes
features/project/issues/issues.feature
View file @
9823d00e
...
...
@@ -88,6 +88,16 @@ Feature: Project Issues
And
I visit dashboard merge requests page
Then
The list should be sorted by
"Oldest updated"
@javascript
Scenario
:
Sort issues by upvotes/downvotes
Given
project
"Shop"
have
"Bugfix"
open issue
And
issue
"Release 0.4"
have 2 upvotes and 1 downvote
And
issue
"Tweet control"
have 1 upvote and 2 downvotes
And
I sort the list by
"Most popular"
Then
The list should be sorted by
"Most popular"
And
I sort the list by
"Least popular"
Then
The list should be sorted by
"Least popular"
@javascript
Scenario
:
I
search issue
Given
I fill in issue search with
"Re"
...
...
features/project/merge_requests.feature
View file @
9823d00e
...
...
@@ -107,6 +107,17 @@ Feature: Project Merge Requests
And
I visit dashboard merge requests page
Then
The list should be sorted by
"Oldest updated"
@javascript
Scenario
:
Sort merge requests by upvotes/downvotes
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
project
"Shop"
have
"Bug NS-06"
open merge request
And
merge request
"Bug NS-04"
have 2 upvotes and 1 downvote
And
merge request
"Bug NS-06"
have 1 upvote and 2 downvotes
And
I sort the list by
"Most popular"
Then
The list should be sorted by
"Most popular"
And
I sort the list by
"Least popular"
Then
The list should be sorted by
"Least popular"
@javascript
Scenario
:
Visiting Merge Requests after commenting on diffs
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
...
...
features/steps/project/issues/issues.rb
View file @
9823d00e
...
...
@@ -174,6 +174,13 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
author:
project
.
users
.
first
)
end
step
'project "Shop" have "Bugfix" open issue'
do
create
(
:issue
,
title:
"Bugfix"
,
project:
project
,
author:
project
.
users
.
first
)
end
step
'project "Shop" have "Release 0.3" closed issue'
do
create
(
:closed_issue
,
title:
"Release 0.3"
,
...
...
@@ -181,6 +188,56 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
author:
project
.
users
.
first
)
end
step
'issue "Release 0.4" have 2 upvotes and 1 downvote'
do
issue
=
Issue
.
find_by
(
title:
'Release 0.4'
)
create_list
(
:upvote_note
,
2
,
project:
project
,
noteable:
issue
)
create
(
:downvote_note
,
project:
project
,
noteable:
issue
)
end
step
'issue "Tweet control" have 1 upvote and 2 downvotes'
do
issue
=
Issue
.
find_by
(
title:
'Tweet control'
)
create
(
:upvote_note
,
project:
project
,
noteable:
issue
)
create_list
(
:downvote_note
,
2
,
project:
project
,
noteable:
issue
)
end
step
'The list should be sorted by "Least popular"'
do
page
.
within
'.issues-list'
do
page
.
within
'li.issue:nth-child(1)'
do
expect
(
page
).
to
have_content
'Tweet control'
expect
(
page
).
to
have_content
'1 2'
end
page
.
within
'li.issue:nth-child(2)'
do
expect
(
page
).
to
have_content
'Release 0.4'
expect
(
page
).
to
have_content
'2 1'
end
page
.
within
'li.issue:nth-child(3)'
do
expect
(
page
).
to
have_content
'Bugfix'
expect
(
page
).
to
have_content
'0 0'
end
end
end
step
'The list should be sorted by "Most popular"'
do
page
.
within
'.issues-list'
do
page
.
within
'li.issue:nth-child(1)'
do
expect
(
page
).
to
have_content
'Release 0.4'
expect
(
page
).
to
have_content
'2 1'
end
page
.
within
'li.issue:nth-child(2)'
do
expect
(
page
).
to
have_content
'Tweet control'
expect
(
page
).
to
have_content
'1 2'
end
page
.
within
'li.issue:nth-child(3)'
do
expect
(
page
).
to
have_content
'Bugfix'
expect
(
page
).
to
have_content
'0 0'
end
end
end
step
'empty project "Empty Project"'
do
create
:empty_project
,
name:
'Empty Project'
,
namespace:
@user
.
namespace
end
...
...
features/steps/project/merge_requests.rb
View file @
9823d00e
...
...
@@ -138,6 +138,56 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
author:
project
.
users
.
first
)
end
step
'merge request "Bug NS-04" have 2 upvotes and 1 downvote'
do
merge_request
=
MergeRequest
.
find_by
(
title:
'Bug NS-04'
)
create_list
(
:upvote_note
,
2
,
project:
project
,
noteable:
merge_request
)
create
(
:downvote_note
,
project:
project
,
noteable:
merge_request
)
end
step
'merge request "Bug NS-06" have 1 upvote and 2 downvotes'
do
merge_request
=
MergeRequest
.
find_by
(
title:
'Bug NS-06'
)
create
(
:upvote_note
,
project:
project
,
noteable:
merge_request
)
create_list
(
:downvote_note
,
2
,
project:
project
,
noteable:
merge_request
)
end
step
'The list should be sorted by "Least popular"'
do
page
.
within
'.mr-list'
do
page
.
within
'li.merge-request:nth-child(1)'
do
expect
(
page
).
to
have_content
'Bug NS-06'
expect
(
page
).
to
have_content
'1 2'
end
page
.
within
'li.merge-request:nth-child(2)'
do
expect
(
page
).
to
have_content
'Bug NS-04'
expect
(
page
).
to
have_content
'2 1'
end
page
.
within
'li.merge-request:nth-child(3)'
do
expect
(
page
).
to
have_content
'Bug NS-05'
expect
(
page
).
to
have_content
'0 0'
end
end
end
step
'The list should be sorted by "Most popular"'
do
page
.
within
'.mr-list'
do
page
.
within
'li.merge-request:nth-child(1)'
do
expect
(
page
).
to
have_content
'Bug NS-04'
expect
(
page
).
to
have_content
'2 1'
end
page
.
within
'li.merge-request:nth-child(2)'
do
expect
(
page
).
to
have_content
'Bug NS-06'
expect
(
page
).
to
have_content
'1 2'
end
page
.
within
'li.merge-request:nth-child(3)'
do
expect
(
page
).
to
have_content
'Bug NS-05'
expect
(
page
).
to
have_content
'0 0'
end
end
end
step
'I click on the Changes tab'
do
page
.
within
'.merge-request-tabs'
do
click_link
'Changes'
...
...
features/steps/shared/issuable.rb
View file @
9823d00e
...
...
@@ -113,6 +113,22 @@ module SharedIssuable
end
end
step
'I sort the list by "Least popular"'
do
find
(
'button.dropdown-toggle.btn'
).
click
page
.
within
(
'ul.dropdown-menu.dropdown-menu-align-right li'
)
do
click_link
'Least popular'
end
end
step
'I sort the list by "Most popular"'
do
find
(
'button.dropdown-toggle.btn'
).
click
page
.
within
(
'ul.dropdown-menu.dropdown-menu-align-right li'
)
do
click_link
'Most popular'
end
end
step
'The list should be sorted by "Oldest updated"'
do
page
.
within
(
'div.dropdown.inline.prepend-left-10'
)
do
expect
(
page
.
find
(
'button.dropdown-toggle.btn'
)).
to
have_content
(
'Oldest updated'
)
...
...
spec/factories/notes.rb
View file @
9823d00e
...
...
@@ -34,6 +34,8 @@ FactoryGirl.define do
factory
:note_on_merge_request_diff
,
traits:
[
:on_merge_request
,
:on_diff
]
factory
:note_on_project_snippet
,
traits:
[
:on_project_snippet
]
factory
:system_note
,
traits:
[
:system
]
factory
:downvote_note
,
traits:
[
:award
,
:downvote
]
factory
:upvote_note
,
traits:
[
:award
,
:upvote
]
trait
:on_commit
do
project
...
...
@@ -65,6 +67,18 @@ FactoryGirl.define do
system
true
end
trait
:award
do
is_award
true
end
trait
:downvote
do
note
"thumbsdown"
end
trait
:upvote
do
note
"thumbsup"
end
trait
:with_attachment
do
attachment
{
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"`/png"
)
}
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