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
2fb3086e
Commit
2fb3086e
authored
Dec 02, 2015
by
wajeeha-khalid
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #151 from edx/jia/MA-1742
MA-1742; return read status on GET thread for user_id provided
parents
ce416ccc
6372e2fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
api/comment_threads.rb
+5
-2
spec/api/comment_thread_spec.rb
+12
-0
No files found.
api/comment_threads.rb
View file @
2fb3086e
...
@@ -27,9 +27,12 @@ get "#{APIPREFIX}/threads/:thread_id" do |thread_id|
...
@@ -27,9 +27,12 @@ get "#{APIPREFIX}/threads/:thread_id" do |thread_id|
error
404
,
[
t
(
:requested_object_not_found
)].
to_json
error
404
,
[
t
(
:requested_object_not_found
)].
to_json
end
end
if
params
[
"user_id"
]
and
bool_mark_as_read
# user is required to return user-specific fields, such as "read" (even if bool_mark_as_read is False)
if
params
[
"user_id"
]
user
=
User
.
only
([
:id
,
:username
,
:read_states
]).
find_by
(
external_id:
params
[
"user_id"
])
user
=
User
.
only
([
:id
,
:username
,
:read_states
]).
find_by
(
external_id:
params
[
"user_id"
])
user
.
mark_as_read
(
thread
)
if
user
end
if
user
and
bool_mark_as_read
user
.
mark_as_read
(
thread
)
end
end
presenter
=
ThreadPresenter
.
factory
(
thread
,
user
||
nil
)
presenter
=
ThreadPresenter
.
factory
(
thread
,
user
||
nil
)
...
...
spec/api/comment_thread_spec.rb
View file @
2fb3086e
...
@@ -498,6 +498,18 @@ describe "app" do
...
@@ -498,6 +498,18 @@ describe "app" do
parse
(
last_response
.
body
).
first
.
should
==
I18n
.
t
(
:requested_object_not_found
)
parse
(
last_response
.
body
).
first
.
should
==
I18n
.
t
(
:requested_object_not_found
)
end
end
it
"marks thread as read and confirms its value on returned response"
do
user
=
create_test_user
(
123
)
thread
=
CommentThread
.
first
user
.
mark_as_read
(
thread
)
get
"/api/v1/threads/
#{
thread
.
id
}
"
,
user_id:
user
.
id
last_response
.
should
be_ok
json_response
=
parse
(
last_response
.
body
)
changed_thread
=
CommentThread
.
find
(
thread
.
id
)
check_thread_result_json
(
user
,
changed_thread
,
json_response
)
json_response
[
"read"
].
should
==
true
end
def
test_unicode_data
(
text
)
def
test_unicode_data
(
text
)
thread
=
make_thread
(
User
.
first
,
text
,
"unicode_course"
,
"unicode_commentable"
)
thread
=
make_thread
(
User
.
first
,
text
,
"unicode_course"
,
"unicode_commentable"
)
make_comment
(
User
.
first
,
thread
,
text
)
make_comment
(
User
.
first
,
thread
,
text
)
...
...
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