BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
2e0d5c22
Commit
2e0d5c22
authored
Sep 08, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add downvotes
parent
a2a00600
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
17 deletions
+48
-17
votes.rb
app/roles/votes.rb
+5
-0
votes_spec.rb
spec/roles/votes_spec.rb
+43
-17
No files found.
app/roles/votes.rb
View file @
2e0d5c22
...
...
@@ -3,4 +3,9 @@ module Votes
def
upvotes
notes
.
select
(
&
:upvote?
).
size
end
# Return the number of -1 comments (downvotes)
def
downvotes
notes
.
select
(
&
:downvote?
).
size
end
end
spec/roles/votes_spec.rb
View file @
2e0d5c22
require
'spec_helper'
describe
Issue
,
"Upvote"
do
describe
Issue
do
let
(
:issue
)
{
create
(
:issue
)
}
it
"with no notes has a 0/0 score"
do
issue
.
upvotes
.
should
==
0
end
describe
"#upvotes"
do
it
"with no notes has a 0/0 score"
do
issue
.
upvotes
.
should
==
0
end
it
"should recognize non-+1 notes"
do
issue
.
notes
<<
create
(
:note
,
note:
"No +1 here"
)
issue
.
should
have
(
1
).
note
issue
.
notes
.
first
.
upvote?
.
should
be_false
issue
.
upvotes
.
should
==
0
end
it
"should recognize non-+1 notes"
do
issue
.
notes
<<
create
(
:note
,
note:
"No +1 here"
)
issue
.
should
have
(
1
).
note
issue
.
notes
.
first
.
upvote?
.
should
be_false
issue
.
upvotes
.
should
==
0
end
it
"should recognize a single +1 note"
do
issue
.
notes
<<
create
(
:note
,
note:
"+1 This is awesome"
)
issue
.
upvotes
.
should
==
1
end
it
"should recognize a single +1 note"
do
issue
.
notes
<<
create
(
:note
,
note:
"+1 This is awesome"
)
issue
.
upvotes
.
should
==
1
it
"should recognize multiple +1 notes"
do
issue
.
notes
<<
create
(
:note
,
note:
"+1 This is awesome"
)
issue
.
notes
<<
create
(
:note
,
note:
"+1 I want this"
)
issue
.
upvotes
.
should
==
2
end
end
it
"should recognize multiple +1 notes"
do
issue
.
notes
<<
create
(
:note
,
note:
"+1 This is awesome"
)
issue
.
notes
<<
create
(
:note
,
note:
"+1 I want this"
)
issue
.
upvotes
.
should
==
2
describe
"#downvotes"
do
it
"with no notes has a 0/0 score"
do
issue
.
downvotes
.
should
==
0
end
it
"should recognize non--1 notes"
do
issue
.
notes
<<
create
(
:note
,
note:
"Almost got a -1"
)
issue
.
should
have
(
1
).
note
issue
.
notes
.
first
.
downvote?
.
should
be_false
issue
.
downvotes
.
should
==
0
end
it
"should recognize a single -1 note"
do
issue
.
notes
<<
create
(
:note
,
note:
"-1 This is bad"
)
issue
.
downvotes
.
should
==
1
end
it
"should recognize multiple -1 notes"
do
issue
.
notes
<<
create
(
:note
,
note:
"-1 This is bad"
)
issue
.
notes
<<
create
(
:note
,
note:
"-1 Away with this"
)
issue
.
downvotes
.
should
==
2
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