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
Kazuhiko Shiozaki
gitlab-ce
Commits
7b0c7ae5
Commit
7b0c7ae5
authored
Sep 08, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add votes_count
parent
2e0d5c22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
app/roles/votes.rb
app/roles/votes.rb
+5
-0
spec/roles/votes_spec.rb
spec/roles/votes_spec.rb
+29
-0
No files found.
app/roles/votes.rb
View file @
7b0c7ae5
...
...
@@ -8,4 +8,9 @@ module Votes
def
downvotes
notes
.
select
(
&
:downvote?
).
size
end
# Return the total number of votes
def
votes_count
upvotes
+
downvotes
end
end
spec/roles/votes_spec.rb
View file @
7b0c7ae5
...
...
@@ -50,4 +50,33 @@ describe Issue do
issue
.
downvotes
.
should
==
2
end
end
describe
"#votes_count"
do
it
"with no notes has a 0/0 score"
do
issue
.
votes_count
.
should
==
0
end
it
"should recognize non notes"
do
issue
.
notes
<<
create
(
:note
,
note:
"No +1 here"
)
issue
.
should
have
(
1
).
note
issue
.
votes_count
.
should
==
0
end
it
"should recognize a single +1 note"
do
issue
.
notes
<<
create
(
:note
,
note:
"+1 This is awesome"
)
issue
.
votes_count
.
should
==
1
end
it
"should recognize a single -1 note"
do
issue
.
notes
<<
create
(
:note
,
note:
"-1 This is bad"
)
issue
.
votes_count
.
should
==
1
end
it
"should recognize multiple notes"
do
issue
.
notes
<<
create
(
:note
,
note:
"+1 This is awesome"
)
issue
.
notes
<<
create
(
:note
,
note:
"-1 This is bad"
)
issue
.
notes
<<
create
(
:note
,
note:
"+1 I want this"
)
issue
.
votes_count
.
should
==
3
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