Ensures a nil location is not processed when enumerating usernames

This commit is contained in:
erwanlr
2014-08-15 22:54:17 +02:00
parent 30a07f037e
commit cebd808674
2 changed files with 11 additions and 0 deletions

View File

@@ -22,6 +22,8 @@ class WpUser < WpItem
if response.code == 301 # login in location?
location = response.headers_hash['Location']
return unless location
@login = Existable.login_from_author_pattern(location)
@display_name = Existable.display_name_from_body(
Browser.get(location).body

View File

@@ -124,6 +124,15 @@ shared_examples 'WpUser::Existable' do
@login = 'admin'
@display_name = 'admin name'
end
context 'when the location is nil' do
let(:location) { nil }
it 'returns nil' do
@login = nil
@display_name = nil
end
end
end
context 'with a 200' do