From cb668810e9f1daf63c47a707b3dd0fe66d7741cd Mon Sep 17 00:00:00 2001 From: Alex Coomans Date: Mon, 23 Nov 2009 10:59:14 -0700 Subject: [PATCH] Cleaning a bit on su.pr --- lib/shorty/supr.rb | 6 +----- test/supr_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/shorty/supr.rb b/lib/shorty/supr.rb index 1f1ef36..ec214af 100644 --- a/lib/shorty/supr.rb +++ b/lib/shorty/supr.rb @@ -72,11 +72,7 @@ def self.raise_error(hash) end def self.handle_full_or_hash_option(short, url, full) - if full - short["errorCode"].zero? ? short["results"][url]["shortUrl"] : self.raise_error(short) - else - short["errorCode"].zero? ? short["results"][url]["hash"] : self.raise_error(short) - end + short["errorCode"].zero? ? (full ? short["results"][url]["shortUrl"] : short["results"][url]["hash"]) : self.raise_error(short) end def self.prep_shorten_request(url) diff --git a/test/supr_test.rb b/test/supr_test.rb index 9e14a55..7d879a3 100644 --- a/test/supr_test.rb +++ b/test/supr_test.rb @@ -49,6 +49,10 @@ class SuprTest < Test::Unit::TestCase should "return a shortened url" do assert_equal 'http://su.pr/2yw2PP', Shorty::Supr.shorten('http://cnn.com') end + + should "return a shortened hash" do + assert_equal '2yw2PP', Shorty::Supr.shorten('http://cnn.com', false) + end should "return an expanded url when passed a hash" do assert_equal 'http://cnn.com/', Shorty::Supr.expand('2yw2PP')