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
8f490810
Commit
8f490810
authored
Sep 13, 2016
by
Robert Raposa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix respec tests.
parent
1f26217d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
spec/api/comment_thread_spec.rb
+21
-21
No files found.
spec/api/comment_thread_spec.rb
View file @
8f490810
...
...
@@ -25,7 +25,7 @@ describe "app" do
rs
=
thread_result
course_id:
"abc"
rs
.
length
.
should
==
2
rs
.
each_with_index
{
|
res
,
i
|
check_thread_result_json
(
nil
,
@threads
[
"t
#{
i
+
1
}
"
],
res
)
check_thread_result_json
(
nil
,
@threads
[
"t
#{
2
-
i
}
"
],
res
)
res
[
"course_id"
].
should
==
"abc"
}
end
...
...
@@ -38,8 +38,8 @@ describe "app" do
@threads
[
"t2"
].
save!
rs
=
thread_result
course_id:
"abc"
rs
.
length
.
should
==
2
check_thread_result_json
(
nil
,
@threads
[
"t
1
"
],
rs
[
0
])
check_thread_result_json
(
nil
,
@threads
[
"t
3
"
],
rs
[
1
])
check_thread_result_json
(
nil
,
@threads
[
"t
3
"
],
rs
[
0
])
check_thread_result_json
(
nil
,
@threads
[
"t
1
"
],
rs
[
1
])
end
it
"returns only threads where course id and commentable id match"
do
@threads
[
"t1"
].
course_id
=
"course1"
...
...
@@ -91,7 +91,7 @@ describe "app" do
rs
=
thread_result
course_id:
"omg"
,
group_id:
100
rs
.
length
.
should
==
2
rs
.
each_with_index
{
|
res
,
i
|
check_thread_result_json
(
nil
,
@threads
[
"t
#{
i
+
1
}
"
],
res
)
check_thread_result_json
(
nil
,
@threads
[
"t
#{
2
-
i
}
"
],
res
)
res
[
"course_id"
].
should
==
"omg"
}
end
...
...
@@ -187,7 +187,7 @@ describe "app" do
rs
=
thread_result
course_id:
"abc"
,
user_id:
"123"
rs
.
length
.
should
==
2
rs
.
each_with_index
{
|
result
,
i
|
check_thread_result_json
(
user
,
@threads
[
"t
#{
i
+
1
}
"
],
result
)
check_thread_result_json
(
user
,
@threads
[
"t
#{
2
-
i
}
"
],
result
)
result
[
"course_id"
].
should
==
"abc"
result
[
"unread_comments_count"
].
should
==
5
result
[
"read"
].
should
==
false
...
...
@@ -197,34 +197,34 @@ describe "app" do
rs
=
thread_result
course_id:
"abc"
,
user_id:
"123"
rs
.
length
.
should
==
2
rs
.
each_with_index
{
|
result
,
i
|
check_thread_result_json
(
user
,
@threads
[
"t
#{
i
+
1
}
"
],
result
)
check_thread_result_json
(
user
,
@threads
[
"t
#{
2
-
i
}
"
],
result
)
}
rs
[
0
][
"read"
].
should
==
true
rs
[
0
][
"unread_comments_count"
].
should
==
0
rs
[
1
][
"read"
].
should
==
false
rs
[
1
][
"unread_comments_count"
].
should
==
5
rs
[
1
][
"read"
].
should
==
true
rs
[
1
][
"unread_comments_count"
].
should
==
0
rs
[
0
][
"read"
].
should
==
false
rs
[
0
][
"unread_comments_count"
].
should
==
5
@threads
[
"t1"
].
updated_at
+=
1
# 1 second later
@threads
[
"t1"
].
save!
rs
=
thread_result
course_id:
"abc"
,
user_id:
"123"
rs
.
length
.
should
==
2
rs
.
each_with_index
{
|
result
,
i
|
check_thread_result_json
(
user
,
@threads
[
"t
#{
i
+
1
}
"
],
result
)
check_thread_result_json
(
user
,
@threads
[
"t
#{
2
-
i
}
"
],
result
)
}
rs
[
0
][
"read"
].
should
==
true
rs
[
0
][
"unread_comments_count"
].
should
==
0
rs
[
1
][
"read"
].
should
==
false
rs
[
1
][
"unread_comments_count"
].
should
==
5
rs
[
1
][
"read"
].
should
==
true
rs
[
1
][
"unread_comments_count"
].
should
==
0
rs
[
0
][
"read"
].
should
==
false
rs
[
0
][
"unread_comments_count"
].
should
==
5
# author's own posts should not count as unread
make_comment
(
user
,
@threads
[
"t1"
],
"my two cents"
)
rs
=
thread_result
course_id:
"abc"
,
user_id:
"123"
rs
[
0
][
"unread_comments_count"
].
should
==
0
rs
[
1
][
"unread_comments_count"
].
should
==
0
# other's posts do, though
make_comment
(
@threads
[
"t1"
].
author
,
@threads
[
"t1"
],
"the last word"
)
rs
=
thread_result
course_id:
"abc"
,
user_id:
"123"
rs
[
0
][
"unread_comments_count"
].
should
==
1
rs
[
1
][
"unread_comments_count"
].
should
==
1
end
context
"sorting"
do
...
...
@@ -300,14 +300,14 @@ describe "app" do
@threads
[
"t7"
].
save!
actual_order
=
thread_result_order
(
"comments"
)
expected_order
=
move_to_front
(
move_to_front
(
@default_order
,
"t5"
),
"t7
"
)
expected_order
=
move_to_front
(
@default_order
,
"t7"
,
"t5
"
)
actual_order
.
should
==
expected_order
@threads
[
"t8"
].
pinned
=
true
@threads
[
"t8"
].
save!
actual_order
=
thread_result_order
(
"comments"
)
expected_order
=
move_to_
end
(
move_to_front
(
@default_order
,
"t5"
),
"t8"
,
"t7
"
)
expected_order
=
move_to_
front
(
@default_order
,
"t8"
,
"t7"
,
"t5
"
)
actual_order
.
should
==
expected_order
actual_order
=
thread_result_order
(
"date"
)
...
...
@@ -391,7 +391,7 @@ describe "app" do
make_comment
(
@threads
[
"t5"
].
author
,
@threads
[
"t5"
],
"extra comment"
)
@threads
[
"t7"
].
pinned
=
true
@threads
[
"t7"
].
save!
expected_order
=
move_to_
end
(
move_to_front
(
@default_order
,
"t5"
),
"t7
"
)
expected_order
=
move_to_
front
(
@default_order
,
"t7"
,
"t5
"
)
test_paged_order
({
'sort_key'
=>
'comments'
,
'per_page'
=>
3
},
expected_order
)
end
...
...
@@ -402,7 +402,7 @@ describe "app" do
make_comment
(
@threads
[
"t5"
].
author
,
@threads
[
"t5"
],
"extra comment"
)
@threads
[
"t7"
].
pinned
=
true
@threads
[
"t7"
].
save!
expected_order
=
move_to_
end
(
move_to_front
(
@default_order
[
1
..
8
],
"t5"
),
"t7
"
)
expected_order
=
move_to_
front
(
@default_order
[
1
..
8
],
"t7"
,
"t5
"
)
test_paged_order
(
{
'sort_key'
=>
'comments'
,
'per_page'
=>
3
},
expected_order
,
...
...
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