Commit af3d2713 by Waqas Khalid

Merge pull request #5540 from mlkwaqas/waqas/tnl188-endorsement-username-link-broken

Endorsement username shouldn't be broken
parents 7e52ba87 f023b62b
...@@ -45,6 +45,7 @@ describe "ThreadResponseShowView", -> ...@@ -45,6 +45,7 @@ describe "ThreadResponseShowView", ->
it "renders endorsement correctly for a marked answer in a question thread", -> it "renders endorsement correctly for a marked answer in a question thread", ->
endorsement = { endorsement = {
"username": "test_endorser", "username": "test_endorser",
"user_id": "test_id",
"time": new Date().toISOString() "time": new Date().toISOString()
} }
@thread.set("thread_type", "question") @thread.set("thread_type", "question")
...@@ -56,6 +57,7 @@ describe "ThreadResponseShowView", -> ...@@ -56,6 +57,7 @@ describe "ThreadResponseShowView", ->
expect(@view.$(".posted-details").text().replace(/\s+/g, " ")).toMatch( expect(@view.$(".posted-details").text().replace(/\s+/g, " ")).toMatch(
"marked as answer less than a minute ago by " + endorsement.username "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", -> it "renders anonymous endorsement correctly for a marked answer in a question thread", ->
endorsement = { endorsement = {
...@@ -74,6 +76,7 @@ describe "ThreadResponseShowView", -> ...@@ -74,6 +76,7 @@ describe "ThreadResponseShowView", ->
it "renders endorsement correctly for an endorsed response in a discussion thread", -> it "renders endorsement correctly for an endorsed response in a discussion thread", ->
endorsement = { endorsement = {
"username": "test_endorser", "username": "test_endorser",
"user_id": "test_id",
"time": new Date().toISOString() "time": new Date().toISOString()
} }
@thread.set("thread_type", "discussion") @thread.set("thread_type", "discussion")
...@@ -85,6 +88,7 @@ describe "ThreadResponseShowView", -> ...@@ -85,6 +88,7 @@ describe "ThreadResponseShowView", ->
expect(@view.$(".posted-details").text().replace(/\s+/g, " ")).toMatch( expect(@view.$(".posted-details").text().replace(/\s+/g, " ")).toMatch(
"endorsed less than a minute ago by " + endorsement.username "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", -> it "renders anonymous endorsement correctly for an endorsed response in a discussion thread", ->
endorsement = { endorsement = {
......
...@@ -194,7 +194,7 @@ if Backbone? ...@@ -194,7 +194,7 @@ if Backbone?
url = @model.urlFor("endorse") url = @model.urlFor("endorse")
updates = updates =
endorsed: is_endorsing 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 @model.get('thread').get('thread_type') == 'question'
if is_endorsing if is_endorsing
msg = gettext("We had some trouble marking this response as an answer. Please try again.") msg = gettext("We had some trouble marking this response as an answer. Please try again.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment