Fix oEmbed endpoint when only one of maxwidth/maxheight given

element
Marcin Kulik 9 years ago
parent 939137cff6
commit 7254b1d099

@ -25,11 +25,12 @@ class OembedController < ApplicationController
def oembed_response(asciicast)
asciicast_image_generator.generate(asciicast) if asciicast.image_stale?
width, height = asciicast.image_width, asciicast.image_height
if params[:maxwidth]
width, height = size_smaller_than(width, height, params[:maxwidth], params[:maxheight])
end
width, height = size_smaller_than(
asciicast.image_width,
asciicast.image_height,
params[:maxwidth] || asciicast.image_width,
params[:maxheight] || asciicast.image_height
)
oembed = {
type: 'rich',

@ -14,4 +14,9 @@ describe "oEmbed provider", needs_phantomjs_2_bin: true do
expect(response.status).to eq(200)
end
it "responds with status 200 when only maxwidth given" do
get "/oembed?url=http://localhost:3000/a/#{asciicast.id}&format=json&maxwidth=500"
expect(response.status).to eq(200)
end
end

Loading…
Cancel
Save