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
52b40cf4
Commit
52b40cf4
authored
Oct 21, 2015
by
wajeeha-khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MA-1359 returned resp_total for existing question and new thread
parent
2e84f826
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
1 deletions
+8
-1
api/commentables.rb
+3
-1
presenters/thread.rb
+1
-0
spec/api/commentable_spec.rb
+1
-0
spec/spec_helper.rb
+3
-0
No files found.
api/commentables.rb
View file @
52b40cf4
...
@@ -47,6 +47,8 @@ post "#{APIPREFIX}/:commentable_id/threads" do |commentable_id|
...
@@ -47,6 +47,8 @@ post "#{APIPREFIX}/:commentable_id/threads" do |commentable_id|
else
else
user
.
subscribe
(
thread
)
if
bool_auto_subscribe
user
.
subscribe
(
thread
)
if
bool_auto_subscribe
presenter
=
ThreadPresenter
.
factory
(
thread
,
nil
)
presenter
=
ThreadPresenter
.
factory
(
thread
,
nil
)
presenter
.
to_hash
.
to_json
thread
=
presenter
.
to_hash
thread
[
"resp_total"
]
=
0
thread
.
to_json
end
end
end
end
presenters/thread.rb
View file @
52b40cf4
...
@@ -51,6 +51,7 @@ class ThreadPresenter
...
@@ -51,6 +51,7 @@ class ThreadPresenter
h
[
"endorsed_responses"
]
=
endorsed_response_info
[
"responses"
]
h
[
"endorsed_responses"
]
=
endorsed_response_info
[
"responses"
]
h
[
"non_endorsed_responses"
]
=
non_endorsed_response_info
[
"responses"
]
h
[
"non_endorsed_responses"
]
=
non_endorsed_response_info
[
"responses"
]
h
[
"non_endorsed_resp_total"
]
=
non_endorsed_response_info
[
"response_count"
]
h
[
"non_endorsed_resp_total"
]
=
non_endorsed_response_info
[
"response_count"
]
h
[
"resp_total"
]
=
non_endorsed_response_info
[
"response_count"
]
+
endorsed_response_info
[
"response_count"
]
when
"discussion"
when
"discussion"
response_info
=
get_paged_merged_responses
(
@thread
.
_id
,
responses
,
resp_skip
,
resp_limit
)
response_info
=
get_paged_merged_responses
(
@thread
.
_id
,
responses
,
resp_skip
,
resp_limit
)
h
[
"children"
]
=
response_info
[
"responses"
]
h
[
"children"
]
=
response_info
[
"responses"
]
...
...
spec/api/commentable_spec.rb
View file @
52b40cf4
...
@@ -102,6 +102,7 @@ describe "app" do
...
@@ -102,6 +102,7 @@ describe "app" do
result
[
"read"
].
should
==
false
result
[
"read"
].
should
==
false
result
[
"unread_comments_count"
].
should
==
0
result
[
"unread_comments_count"
].
should
==
0
result
[
"endorsed"
].
should
==
false
result
[
"endorsed"
].
should
==
false
result
[
"resp_total"
].
should
==
0
CommentThread
.
count
.
should
==
old_count
+
1
CommentThread
.
count
.
should
==
old_count
+
1
thread
=
CommentThread
.
where
(
title:
"Interesting question"
).
first
thread
=
CommentThread
.
where
(
title:
"Interesting question"
).
first
thread
.
should_not
be_nil
thread
.
should_not
be_nil
...
...
spec/spec_helper.rb
View file @
52b40cf4
...
@@ -341,6 +341,9 @@ def check_question_response_paging(thread, hash, resp_skip=0, resp_limit=nil, is
...
@@ -341,6 +341,9 @@ def check_question_response_paging(thread, hash, resp_skip=0, resp_limit=nil, is
hash
[
"non_endorsed_responses"
].
each_with_index
do
|
response_hash
,
i
|
hash
[
"non_endorsed_responses"
].
each_with_index
do
|
response_hash
,
i
|
check_comment
(
expected_non_endorsed_responses
[
i
],
response_hash
,
is_json
)
check_comment
(
expected_non_endorsed_responses
[
i
],
response_hash
,
is_json
)
end
end
total_responses
=
endorsed_responses
.
length
+
non_endorsed_responses
.
length
hash
[
"resp_total"
].
should
==
total_responses
hash
[
"resp_skip"
].
to_i
.
should
==
resp_skip
hash
[
"resp_skip"
].
to_i
.
should
==
resp_skip
if
resp_limit
.
nil?
if
resp_limit
.
nil?
hash
[
"resp_limit"
].
should
be_nil
hash
[
"resp_limit"
].
should
be_nil
...
...
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