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
ef5862be
Commit
ef5862be
authored
Jul 26, 2016
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle comment context in cases of missing parent thread.
TNL-4944
parent
f471f96d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletions
+33
-1
models/comment.rb
+8
-1
spec/models/comment_spec.rb
+25
-0
No files found.
models/comment.rb
View file @
ef5862be
...
@@ -141,7 +141,14 @@ class Comment < Content
...
@@ -141,7 +141,14 @@ class Comment < Content
end
end
def
context
def
context
self
.
comment_thread_id
?
self
.
comment_thread
.
context
:
nil
if
self
.
comment_thread_id
t
=
CommentThread
.
find
self
.
comment_thread_id
if
t
t
.
context
end
end
rescue
Mongoid
::
Errors
::
DocumentNotFound
nil
end
end
def
course_context?
def
course_context?
...
...
spec/models/comment_spec.rb
View file @
ef5862be
...
@@ -36,6 +36,14 @@ describe Comment do
...
@@ -36,6 +36,14 @@ describe Comment do
expect
(
comment
.
context
).
to
eq
(
"course"
)
expect
(
comment
.
context
).
to
eq
(
"course"
)
end
end
end
end
context
'without valid parent thread'
do
it
'returns nil'
do
comment
=
make_comment
(
author
,
course_thread
,
"comment"
)
comment
.
comment_thread_id
=
'not a thread'
expect
(
comment
.
context
).
to
eq
(
nil
)
end
end
end
end
describe
'#course_context?'
do
describe
'#course_context?'
do
...
@@ -52,6 +60,14 @@ describe Comment do
...
@@ -52,6 +60,14 @@ describe Comment do
expect
(
comment
.
course_context?
).
to
be_true
expect
(
comment
.
course_context?
).
to
be_true
end
end
end
end
context
'without valid parent thread'
do
it
'returns false'
do
comment
=
make_comment
(
author
,
course_thread
,
"comment"
)
comment
.
comment_thread_id
=
'not a thread'
expect
(
comment
.
course_context?
).
to
be_false
end
end
end
end
describe
'#standalone_context?'
do
describe
'#standalone_context?'
do
...
@@ -68,6 +84,15 @@ describe Comment do
...
@@ -68,6 +84,15 @@ describe Comment do
expect
(
comment
.
standalone_context?
).
to
be_false
expect
(
comment
.
standalone_context?
).
to
be_false
end
end
end
end
context
'without valid parent thread'
do
it
'returns false'
do
comment
=
make_comment
(
author
,
course_thread
,
"comment"
)
comment
.
comment_thread_id
=
'not a thread'
expect
(
comment
.
standalone_context?
).
to
be_false
end
end
end
end
describe
'#child_count'
do
describe
'#child_count'
do
...
...
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