ensure handle is downcased on search, fix #1912

This commit is contained in:
Jonne Hass 2011-09-07 15:17:31 +02:00
parent 92dcffb253
commit bc4872d3a5
4 changed files with 16 additions and 2 deletions

View file

@ -33,7 +33,7 @@ class PeopleController < ApplicationController
format.html do
#only do it if it is an email address
if params[:q].try(:match, Devise.email_regexp)
people = Person.where(:diaspora_handle => params[:q])
people = Person.where(:diaspora_handle => params[:q].downcase)
webfinger(params[:q]) if people.empty?
else
people = Person.search(params[:q], current_user)

View file

@ -4,7 +4,7 @@ require File.join(Rails.root, 'lib/webfinger_profile')
class Webfinger
class WebfingerFailedError < RuntimeError; end
def initialize(account)
@account = account.strip.gsub('acct:','').to_s
@account = account.strip.gsub('acct:','').to_s.downcase
@ssl = true
Rails.logger.info("event=webfinger status=initialized target=#{account}")
end

View file

@ -57,6 +57,14 @@ describe PeopleController do
get :index, :q => "eugene@example.org"
assigns[:people][0].id.should == eugene2.id
end
it "downcases the handle before trying to find someone by it" do
eugene2 = Factory.create(:person, :diaspora_handle => "eugene@example.org",
:profile => Factory.build(:profile, :first_name => "Eugene",
:last_name => "w", :searchable => false))
get :index, :q => "Eugene@Example.ORG"
assigns[:people][0].id.should == eugene2.id
end
it "does not redirect to person page if there is exactly one match" do
get :index, :q => "Korth"

View file

@ -32,6 +32,12 @@ describe Webfinger do
n = Webfinger.new("mbs348@gmail.com")
n.instance_variable_get(:@account).should_not be nil
end
it 'downcases account' do
account = "BIGBOY@Example.Org"
n = Webfinger.new(account)
n.instance_variable_get(:@account).should == account.downcase
end
it 'should set ssl as the default' do
foo = Webfinger.new(account)