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
e4806b0d
Commit
e4806b0d
authored
Jul 26, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
separated out specs
parent
35221024
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
0 deletions
+116
-0
spec/app_spec.rb
+0
-0
spec/spec_helper.rb
+116
-0
No files found.
spec/app_spec.rb
deleted
100644 → 0
View file @
35221024
This diff is collapsed.
Click to expand it.
spec/spec_helper.rb
View file @
e4806b0d
...
...
@@ -19,3 +19,119 @@ end
RSpec
.
configure
do
|
config
|
config
.
include
Rack
::
Test
::
Methods
end
def
parse
(
text
)
Yajl
::
Parser
.
parse
text
end
def
init_without_subscriptions
Comment
.
delete_all
CommentThread
.
delete_all
User
.
delete_all
Notification
.
delete_all
Subscription
.
delete_all
commentable
=
Commentable
.
new
(
"question_1"
)
user
=
User
.
create!
(
external_id:
"1"
)
thread
=
CommentThread
.
new
(
title:
"I can't solve this problem"
,
body:
"can anyone help me?"
,
course_id:
"1"
,
commentable_id:
commentable
.
id
)
thread
.
author
=
user
thread
.
save!
user
.
subscribe
(
thread
)
comment
=
thread
.
comments
.
new
(
body:
"this problem is so easy"
,
course_id:
"1"
)
comment
.
author
=
user
comment
.
save!
comment1
=
comment
.
children
.
new
(
body:
"not for me!"
,
course_id:
"1"
)
comment1
.
author
=
user
comment1
.
comment_thread
=
thread
comment1
.
save!
comment2
=
comment1
.
children
.
new
(
body:
"not for me neither!"
,
course_id:
"1"
)
comment2
.
author
=
user
comment2
.
comment_thread
=
thread
comment2
.
save!
comment
=
thread
.
comments
.
new
(
body:
"see the textbook on page 69. it's quite similar"
,
course_id:
"1"
)
comment
.
author
=
user
comment
.
save!
comment1
=
comment
.
children
.
new
(
body:
"thank you!"
,
course_id:
"1"
)
comment1
.
author
=
user
comment1
.
comment_thread
=
thread
comment1
.
save!
thread
=
CommentThread
.
new
(
title:
"This problem is wrong"
,
body:
"it is unsolvable"
,
course_id:
"2"
,
commentable_id:
commentable
.
id
)
thread
.
author
=
user
thread
.
save!
user
.
subscribe
(
thread
)
comment
=
thread
.
comments
.
new
(
body:
"how do you know?"
,
course_id:
"1"
)
comment
.
author
=
user
comment
.
save!
comment1
=
comment
.
children
.
new
(
body:
"because blablabla"
,
course_id:
"1"
)
comment1
.
author
=
user
comment1
.
comment_thread
=
thread
comment1
.
save!
comment
=
thread
.
comments
.
new
(
body:
"no wonder I can't solve it"
,
course_id:
"1"
)
comment
.
author
=
user
comment
.
save!
comment1
=
comment
.
children
.
new
(
body:
"+1"
,
course_id:
"1"
)
comment1
.
author
=
user
comment1
.
comment_thread
=
thread
comment1
.
save!
users
=
(
2
..
10
).
map
{
|
id
|
User
.
find_or_create_by
(
external_id:
id
.
to_s
)}
Comment
.
all
.
each
do
|
c
|
user
.
vote
(
c
,
:up
)
# make the first user always vote up for convenience
users
.
each
{
|
user
|
user
.
vote
(
c
,
[
:up
,
:down
].
sample
)}
end
CommentThread
.
all
.
each
do
|
c
|
user
.
vote
(
c
,
:up
)
# make the first user always vote up for convenience
users
.
each
{
|
user
|
user
.
vote
(
c
,
[
:up
,
:down
].
sample
)}
end
end
def
init_with_subscriptions
Comment
.
delete_all
CommentThread
.
delete_all
User
.
delete_all
Notification
.
delete_all
Subscription
.
delete_all
user1
=
User
.
create!
(
external_id:
"1"
)
user2
=
User
.
create!
(
external_id:
"2"
)
user2
.
subscribe
(
user1
)
commentable
=
Commentable
.
new
(
"question_1"
)
user1
.
subscribe
(
commentable
)
user2
.
subscribe
(
commentable
)
thread
=
CommentThread
.
new
(
title:
"I can't solve this problem"
,
body:
"can anyone help me?"
,
course_id:
"1"
,
commentable_id:
commentable
.
id
)
thread
.
author
=
user1
user1
.
subscribe
(
thread
)
user2
.
subscribe
(
thread
)
thread
.
save!
thread
=
thread
.
reload
comment
=
thread
.
comments
.
new
(
body:
"this problem is so easy"
,
course_id:
"1"
)
comment
.
author
=
user2
comment
.
save!
comment1
=
comment
.
children
.
new
(
body:
"not for me!"
,
course_id:
"1"
)
comment1
.
author
=
user1
comment1
.
comment_thread
=
thread
comment1
.
save!
comment2
=
comment1
.
children
.
new
(
body:
"not for me neither!"
,
course_id:
"1"
)
comment2
.
author
=
user2
comment2
.
comment_thread
=
thread
comment2
.
save!
thread
=
CommentThread
.
new
(
title:
"This problem is wrong"
,
body:
"it is unsolvable"
,
course_id:
"2"
,
commentable_id:
commentable
.
id
)
thread
.
author
=
user2
user2
.
subscribe
(
thread
)
thread
.
save!
end
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