From 5f53297f5815ff9db0a64d94737cea95c8b03aa9 Mon Sep 17 00:00:00 2001 From: erwanlr Date: Fri, 15 Aug 2014 23:00:42 +0200 Subject: [PATCH] Also ensure to not process empty Location headers --- lib/common/models/wp_user/existable.rb | 2 +- spec/shared_examples/wp_user/existable.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/common/models/wp_user/existable.rb b/lib/common/models/wp_user/existable.rb index 30603748..7092d467 100755 --- a/lib/common/models/wp_user/existable.rb +++ b/lib/common/models/wp_user/existable.rb @@ -22,7 +22,7 @@ class WpUser < WpItem if response.code == 301 # login in location? location = response.headers_hash['Location'] - return unless location + return if location.nil? || location.empty? @login = Existable.login_from_author_pattern(location) @display_name = Existable.display_name_from_body( diff --git a/spec/shared_examples/wp_user/existable.rb b/spec/shared_examples/wp_user/existable.rb index 5803a98d..1499fcd3 100644 --- a/spec/shared_examples/wp_user/existable.rb +++ b/spec/shared_examples/wp_user/existable.rb @@ -133,6 +133,15 @@ shared_examples 'WpUser::Existable' do @display_name = nil end end + + context 'when the location is empty' do + let(:location) { '' } + + it 'returns nil' do + @login = nil + @display_name = nil + end + end end context 'with a 200' do