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
20349d6f
Commit
20349d6f
authored
May 22, 2015
by
Eugeny Kolpakov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #449 from open-craft/forum-thread-hotfix
Fixing various issues after birch rebase
parents
460d49d9
57f6103b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
250 additions
and
32 deletions
+250
-32
common/static/coffee/spec/discussion/discussion_router_spec.coffee
+220
-0
common/static/coffee/spec/discussion/view/new_post_view_spec.coffee
+0
-6
common/static/coffee/spec/discussion/view/thread_response_show_view_spec.coffee
+2
-2
common/templates/discussion/_course_discussion_section.html
+23
-0
common/templates/discussion/_discussion_course.html
+1
-22
common/templates/discussion/index.html
+4
-2
No files found.
common/static/coffee/spec/discussion/discussion_router_spec.coffee
0 → 100644
View file @
20349d6f
describe
'DiscussionRouter'
,
->
beforeEach
->
DiscussionSpecHelper
.
setUpGlobals
()
DiscussionSpecHelper
.
setUnderscoreFixtures
()
appendSetFixtures
(
"""
<script type="text/template" id="thread-list-template">
<div class="forum-nav-header">
<a href="#" class="forum-nav-browse" aria-haspopup="true">
<i class="icon fa fa-bars"></i>
<span class="sr">Discussion topics; current selection is: </span>
<span class="forum-nav-browse-current">All Discussions</span>
▾
</a>
<form class="forum-nav-search">
<label>
<span class="sr">Search</span>
<input class="forum-nav-search-input" type="text" placeholder="Search all posts">
<i class="icon fa fa-search"></i>
</label>
</form>
</div>
<div class="forum-nav-browse-menu-wrapper" style="display: none">
<form class="forum-nav-browse-filter">
<label>
<span class="sr">Filter Topics</span>
<input type="text" class="forum-nav-browse-filter-input" placeholder="filter topics">
</label>
</form>
<ul class="forum-nav-browse-menu">
<li class="forum-nav-browse-menu-item forum-nav-browse-menu-all">
<a href="#" class="forum-nav-browse-title">All Discussions</a>
</li>
<li class="forum-nav-browse-menu-item forum-nav-browse-menu-following">
<a href="#" class="forum-nav-browse-title"><i class="icon fa fa-star"></i>Posts I'm Following</a>
</li>
<li class="forum-nav-browse-menu-item">
<a href="#" class="forum-nav-browse-title">Parent</a>
<ul class="forum-nav-browse-submenu">
<li class="forum-nav-browse-menu-item">
<a href="#" class="forum-nav-browse-title">Target</a>
<ul class="forum-nav-browse-submenu">
<li
class="forum-nav-browse-menu-item"
data-discussion-id="child"
data-cohorted="false"
>
<a href="#" class="forum-nav-browse-title">Child</a>
</li>
</ul>
<li
class="forum-nav-browse-menu-item"
data-discussion-id="sibling"
data-cohorted="false"
>
<a href="#" class="forum-nav-browse-title">Sibling</a>
</li>
</ul>
</li>
<li
class="forum-nav-browse-menu-item"
data-discussion-id="other"
data-cohorted="true"
>
<a href="#" class="forum-nav-browse-title">Other Category</a>
</li>
</ul>
</div>
<div class="forum-nav-thread-list-wrapper">
<div class="forum-nav-refine-bar">
<label class="forum-nav-filter-main">
<select class="forum-nav-filter-main-control">
<option value="all">Show all</option>
<option value="unread">Unread</option>
<option value="unanswered">Unanswered</option>
<option value="flagged">Flagged</option>
</select>
</label>
<% if (isCohorted && isPrivilegedUser) { %>
<label class="forum-nav-filter-cohort">
<span class="sr">Cohort:</span>
<select class="forum-nav-filter-cohort-control">
<option value="">in all cohorts</option>
<option value="1">Cohort1</option>
<option value="2">Cohort2</option>
</select>
</label>
<% } %>
<label class="forum-nav-sort">
<select class="forum-nav-sort-control">
<option value="date">by recent activity</option>
<option value="comments">by most activity</option>
<option value="votes">by most votes</option>
</select>
</label>
</div>
</div>
<div class="search-alerts"></div>
<ul class="forum-nav-thread-list"></ul>
</script>
"""
)
@
threads
=
[
DiscussionViewSpecHelper
.
makeThreadWithProps
({
id
:
"1"
,
title
:
"Thread1"
,
votes
:
{
up_count
:
'20'
},
pinned
:
true
,
comments_count
:
1
,
created_at
:
'2013-04-03T20:08:39Z'
,
}),
DiscussionViewSpecHelper
.
makeThreadWithProps
({
id
:
"2"
,
title
:
"Thread2"
,
votes
:
{
up_count
:
'42'
},
comments_count
:
2
,
created_at
:
'2013-04-03T20:07:39Z'
,
}),
DiscussionViewSpecHelper
.
makeThreadWithProps
({
id
:
"3"
,
title
:
"Thread3"
,
votes
:
{
up_count
:
'12'
},
comments_count
:
3
,
created_at
:
'2013-04-03T20:06:39Z'
,
}),
DiscussionViewSpecHelper
.
makeThreadWithProps
({
id
:
"4"
,
title
:
"Thread4"
,
votes
:
{
up_count
:
'25'
},
comments_count
:
0
,
pinned
:
true
,
created_at
:
'2013-04-03T20:05:39Z'
,
}),
]
@
other_threads
=
{
'12'
:
DiscussionViewSpecHelper
.
makeThreadWithProps
({
id
:
"12"
,
title
:
"Thread12"
,
votes
:
{
up_count
:
'74'
},
comments_count
:
0
,
pinned
:
false
,
created_at
:
'2015-04-03T20:05:39Z'
,
}),
'15'
:
DiscussionViewSpecHelper
.
makeThreadWithProps
({
id
:
"15"
,
title
:
"Thread15"
,
votes
:
{
up_count
:
'92'
},
comments_count
:
0
,
pinned
:
true
,
created_at
:
'2015-05-01T19:4:03Z'
,
}),
'112'
:
DiscussionViewSpecHelper
.
makeThreadWithProps
({
id
:
"112"
,
title
:
"Thread112"
,
votes
:
{
up_count
:
'1'
},
comments_count
:
2
,
pinned
:
false
,
created_at
:
'2015-06-09T20:05:39Z'
,
})
}
spyOn
(
DiscussionUtil
,
'makeWmdEditor'
)
@
discussion
=
new
Discussion
(
_
.
map
(
@
threads
,
(
thread_spec
)
->
new
Thread
(
thread_spec
)),
{
pages
:
2
,
sort
:
'date'
})
@
course_settings
=
new
DiscussionCourseSettings
({
"category_map"
:
{
"children"
:
[
"Topic"
,
"General"
],
"entries"
:
{
"Topic"
:
{
"is_cohorted"
:
false
,
"id"
:
"topic"
},
"General"
:
{
"is_cohorted"
:
false
,
"id"
:
"general"
}
}
},
"allow_anonymous"
:
false
,
"allow_anonymous_to_peers"
:
false
,
"is_cohorted"
:
true
,
"cohorts"
:
[
{
"id"
:
1
,
"name"
:
"Cohort1"
},
{
"id"
:
2
,
"name"
:
"Cohort2"
}
]
})
@
router
=
new
DiscussionRouter
({
discussion
:
@
discussion
,
course_settings
:
@
course_settings
})
describe
'showThread'
,
->
existingCheck
=
(
thread_id
)
->
it
"shows thread
#{
thread_id
}
, which is already in threads collection"
,
->
DiscussionSpecHelper
.
makeAjaxSpy
(()
->
)
spyOn
(
@
router
,
'renderThreadView'
)
# precondition check - thread is in router's collection
expect
(
@
router
.
discussion
.
get
(
thread_id
)).
not
.
toBeUndefined
()
@
router
.
showThread
(
"irrelevant forum name"
,
thread_id
)
expect
(
$
.
ajax
).
not
.
toHaveBeenCalled
()
expect
(
@
router
.
renderThreadView
).
toHaveBeenCalled
()
expect
(
@
router
.
thread
.
id
).
toBe
(
thread_id
)
missingCheck
=
(
forum_name
,
thread_id
)
->
it
"requests thread
#{
thread_id
}
in forum
#{
forum_name
}
if not already in collection"
,
->
DiscussionSpecHelper
.
makeAjaxSpy
(
(
params
)
=>
expect
(
params
.
url
.
path
()).
toBe
(
DiscussionUtil
.
urlFor
(
'retrieve_single_thread'
,
forum_name
,
thread_id
))
params
.
success
({
content
:
@
other_threads
[
thread_id
]})
)
spyOn
(
@
router
,
'renderThreadView'
)
# precondition check - thread is not in router's collection
expect
(
@
router
.
discussion
.
get
(
thread_id
)).
toBeUndefined
()
@
router
.
showThread
(
forum_name
,
thread_id
)
expect
(
@
router
.
renderThreadView
).
toHaveBeenCalled
()
expect
(
@
router
.
thread
.
id
).
toBe
(
thread_id
)
existingCheck
(
'1'
)
existingCheck
(
'2'
)
existingCheck
(
'3'
)
existingCheck
(
'4'
)
missingCheck
(
'forum1'
,
'12'
)
missingCheck
(
'forum2'
,
'15'
)
missingCheck
(
'forum3'
,
'112'
)
common/static/coffee/spec/discussion/view/new_post_view_spec.coffee
View file @
20349d6f
...
...
@@ -226,12 +226,6 @@ describe "NewPostView", ->
mode
:
"tab"
)
checkVisibility
=
(
view
,
expectedVisible
)
=>
view
.
render
()
expect
(
view
.
$
(
".js-group-select"
).
is
(
":visible"
)).
toEqual
(
expectedVisible
)
if
expectedVisible
expect
(
view
.
$
(
".js-group-select"
).
prop
(
"disabled"
)).
toEqual
(
false
)
it
"is not visible to students"
,
->
checkVisibility
(
@
view
,
false
)
...
...
common/static/coffee/spec/discussion/view/thread_response_show_view_spec.coffee
View file @
20349d6f
...
...
@@ -57,7 +57,7 @@ describe "ThreadResponseShowView", ->
expect
(
@
view
.
$
(
".posted-details"
).
text
().
replace
(
/\s+/g
,
" "
)).
toMatch
(
"marked as answer less than a minute ago by "
+
endorsement
.
username
)
expect
(
@
view
.
$
(
".posted-details
>
a"
).
attr
(
'href'
)).
toEqual
(
"/courses/edX/999/test/discussion/forum/users/test_id"
)
expect
(
@
view
.
$
(
".posted-details a"
).
attr
(
'href'
)).
toEqual
(
"/courses/edX/999/test/discussion/forum/users/test_id"
)
it
"renders anonymous endorsement correctly for a marked answer in a question thread"
,
->
endorsement
=
{
...
...
@@ -88,7 +88,7 @@ describe "ThreadResponseShowView", ->
expect
(
@
view
.
$
(
".posted-details"
).
text
().
replace
(
/\s+/g
,
" "
)).
toMatch
(
"endorsed less than a minute ago by "
+
endorsement
.
username
)
expect
(
@
view
.
$
(
".posted-details
>
a"
).
attr
(
'href'
)).
toEqual
(
"/courses/edX/999/test/discussion/forum/users/test_id"
)
expect
(
@
view
.
$
(
".posted-details a"
).
attr
(
'href'
)).
toEqual
(
"/courses/edX/999/test/discussion/forum/users/test_id"
)
it
"renders anonymous endorsement correctly for an endorsed response in a discussion thread"
,
->
endorsement
=
{
...
...
common/templates/discussion/_course_discussion_section.html
0 → 100644
View file @
20349d6f
<section
class=
"discussion container"
id=
"discussion-container"
data-roles=
"${roles}"
data-course-id=
"${course_id}"
data-user-info=
"${user_info}"
data-threads=
"${threads}"
data-thread-pages=
"${thread_pages}"
data-content-info=
"${annotated_content_info}"
data-sort-preference=
"${sort_preference}"
data-flag-moderator=
"${flag_moderator}"
data-user-cohort-id=
"${user_cohort}"
data-course-settings=
"${course_settings}"
>
<div
class=
"discussion-body"
>
<div
class=
"forum-nav"
></div>
<div
class=
"discussion-column"
>
<article
class=
"new-post-article"
style=
"display: none"
></article>
<div
class=
"forum-content"
></div>
</div>
</div>
</section>
<
%
include
file=
"_underscore_templates.html"
/>
<
%
include
file=
"_thread_list_template.html"
/>
\ No newline at end of file
common/templates/discussion/_discussion_course.html
View file @
20349d6f
...
...
@@ -21,27 +21,6 @@
<div
style=
"display: block; clear: both; height: 1px;"
></div>
% endif
<section
class=
"discussion container"
id=
"discussion-container"
data-roles=
"${roles}"
data-course-id=
"${course_id}"
data-user-info=
"${user_info}"
data-threads=
"${threads}"
data-thread-pages=
"${thread_pages}"
data-content-info=
"${annotated_content_info}"
data-sort-preference=
"${sort_preference}"
data-flag-moderator=
"${flag_moderator}"
data-user-cohort-id=
"${user_cohort}"
data-course-settings=
"${course_settings}"
>
<div
class=
"discussion-body"
>
<div
class=
"forum-nav"
></div>
<div
class=
"discussion-column"
>
<article
class=
"new-post-article"
style=
"display: none"
></article>
<div
class=
"forum-content"
></div>
</div>
</div>
</section>
<
%
include
file=
"_underscore_templates.html"
/>
<
%
include
file=
"_thread_list_template.html"
/>
<
%
include
file=
"_course_discussion_section.html"
/>
</div>
common/templates/discussion/index.html
View file @
20349d6f
...
...
@@ -12,10 +12,12 @@
<
%
block
name=
"headextra"
>
<
%
static:css
group=
'style-course-vendor'
/>
<
%
static:css
group=
'style-course'
/>
<
%
include
file=
"_js_head_dependencies.html"
/>
</
%
block>
<
%
block
name=
"js_extra"
>
<
%
include
file=
"
/discussion/
_js_body_dependencies.html"
/>
<
%
include
file=
"_js_body_dependencies.html"
/>
<
%
static:js
group=
'discussion'
/>
<script
language=
"javascript"
>
$
(
function
()
{
...
...
@@ -28,4 +30,4 @@
<
%
include
file=
"_discussion_course_navigation.html"
args=
"active_page='discussion'"
/>
<
%
include
file=
"
/discussion/_discussion_course
.html"
/>
<
%
include
file=
"
_course_discussion_section
.html"
/>
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