Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
298ad30a
Commit
298ad30a
authored
Sep 24, 2014
by
Waqas Khalid
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5142 from mlkwaqas/waqas/tnl150-stop-comment--on-closed-thread
Don't allow commenting while the thread is closed
parents
aa5781c1
fcf46546
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
2 deletions
+60
-2
common/static/coffee/spec/discussion/view/discussion_thread_view_spec.coffee
+26
-0
common/static/coffee/spec/discussion/view/thread_response_view_spec.coffee
+31
-2
common/static/coffee/src/discussion/views/discussion_thread_view.coffee
+1
-0
common/static/coffee/src/discussion/views/thread_response_view.coffee
+2
-0
No files found.
common/static/coffee/spec/discussion/view/discussion_thread_view_spec.coffee
View file @
298ad30a
...
@@ -40,6 +40,32 @@ describe "DiscussionThreadView", ->
...
@@ -40,6 +40,32 @@ describe "DiscussionThreadView", ->
else
else
expect
(
view
.
$el
.
find
(
".load-response-button"
).
length
).
toEqual
(
0
)
expect
(
view
.
$el
.
find
(
".load-response-button"
).
length
).
toEqual
(
0
)
describe
"closed and open Threads"
,
->
checkCommentForm
=
(
originallyClosed
,
mode
)
->
threadData
=
DiscussionViewSpecHelper
.
makeThreadWithProps
({
closed
:
originallyClosed
})
thread
=
new
Thread
(
threadData
)
view
=
new
DiscussionThreadView
({
model
:
thread
,
el
:
$
(
"#fixture-element"
),
mode
:
mode
})
renderWithContent
(
view
,
{
resp_total
:
1
,
children
:
[{}]})
if
mode
==
"inline"
view
.
expand
()
spyOn
(
DiscussionUtil
,
"updateWithUndo"
).
andCallFake
(
(
model
,
updates
,
safeAjaxParams
,
errorMsg
)
->
model
.
set
(
updates
)
)
expect
(
view
.
$
(
'.comment-form'
).
closest
(
'li'
).
is
(
":visible"
)).
toBe
(
not
originallyClosed
)
expect
(
view
.
$
(
".discussion-reply-new"
).
is
(
":visible"
)).
toBe
(
not
originallyClosed
)
view
.
$
(
".action-close"
).
click
()
expect
(
view
.
$
(
'.comment-form'
).
closest
(
'li'
).
is
(
":visible"
)).
toBe
(
originallyClosed
)
expect
(
view
.
$
(
".discussion-reply-new"
).
is
(
":visible"
)).
toBe
(
originallyClosed
)
_
.
each
([
"tab"
,
"inline"
],
(
mode
)
=>
it
'Test that in #{mode} mode when a closed thread is opened the comment form is displayed'
,
->
checkCommentForm
(
true
,
mode
)
it
'Test that in #{mode} mode when a open thread is closed the comment form is hidden'
,
->
checkCommentForm
(
false
,
mode
)
)
describe
"tab mode"
,
->
describe
"tab mode"
,
->
beforeEach
->
beforeEach
->
@
view
=
new
DiscussionThreadView
({
model
:
@
thread
,
el
:
$
(
"#fixture-element"
),
mode
:
"tab"
})
@
view
=
new
DiscussionThreadView
({
model
:
@
thread
,
el
:
$
(
"#fixture-element"
),
mode
:
"tab"
})
...
...
common/static/coffee/spec/discussion/view/thread_response_view_spec.coffee
View file @
298ad30a
...
@@ -3,13 +3,42 @@ describe 'ThreadResponseView', ->
...
@@ -3,13 +3,42 @@ describe 'ThreadResponseView', ->
DiscussionSpecHelper
.
setUpGlobals
()
DiscussionSpecHelper
.
setUpGlobals
()
DiscussionSpecHelper
.
setUnderscoreFixtures
()
DiscussionSpecHelper
.
setUnderscoreFixtures
()
@
thread
=
new
Thread
({
"thread_type"
:
"discussion"
})
@
response
=
new
Comment
{
@
response
=
new
Comment
{
children
:
[{},
{}]
children
:
[{},
{}],
thread
:
@
thread
,
}
}
@
view
=
new
ThreadResponseView
({
model
:
@
response
,
el
:
$
(
"#fixture-element"
)})
@
view
=
new
ThreadResponseView
({
model
:
@
response
,
el
:
$
(
"#fixture-element"
)})
spyOn
(
ThreadResponseShowView
.
prototype
,
"render"
)
spyOn
(
ThreadResponseShowView
.
prototype
,
"render"
)
spyOn
(
ResponseCommentView
.
prototype
,
"render"
)
spyOn
(
ResponseCommentView
.
prototype
,
"render"
)
describe
'closed and open Threads'
,
->
checkCommentForm
=
(
closed
)
->
thread
=
new
Thread
({
"thread_type"
:
"discussion"
,
"closed"
:
closed
})
commentData
=
{
id
:
"dummy"
,
user_id
:
"567"
,
course_id
:
"TestOrg/TestCourse/TestRun"
,
body
:
"this is a comment"
,
created_at
:
"2013-04-03T20:08:39Z"
,
abuse_flaggers
:
[],
type
:
"comment"
,
children
:
[],
thread
:
thread
,
}
comment
=
new
Comment
(
commentData
)
view
=
new
ThreadResponseView
({
model
:
comment
,
el
:
$
(
"#fixture-element"
),
})
view
.
render
()
expect
(
view
.
$
(
'.comment-form'
).
closest
(
'li'
).
is
(
":visible"
)).
toBe
(
not
closed
)
it
'hides comment form when thread is closed'
,
->
checkCommentForm
(
true
)
it
'show comment form when thread is open'
,
->
checkCommentForm
(
false
)
describe
'renderComments'
,
->
describe
'renderComments'
,
->
it
'hides "show comments" link if collapseComments is not set'
,
->
it
'hides "show comments" link if collapseComments is not set'
,
->
@
view
.
render
()
@
view
.
render
()
...
@@ -17,7 +46,7 @@ describe 'ThreadResponseView', ->
...
@@ -17,7 +46,7 @@ describe 'ThreadResponseView', ->
expect
(
@
view
.
$
(
".action-show-comments"
)).
not
.
toBeVisible
()
expect
(
@
view
.
$
(
".action-show-comments"
)).
not
.
toBeVisible
()
it
'hides "show comments" link if collapseComments is set but response has no comments'
,
->
it
'hides "show comments" link if collapseComments is set but response has no comments'
,
->
@
response
=
new
Comment
{
children
:
[]
}
@
response
=
new
Comment
{
children
:
[]
,
thread
:
@
thread
}
@
view
=
new
ThreadResponseView
({
@
view
=
new
ThreadResponseView
({
model
:
@
response
,
el
:
$
(
"#fixture-element"
),
model
:
@
response
,
el
:
$
(
"#fixture-element"
),
collapseComments
:
true
collapseComments
:
true
...
...
common/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
298ad30a
...
@@ -55,6 +55,7 @@ if Backbone?
...
@@ -55,6 +55,7 @@ if Backbone?
attrRenderer
:
$
.
extend
({},
DiscussionContentView
.
prototype
.
attrRenderer
,
{
attrRenderer
:
$
.
extend
({},
DiscussionContentView
.
prototype
.
attrRenderer
,
{
closed
:
(
closed
)
->
closed
:
(
closed
)
->
@
$
(
".discussion-reply-new"
).
toggle
(
not
closed
)
@
$
(
".discussion-reply-new"
).
toggle
(
not
closed
)
@
$
(
'.comment-form'
).
closest
(
'li'
).
toggle
(
not
closed
)
@
renderAddResponseButton
()
@
renderAddResponseButton
()
})
})
...
...
common/static/coffee/src/discussion/views/thread_response_view.coffee
View file @
298ad30a
...
@@ -28,6 +28,8 @@ if Backbone?
...
@@ -28,6 +28,8 @@ if Backbone?
@
renderShowView
()
@
renderShowView
()
@
renderAttrs
()
@
renderAttrs
()
if
@
model
.
get
(
"thread"
).
get
(
"closed"
)
@
hideCommentForm
()
@
renderComments
()
@
renderComments
()
@
@
...
...
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