diff --git a/lib/onebox/layout.rb b/lib/onebox/layout.rb index 66b010e7..2a07d7f5 100644 --- a/lib/onebox/layout.rb +++ b/lib/onebox/layout.rb @@ -20,7 +20,7 @@ def initialize(name, record, cache) end @md5 = Digest::MD5.new - @view = View.new(name, record) + @view = View.new(name, @record) @template_name = "_layout" @template_path = load_paths.last end diff --git a/spec/lib/onebox/layout_spec.rb b/spec/lib/onebox/layout_spec.rb index 0bee1312..3c10722d 100644 --- a/spec/lib/onebox/layout_spec.rb +++ b/spec/lib/onebox/layout_spec.rb @@ -69,5 +69,11 @@ def data html = described_class.new("amazon", record, cache).to_html expect(html).to include(%|"foo"|) end + + it "rewrites relative image path" do + record = { image: "/image.png", link: "https://discourse.org" } + klass = described_class.new("whitelistedgeneric", record, cache) + expect(klass.view.record[:image]).to include("https://discourse.org") + end end end