Skip to content

Commit

Permalink
allow the image_size option to be set as a symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrau committed Feb 17, 2015
1 parent 9c93c08 commit d541116
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/omniauth/strategies/facebook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def image_url(uid, options)
site_uri = URI.parse(client.site)
url = uri_class.build({:host => site_uri.host, :path => "#{site_uri.path}/#{uid}/picture"})

query = if options[:image_size].is_a?(String)
query = if options[:image_size].is_a?(String) || options[:image_size].is_a?(Symbol)
{ :type => options[:image_size] }
elsif options[:image_size].is_a?(Hash)
options[:image_size]
Expand Down
7 changes: 7 additions & 0 deletions test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ class InfoTest < StrategyTestCase
assert_equal 'http://graph.facebook.com/321/picture?type=normal', strategy.info['image']
end

test 'returns the image with size specified as a symbol in the `image_size` option' do
@options = { :image_size => :normal }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info)
assert_equal 'http://graph.facebook.com/321/picture?type=normal', strategy.info['image']
end

test 'returns the image with width and height specified in the `image_size` option' do
@options = { :image_size => { :width => 123, :height => 987 } }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
Expand Down

0 comments on commit d541116

Please sign in to comment.