mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 18:35:31 +08:00
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
|
@max_sort_order ||= (2**31) - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.max_fancy_title_length
|
||||||
|
400
|
||||||
|
end
|
||||||
|
|
||||||
def featured_users
|
def featured_users
|
||||||
@featured_users ||= TopicFeaturedUsers.new(self)
|
@featured_users ||= TopicFeaturedUsers.new(self)
|
||||||
end
|
end
|
||||||
|
@ -304,7 +308,8 @@ class Topic < ActiveRecord::Base
|
||||||
def self.fancy_title(title)
|
def self.fancy_title(title)
|
||||||
escaped = ERB::Util.html_escape(title)
|
escaped = ERB::Util.html_escape(title)
|
||||||
return unless escaped
|
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
|
end
|
||||||
|
|
||||||
def fancy_title
|
def fancy_title
|
||||||
|
|
|
@ -329,6 +329,14 @@ describe Topic do
|
||||||
expect(topic.fancy_title).to eq("this is another edge case")
|
expect(topic.fancy_title).to eq("this is another edge case")
|
||||||
end
|
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
|
context 'readonly mode' do
|
||||||
before do
|
before do
|
||||||
Discourse.enable_readonly_mode
|
Discourse.enable_readonly_mode
|
||||||
|
|
Loading…
Reference in New Issue
Block a user