Skip to content
This repository
Browse code

fixes exception raised when redirect_to is nil. can occur on load of …

…a redis entry
  • Loading branch information...
commit 0657c75996d128b7785faa609b81b9ff068e46aa 1 parent 2f597ae
Brown Beagle Software authored August 25, 2011 chriskite committed January 19, 2012
2  lib/anemone/page.rb
@@ -190,7 +190,7 @@ def self.from_hash(hash)
190 190
        '@visited' => hash['visited'],
191 191
        '@depth' => hash['depth'].to_i,
192 192
        '@referer' => hash['referer'],
193  
-       '@redirect_to' => URI(hash['redirect_to']),
  193
+       '@redirect_to' => URI(hash['redirect_to'] || ''),
194 194
        '@response_time' => hash['response_time'].to_i,
195 195
        '@fetched' => hash['fetched']
196 196
       }.each do |var, value|
6  spec/page_spec.rb
@@ -89,5 +89,11 @@ module Anemone
89 89
       converted.depth.should == page.depth
90 90
     end
91 91
 
  92
+    it 'should handle a from_hash with a nil redirect_to' do
  93
+      page_hash = @page.to_hash
  94
+      page_hash['redirect_to'] = nil
  95
+      lambda{Page.from_hash(page_hash)}.should_not raise_error(URI::InvalidURIError)
  96
+    end
  97
+
92 98
   end
93 99
 end

0 notes on commit 0657c75

Please sign in to comment.
Something went wrong with that request. Please try again.