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
e7e0fd8c
Commit
e7e0fd8c
authored
Jun 27, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added spec & fixed bug
parent
0bf762e5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
models/comment.rb
+2
-2
spec/app_spec.rb
+24
-0
No files found.
models/comment.rb
View file @
e7e0fd8c
...
@@ -12,8 +12,8 @@ class Comment < ActiveRecord::Base
...
@@ -12,8 +12,8 @@ class Comment < ActiveRecord::Base
acts_as_voteable
acts_as_voteable
validates_presence_of
:title
,
:unless
=>
Proc
.
new
{
|
c
|
c
.
is_root?
or
c
.
body
}
validates_presence_of
:title
,
:unless
=>
Proc
.
new
{
|
c
|
c
.
is_root?
or
not
c
.
body
.
blank?
}
validates_presence_of
:body
,
:unless
=>
Proc
.
new
{
|
c
|
c
.
is_root?
or
c
.
title
}
validates_presence_of
:body
,
:unless
=>
Proc
.
new
{
|
c
|
c
.
is_root?
or
not
c
.
title
.
blank?
}
validates_presence_of
:user_id
,
:unless
=>
:is_root?
validates_presence_of
:user_id
,
:unless
=>
:is_root?
validates_presence_of
:course_id
,
:unless
=>
:is_root?
validates_presence_of
:course_id
,
:unless
=>
:is_root?
validates_presence_of
:comment_thread_id
validates_presence_of
:comment_thread_id
...
...
spec/app_spec.rb
View file @
e7e0fd8c
...
@@ -18,6 +18,30 @@ describe "app" do
...
@@ -18,6 +18,30 @@ describe "app" do
comment
.
user_id
.
should
==
1
comment
.
user_id
.
should
==
1
comment
.
user_id
.
should
==
1
comment
.
user_id
.
should
==
1
end
end
it
"should create a top-level comment with only title"
do
post
"/api/v1/commentables/questions/1/comments"
,
:body
=>
""
,
:title
=>
"comment title"
,
:user_id
=>
1
,
:course_id
=>
1
last_response
.
should
be_ok
comment
=
CommentThread
.
first
.
root_comments
.
first
comment
.
should_not
be_nil
comment
.
body
.
should
==
""
comment
.
title
.
should
==
"comment title"
comment
.
user_id
.
should
==
1
comment
.
user_id
.
should
==
1
end
it
"should create a top-level comment with only body"
do
post
"/api/v1/commentables/questions/1/comments"
,
:body
=>
"comment body"
,
:title
=>
""
,
:user_id
=>
1
,
:course_id
=>
1
last_response
.
should
be_ok
comment
=
CommentThread
.
first
.
root_comments
.
first
comment
.
should_not
be_nil
comment
.
body
.
should
==
"comment body"
comment
.
title
.
should
==
""
comment
.
user_id
.
should
==
1
comment
.
user_id
.
should
==
1
end
it
"should not create a top-level comment with neither title nor body"
do
post
"/api/v1/commentables/questions/1/comments"
,
:body
=>
""
,
:title
=>
""
,
:user_id
=>
1
,
:course_id
=>
1
last_response
.
status
.
should
==
400
end
end
end
describe
"POST on /api/v1/comments/:comment_id"
do
describe
"POST on /api/v1/comments/:comment_id"
do
before
:each
do
before
:each
do
...
...
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