Permalink
Browse files

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

…a redis entry
  • Loading branch information...
1 parent 2f597ae commit 0657c75996d128b7785faa609b81b9ff068e46aa @brownbeagle brownbeagle committed with Aug 25, 2011
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/anemone/page.rb
  2. +6 −0 spec/page_spec.rb
View
@@ -190,7 +190,7 @@ def self.from_hash(hash)
'@visited' => hash['visited'],
'@depth' => hash['depth'].to_i,
'@referer' => hash['referer'],
- '@redirect_to' => URI(hash['redirect_to']),
+ '@redirect_to' => URI(hash['redirect_to'] || ''),
'@response_time' => hash['response_time'].to_i,
'@fetched' => hash['fetched']
}.each do |var, value|
View
@@ -89,5 +89,11 @@ module Anemone
converted.depth.should == page.depth
end
+ it 'should handle a from_hash with a nil redirect_to' do
+ page_hash = @page.to_hash
+ page_hash['redirect_to'] = nil
+ lambda{Page.from_hash(page_hash)}.should_not raise_error(URI::InvalidURIError)
+ end
+
end
end

0 comments on commit 0657c75

Please sign in to comment.