FIX: fancy topic title must fit into column
This commit is contained in:
parent
c41880ab19
commit
3cd73cdf18
|
@ -37,6 +37,10 @@ class Topic < ActiveRecord::Base
|
|||
@max_sort_order ||= (2**31) - 1
|
||||
end
|
||||
|
||||
def self.max_fancy_title_length
|
||||
400
|
||||
end
|
||||
|
||||
def featured_users
|
||||
@featured_users ||= TopicFeaturedUsers.new(self)
|
||||
end
|
||||
|
@ -304,7 +308,8 @@ class Topic < ActiveRecord::Base
|
|||
def self.fancy_title(title)
|
||||
escaped = ERB::Util.html_escape(title)
|
||||
return unless escaped
|
||||
Emoji.unicode_unescape(HtmlPrettify.render(escaped))
|
||||
fancy_title = Emoji.unicode_unescape(HtmlPrettify.render(escaped))
|
||||
fancy_title.length > Topic.max_fancy_title_length ? title : fancy_title
|
||||
end
|
||||
|
||||
def fancy_title
|
||||
|
|
|
@ -329,6 +329,14 @@ describe Topic do
|
|||
expect(topic.fancy_title).to eq("this is another edge case")
|
||||
end
|
||||
|
||||
it "works with long title that results in lots of entities" do
|
||||
long_title = "NEW STOCK PICK: PRCT - LAST PICK UP 233%, NNCO.................................................................................................................................................................. ofoum"
|
||||
topic.title = long_title
|
||||
|
||||
expect { topic.save! }.to_not raise_error
|
||||
expect(topic.fancy_title).to eq(long_title)
|
||||
end
|
||||
|
||||
context 'readonly mode' do
|
||||
before do
|
||||
Discourse.enable_readonly_mode
|
||||
|
|
Loading…
Reference in New Issue