Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
cs_comments_service
Commits
2af135dd
Commit
2af135dd
authored
Sep 07, 2012
by
arjun810
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4 from rll/mm-endorsed
Add endoresed information for threads.
parents
95941b36
c5d51bba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
models/comment_thread.rb
+5
-0
spec/models/comment_thread_spec.rb
+24
-0
No files found.
models/comment_thread.rb
View file @
2af135dd
...
@@ -147,6 +147,10 @@ class CommentThread < Content
...
@@ -147,6 +147,10 @@ class CommentThread < Content
subscriptions
.
map
(
&
:subscriber
)
subscriptions
.
map
(
&
:subscriber
)
end
end
def
endorsed?
comments
.
where
(
endorsed:
true
).
exists?
end
def
to_hash
(
params
=
{})
def
to_hash
(
params
=
{})
doc
=
as_document
.
slice
(
*
%w[title body course_id anonymous commentable_id created_at updated_at at_position_list closed]
)
doc
=
as_document
.
slice
(
*
%w[title body course_id anonymous commentable_id created_at updated_at at_position_list closed]
)
.
merge
(
"id"
=>
_id
)
.
merge
(
"id"
=>
_id
)
...
@@ -155,6 +159,7 @@ class CommentThread < Content
...
@@ -155,6 +159,7 @@ class CommentThread < Content
.
merge
(
"votes"
=>
votes
.
slice
(
*
%w[count up_count down_count point]
))
.
merge
(
"votes"
=>
votes
.
slice
(
*
%w[count up_count down_count point]
))
.
merge
(
"tags"
=>
tags_array
)
.
merge
(
"tags"
=>
tags_array
)
.
merge
(
"type"
=>
"thread"
)
.
merge
(
"type"
=>
"thread"
)
.
merge
(
"endorsed"
=>
endorsed?
)
if
params
[
:recursive
]
if
params
[
:recursive
]
doc
=
doc
.
merge
(
"children"
=>
root_comments
.
map
{
|
c
|
c
.
to_hash
(
recursive:
true
)})
doc
=
doc
.
merge
(
"children"
=>
root_comments
.
map
{
|
c
|
c
.
to_hash
(
recursive:
true
)})
...
...
spec/models/comment_thread.rb
→
spec/models/comment_thread
_spec
.rb
View file @
2af135dd
...
@@ -20,4 +20,28 @@ describe CommentThread do
...
@@ -20,4 +20,28 @@ describe CommentThread do
CommentThread
.
tag_name_valid?
(
"_this-is-a-tag"
).
should
be_false
CommentThread
.
tag_name_valid?
(
"_this-is-a-tag"
).
should
be_false
CommentThread
.
tag_name_valid?
(
"this-is+a-tag"
).
should
be_false
CommentThread
.
tag_name_valid?
(
"this-is+a-tag"
).
should
be_false
end
end
context
"endorsed?"
do
it
"knows if it is #endorsed?"
do
thread
=
CommentThread
.
new
criteria
=
build_criteria
(
thread
,
:exists?
=>
true
)
thread
.
endorsed?
.
should
be_true
end
it
"knows when it is not #endorsed?"
do
thread
=
CommentThread
.
new
criteria
=
build_criteria
(
thread
,
:exists?
=>
false
)
thread
.
endorsed?
.
should
be_false
end
def
build_criteria
(
thread
,
options
)
double
(
"criteria"
).
tap
do
|
criteria
|
comments
=
double
(
"relation"
)
comments
.
stub
(
:where
).
with
(
endorsed:
true
).
and_return
(
criteria
)
thread
.
stub
(
:comments
).
and_return
(
comments
)
criteria
.
stub
(
options
)
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