0
0
Fork 0

Remove some arguments of Formatter.instance.format and spec (#3541)

* Remove some arguments of Formatter.instance.format

* Improve spec for Formatter
This commit is contained in:
Akihiko Odaki (@fn_aki@pawoo.net) 2017-06-04 21:58:57 +09:00 committed by Eugen Rochko
parent 9475fbae78
commit c7af8cbc90
2 changed files with 208 additions and 117 deletions

View file

@ -9,7 +9,7 @@ class Formatter
include ActionView::Helpers::TextHelper
def format(status, attribute = :text, paragraphize = true)
def format(status)
if status.reblog?
prepend_reblog = status.reblog.account.acct
status = status.proper
@ -17,9 +17,8 @@ class Formatter
prepend_reblog = false
end
raw_content = status.public_send(attribute)
raw_content = status.text
return '' if raw_content.blank?
return reformat(raw_content) unless status.local?
linkable_accounts = status.mentions.map(&:account)
@ -28,7 +27,7 @@ class Formatter
html = raw_content
html = "RT @#{prepend_reblog} #{html}" if prepend_reblog
html = encode_and_link_urls(html, linkable_accounts)
html = simple_format(html, {}, sanitize: false) if paragraphize
html = simple_format(html, {}, sanitize: false)
html = html.delete("\n")
html.html_safe # rubocop:disable Rails/OutputSafety