FIX: Replace emoji in local oneboxes

This commit is contained in:
Robin Ward 2016-03-14 14:48:30 -04:00
parent ff12b5bf57
commit 621f7e0a65
3 changed files with 9 additions and 4 deletions

View file

@ -93,7 +93,7 @@ module Onebox
quote = post.excerpt(SiteSetting.post_onebox_maxlength) quote = post.excerpt(SiteSetting.post_onebox_maxlength)
args = { original_url: url, args = { original_url: url,
title: topic.title, title: PrettyText.unescape_emoji(topic.title),
avatar: PrettyText.avatar_img(topic.user.avatar_template, 'tiny'), avatar: PrettyText.avatar_img(topic.user.avatar_template, 'tiny'),
posts_count: topic.posts_count, posts_count: topic.posts_count,
last_post: FreedomPatches::Rails4.time_ago_in_words(topic.last_posted_at, false, scope: :'datetime.distance_in_words_verbose'), last_post: FreedomPatches::Rails4.time_ago_in_words(topic.last_posted_at, false, scope: :'datetime.distance_in_words_verbose'),

View file

@ -2,7 +2,7 @@
<div class='title'> <div class='title'>
<div class='quote-controls'></div> <div class='quote-controls'></div>
{{{avatar}}} {{{avatar}}}
<a href="{{original_url}}">{{title}}</a> {{{category_html}}} <a href="{{original_url}}">{{{title}}}</a> {{{category_html}}}
</div> </div>
<blockquote>{{{quote}}} <blockquote>{{{quote}}}
<div class='topic-info'> <div class='topic-info'>

View file

@ -60,11 +60,16 @@ describe Onebox::Engine::DiscourseLocalOnebox do
end end
it "returns a link if not allowed to see the post" do it "returns a link if not allowed to see the post" do
url = "#{topic.url}" url = topic.url
Guardian.any_instance.stubs(:can_see?).returns(false) Guardian.any_instance.stubs(:can_see?).returns(false)
expect(Onebox.preview(url).to_s).to eq("<a href='#{url}'>#{url}</a>") expect(Onebox.preview(url).to_s).to eq("<a href='#{url}'>#{url}</a>")
end end
it "replaces emoji in the title" do
topic.update_column(:title, "Who wants to eat a :hamburger:")
expect(Onebox.preview(topic.url).to_s).to match(/hamburger.png/)
end
it "returns some onebox goodness if post exists and can be seen" do it "returns some onebox goodness if post exists and can be seen" do
SiteSetting.external_system_avatars_enabled = false SiteSetting.external_system_avatars_enabled = false
url = "#{topic.url}" url = "#{topic.url}"