Skip to content

Commit

Permalink
Merge 5d9b5b7 into 13d2f3d
Browse files Browse the repository at this point in the history
  • Loading branch information
emptyflask committed Jan 7, 2016
2 parents 13d2f3d + 5d9b5b7 commit 695eb0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lib/thumbor/crypto_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ def calculate_width_and_height(url_parts, options)
width = '0' if not has_width and not options[:flip]
end

if width or height
width = width.to_s
height = height.to_s
url_parts.push(width << 'x' << height)
end
url_parts.push("#{width}x#{height}") if width || height
end

def calculate_centered_crop(options)
Expand Down
11 changes: 11 additions & 0 deletions spec/thumbor/crypto_url_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@
url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => -50, :height => -40, :center => [50, 50]
expect(url).to eq('0x10:100x90/-50x-40/' << image_md5)
end

it "should handle string values" do
url = subject.url_for :image => image_url, :width => '40', :height => '50'
expect(url).to eq('40x50/' << image_md5)
end

it "should never mutate its arguments" do
opts = {:image => image_url, :width => '500'}
subject.url_for opts
expect(opts).to eq({:image => image_url, :width => '500'})
end
end

describe '#generate' do
Expand Down

0 comments on commit 695eb0e

Please sign in to comment.