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
6372e2fb
Commit
6372e2fb
authored
Nov 30, 2015
by
wajeeha-khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MA-1742; return read status on GET thread for user_id provided
parent
ce416ccc
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 @
6372e2fb
...
...
@@ -27,9 +27,12 @@ get "#{APIPREFIX}/threads/:thread_id" do |thread_id|
error
404
,
[
t
(
:requested_object_not_found
)].
to_json
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
.
mark_as_read
(
thread
)
if
user
end
if
user
and
bool_mark_as_read
user
.
mark_as_read
(
thread
)
end
presenter
=
ThreadPresenter
.
factory
(
thread
,
user
||
nil
)
...
...
spec/api/comment_thread_spec.rb
View file @
6372e2fb
...
...
@@ -498,6 +498,18 @@ describe "app" do
parse
(
last_response
.
body
).
first
.
should
==
I18n
.
t
(
:requested_object_not_found
)
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
)
thread
=
make_thread
(
User
.
first
,
text
,
"unicode_course"
,
"unicode_commentable"
)
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