From f023b62bd0865df59ee6dd6588008c514ca37255 Mon Sep 17 00:00:00 2001 From: Waqas Khalid Date: Fri, 10 Oct 2014 15:22:51 +0500 Subject: [PATCH] Endorsement username shouldn't be broken If we endourse the answer of the question in discussion the username link that is created is broken whereas it should point to the userprofile. TNL-188 --- .../discussion/view/thread_response_show_view_spec.coffee | 4 ++++ .../src/discussion/views/discussion_content_view.coffee | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/static/coffee/spec/discussion/view/thread_response_show_view_spec.coffee b/common/static/coffee/spec/discussion/view/thread_response_show_view_spec.coffee index e545b2676e..41f9511e7e 100644 --- a/common/static/coffee/spec/discussion/view/thread_response_show_view_spec.coffee +++ b/common/static/coffee/spec/discussion/view/thread_response_show_view_spec.coffee @@ -45,6 +45,7 @@ describe "ThreadResponseShowView", -> it "renders endorsement correctly for a marked answer in a question thread", -> endorsement = { "username": "test_endorser", + "user_id": "test_id", "time": new Date().toISOString() } @thread.set("thread_type", "question") @@ -56,6 +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") it "renders anonymous endorsement correctly for a marked answer in a question thread", -> endorsement = { @@ -74,6 +76,7 @@ describe "ThreadResponseShowView", -> it "renders endorsement correctly for an endorsed response in a discussion thread", -> endorsement = { "username": "test_endorser", + "user_id": "test_id", "time": new Date().toISOString() } @thread.set("thread_type", "discussion") @@ -85,6 +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") it "renders anonymous endorsement correctly for an endorsed response in a discussion thread", -> endorsement = { diff --git a/common/static/coffee/src/discussion/views/discussion_content_view.coffee b/common/static/coffee/src/discussion/views/discussion_content_view.coffee index 58f30478ba..a481e2368b 100644 --- a/common/static/coffee/src/discussion/views/discussion_content_view.coffee +++ b/common/static/coffee/src/discussion/views/discussion_content_view.coffee @@ -194,7 +194,7 @@ if Backbone? url = @model.urlFor("endorse") updates = endorsed: is_endorsing - endorsement: if is_endorsing then {username: DiscussionUtil.getUser().get("username"), time: new Date().toISOString()} else null + endorsement: if is_endorsing then {username: DiscussionUtil.getUser().get("username"), user_id: DiscussionUtil.getUser().id, time: new Date().toISOString()} else null if @model.get('thread').get('thread_type') == 'question' if is_endorsing msg = gettext("We had some trouble marking this response as an answer. Please try again.")