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
This commit is contained in:
Waqas Khalid
2014-10-10 15:22:51 +05:00
parent 61dbd70cf6
commit f023b62bd0
2 changed files with 5 additions and 1 deletions

View File

@@ -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 = {

View File

@@ -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.")