do not break oneboxes' favicon after updating favicons
This commit is contained in:
parent
57f7c794d7
commit
40c08eab14
|
@ -29,7 +29,7 @@ module Oneboxer
|
|||
end
|
||||
|
||||
def uriencode(val)
|
||||
return URI.escape(val, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
||||
URI.escape(val, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -39,9 +39,10 @@ module Oneboxer
|
|||
html = fetch_html
|
||||
args = parse(html)
|
||||
return default_url unless args.present?
|
||||
|
||||
args[:original_url] = @url
|
||||
args[:lang] = @lang || ""
|
||||
args[:favicon] = ActionController::Base.helpers.image_path(self.class.favicon_file) if self.class.favicon_file.present?
|
||||
args[:favicon] = ActionController::Base.helpers.asset_path(self.class.favicon_file, digest: false) if self.class.favicon_file.present?
|
||||
args[:host] = nice_host
|
||||
|
||||
HandlebarsOnebox.generate_onebox(template,args)
|
||||
|
@ -51,7 +52,7 @@ module Oneboxer
|
|||
default_url
|
||||
end
|
||||
|
||||
def self.generate_onebox(template, args)
|
||||
def self.generate_onebox(template, args={})
|
||||
Mustache.render(File.read(template), args)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@ require 'oneboxer'
|
|||
require 'oneboxer/handlebars_onebox'
|
||||
|
||||
describe Oneboxer::HandlebarsOnebox do
|
||||
H = Oneboxer::HandlebarsOnebox
|
||||
|
||||
describe 'simple onebox' do
|
||||
H = Oneboxer::HandlebarsOnebox
|
||||
|
||||
it "is able to render image size when specified" do
|
||||
template = H.template_path('simple_onebox')
|
||||
result = H.generate_onebox(template, 'image_width' => 100, 'image_height' => 100, image: 'http://my.com/image.png')
|
||||
|
@ -13,5 +14,22 @@ describe Oneboxer::HandlebarsOnebox do
|
|||
result.should =~ /width=/
|
||||
result.should =~ /height=/
|
||||
end
|
||||
|
||||
class SimpleOnebox < Oneboxer::HandlebarsOnebox
|
||||
favicon 'stackexchange.png'
|
||||
|
||||
def parse(html)
|
||||
{ testing: true }
|
||||
end
|
||||
end
|
||||
|
||||
it "does not use fingerprint on favicons" do
|
||||
onebox = SimpleOnebox.new "http://domain.com"
|
||||
onebox.stubs(:fetch_html).returns("")
|
||||
ActionController::Base.helpers.expects(:asset_path).with('favicons/stackexchange.png', digest: false)
|
||||
result = onebox.onebox
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue