TNL-3818: fixed recent activity mapping in thread-list sort for Forums Web
This commit is contained in:
@@ -88,7 +88,7 @@ describe "DiscussionThreadListView", ->
|
||||
<% } %>
|
||||
<label class="forum-nav-sort">
|
||||
<select class="forum-nav-sort-control">
|
||||
<option value="date">by recent activity</option>
|
||||
<option value="activity">by recent activity</option>
|
||||
<option value="comments">by most activity</option>
|
||||
<option value="votes">by most votes</option>
|
||||
</select>
|
||||
@@ -232,8 +232,8 @@ describe "DiscussionThreadListView", ->
|
||||
)
|
||||
).toEqual(["+25 votes", "+20 votes", "+42 votes", "+12 votes"])
|
||||
|
||||
it "with sort preference date", ->
|
||||
checkRender(@threads, "date", ["Thread1", "Thread4", "Thread2", "Thread3"])
|
||||
it "with sort preference activity", ->
|
||||
checkRender(@threads, "activity", ["Thread1", "Thread2", "Thread3", "Thread4"])
|
||||
|
||||
it "with sort preference votes", ->
|
||||
checkRender(@threads, "votes", ["Thread4", "Thread1", "Thread2", "Thread3"])
|
||||
@@ -249,7 +249,7 @@ describe "DiscussionThreadListView", ->
|
||||
sortControl = view.$el.find(".forum-nav-sort-control")
|
||||
expect(sortControl.val()).toEqual(selected_type)
|
||||
sorted_threads = []
|
||||
if new_type == 'date'
|
||||
if new_type == 'activity'
|
||||
sorted_threads = [threads[0], threads[3], threads[1], threads[2]]
|
||||
else if new_type == 'comments'
|
||||
sorted_threads = [threads[0], threads[3], threads[2], threads[1]]
|
||||
@@ -265,11 +265,11 @@ describe "DiscussionThreadListView", ->
|
||||
expect($.ajax).toHaveBeenCalled()
|
||||
checkThreadsOrdering(view, sort_order, new_type)
|
||||
|
||||
it "with sort preference date", ->
|
||||
changeSorting(@threads, "comments", "date", ["Thread1", "Thread4", "Thread2", "Thread3"])
|
||||
it "with sort preference activity", ->
|
||||
changeSorting(@threads, "comments", "activity", ["Thread1", "Thread4", "Thread3", "Thread2"])
|
||||
|
||||
it "with sort preference votes", ->
|
||||
changeSorting(@threads, "date", "votes", ["Thread4", "Thread1", "Thread2", "Thread3"])
|
||||
changeSorting(@threads, "activity", "votes", ["Thread4", "Thread1", "Thread2", "Thread3"])
|
||||
|
||||
it "with sort preference comments", ->
|
||||
changeSorting(@threads, "votes", "comments", ["Thread1", "Thread4", "Thread3", "Thread2"])
|
||||
|
||||
@@ -20,7 +20,7 @@ if Backbone?
|
||||
|
||||
setSortComparator: (sortBy) ->
|
||||
switch sortBy
|
||||
when 'date' then @comparator = @sortByDateRecentFirst
|
||||
when 'activity' then @comparator = @sortByDateRecentFirst
|
||||
when 'votes' then @comparator = @sortByVotes
|
||||
when 'comments' then @comparator = @sortByComments
|
||||
|
||||
@@ -49,7 +49,7 @@ if Backbone?
|
||||
url = DiscussionUtil.urlFor 'followed_threads', options.user_id
|
||||
if options['group_id']
|
||||
data['group_id'] = options['group_id']
|
||||
data['sort_key'] = sort_options.sort_key || 'date'
|
||||
data['sort_key'] = sort_options.sort_key || 'activity'
|
||||
data['sort_order'] = sort_options.sort_order || 'desc'
|
||||
DiscussionUtil.safeAjax
|
||||
$elem: @$el
|
||||
@@ -117,8 +117,9 @@ if Backbone?
|
||||
|
||||
pinnedThreadsSortComparatorWithDate: (thread, ascending)->
|
||||
# if threads are pinned they should be displayed on top.
|
||||
# Unpinned will be sorted by their date
|
||||
# Unpinned will be sorted by their last activity date
|
||||
threadCreatedTime = new Date(thread.get("created_at")).getTime()
|
||||
threadCreatedTime = new Date(thread.get("last_activity_at")).getTime()
|
||||
if thread.get('pinned')
|
||||
#use tomorrow's date
|
||||
today = new Date();
|
||||
|
||||
@@ -161,7 +161,7 @@ if Backbone?
|
||||
voteCounts.hide()
|
||||
commentCounts.hide()
|
||||
switch @$(".forum-nav-sort-control").val()
|
||||
when "date", "comments"
|
||||
when "activity", "comments"
|
||||
commentCounts.show()
|
||||
when "votes"
|
||||
voteCounts.show()
|
||||
|
||||
@@ -1121,14 +1121,14 @@ class DiscussionSortPreferenceTest(UniqueCourseTest):
|
||||
Test to check the default sorting preference of user. (Default = date )
|
||||
"""
|
||||
selected_sort = self.sort_page.get_selected_sort_preference()
|
||||
self.assertEqual(selected_sort, "date")
|
||||
self.assertEqual(selected_sort, "activity")
|
||||
|
||||
def test_change_sort_preference(self):
|
||||
"""
|
||||
Test that if user sorting preference is changing properly.
|
||||
"""
|
||||
selected_sort = ""
|
||||
for sort_type in ["votes", "comments", "date"]:
|
||||
for sort_type in ["votes", "comments", "activity"]:
|
||||
self.assertNotEqual(selected_sort, sort_type)
|
||||
self.sort_page.change_sort_preference(sort_type)
|
||||
selected_sort = self.sort_page.get_selected_sort_preference()
|
||||
@@ -1139,7 +1139,7 @@ class DiscussionSortPreferenceTest(UniqueCourseTest):
|
||||
Test that user last preference is saved.
|
||||
"""
|
||||
selected_sort = ""
|
||||
for sort_type in ["votes", "comments", "date"]:
|
||||
for sort_type in ["votes", "comments", "activity"]:
|
||||
self.assertNotEqual(selected_sort, sort_type)
|
||||
self.sort_page.change_sort_preference(sort_type)
|
||||
selected_sort = self.sort_page.get_selected_sort_preference()
|
||||
|
||||
Reference in New Issue
Block a user