Skip to content

Commit

Permalink
Fix oEmbed endpoint when only one of maxwidth/maxheight given
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Jun 16, 2015
1 parent 939137c commit 7254b1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/controllers/oembed_controller.rb
Expand Up @@ -25,11 +25,12 @@ def show
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',
Expand Down
5 changes: 5 additions & 0 deletions spec/api/oembed_spec.rb
Expand Up @@ -14,4 +14,9 @@
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

0 comments on commit 7254b1d

Please sign in to comment.