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)
args = { original_url: url,
title: topic.title,
title: PrettyText.unescape_emoji(topic.title),
avatar: PrettyText.avatar_img(topic.user.avatar_template, 'tiny'),
posts_count: topic.posts_count,
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='quote-controls'></div>
{{{avatar}}}
<a href="{{original_url}}">{{title}}</a> {{{category_html}}}
<a href="{{original_url}}">{{{title}}}</a> {{{category_html}}}
</div>
<blockquote>{{{quote}}}
<div class='topic-info'>

View File

@ -60,11 +60,16 @@ describe Onebox::Engine::DiscourseLocalOnebox do
end
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)
expect(Onebox.preview(url).to_s).to eq("<a href='#{url}'>#{url}</a>")
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
SiteSetting.external_system_avatars_enabled = false
url = "#{topic.url}"
@ -94,7 +99,7 @@ describe Onebox::Engine::DiscourseLocalOnebox do
expect(html).to eq("<video width='100%' height='100%' controls><source src='#{url}'><a href='#{url}'>#{url}</a></video>")
end
end
context "When deployed to a subfolder" do
let(:base_url) { "http://test.localhost/subfolder" }
let(:base_uri) { "/subfolder" }