From 18dbf02181a93af011c74ea6319357bedd3e35ce Mon Sep 17 00:00:00 2001 From: SaiVardhan Date: Tue, 19 Jul 2016 16:34:59 +0530 Subject: [PATCH] [FIX] #6642 Strip Markdown from conversation title closes #6642 --- Changelog.md | 1 + app/views/conversations/_conversation.haml | 2 +- spec/controllers/conversations_controller_spec.rb | 10 +++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 03f72f9e2..14d4e8e9d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -138,6 +138,7 @@ before. * Do not allow to change email to an already used one [#6905](https://github.com/diaspora/diaspora/pull/6905) * Correctly filter mentions on the server side [#6902](https://github.com/diaspora/diaspora/pull/6902) * Add aspects to the aspect membership dropdown when creating them on the getting started page [#6864](https://github.com/diaspora/diaspora/pull/6864) +* Strip markdown from message preview in conversations list [#6923](https://github.com/diaspora/diaspora/pull/6923) ## Features * Support color themes [#6033](https://github.com/diaspora/diaspora/pull/6033) diff --git a/app/views/conversations/_conversation.haml b/app/views/conversations/_conversation.haml index cc383565f..5299debbd 100644 --- a/app/views/conversations/_conversation.haml +++ b/app/views/conversations/_conversation.haml @@ -32,7 +32,7 @@ .last_message - if conversation.messages.present? %em - = conversation.messages.last.text + = conversation.messages.last.message.plain_text_without_markdown - if other_participants.count > 1 .participants - other_participants.drop(1).take(15).each do |participant| diff --git a/spec/controllers/conversations_controller_spec.rb b/spec/controllers/conversations_controller_spec.rb index 38e4f90e5..0b0275128 100644 --- a/spec/controllers/conversations_controller_spec.rb +++ b/spec/controllers/conversations_controller_spec.rb @@ -64,7 +64,7 @@ describe ConversationsController, :type => :controller do author: alice.person, participant_ids: [alice.contacts.first.person.id, alice.person.id], subject: "not spam", - messages_attributes: [{author: alice.person, text: "cool stuff"}] + messages_attributes: [{author: alice.person, text: "**cool stuff**"}] } @conversations = Array.new(3) { Conversation.create(hash) } @visibilities = @conversations.map {|conversation| @@ -102,6 +102,14 @@ describe ConversationsController, :type => :controller do get :index, conversation_id: @conversations.first.id expect(assigns[:conversation]).to be_nil end + + it "retrieves a conversation message with out markdown content " do + get :index + @conversation = @conversations.first + expect(response).to be_success + expect(response.body).to match(/cool stuff/) + expect(response.body).not_to match(%r{cool stuff}) + end end describe '#create' do