making a few more cleanup and tests
This commit is contained in:
parent
eddcb71fcb
commit
68a44af856
3 changed files with 12 additions and 56 deletions
|
|
@ -14,9 +14,6 @@ class EMWebfinger
|
|||
|
||||
def fetch
|
||||
raise 'you need to set a callback before calling fetch' if @callbacks.empty?
|
||||
query = /\A^#{Regexp.escape(@account.gsub('acct:', '').to_s)}\z/i
|
||||
local_person = Person.first(:diaspora_handle => query)
|
||||
|
||||
person = Person.by_account_identifier(@account)
|
||||
if person
|
||||
process_callbacks person
|
||||
|
|
|
|||
|
|
@ -28,10 +28,7 @@ describe EMWebfinger do
|
|||
let(:non_diaspora_hcard) {File.open(File.join(Rails.root, 'spec/fixtures/evan_hcard')).read}
|
||||
|
||||
context 'setup' do
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
let(:action){ Proc.new{|person| puts person.inspect }}
|
||||
>>>>>>> EM websocket cleanly merged with master. webfingering is now async
|
||||
|
||||
describe '#intialize' do
|
||||
it 'sets account ' do
|
||||
|
|
@ -40,32 +37,29 @@ describe EMWebfinger do
|
|||
end
|
||||
|
||||
it 'should raise an error on an unresonable email' do
|
||||
<<<<<<< HEAD
|
||||
proc{
|
||||
EMWebfinger.new("joe.valid+email@my-address.com")
|
||||
}.should_not raise_error(RuntimeError, "Identifier is invalid")
|
||||
|
||||
end
|
||||
|
||||
it 'should not allow port numbers' do
|
||||
it 'should not allow port numbers' do
|
||||
proc{
|
||||
EMWebfinger.new('eviljoe@diaspora.local:3000')
|
||||
}.should raise_error(RuntimeError, "Identifier is invalid")
|
||||
end
|
||||
=======
|
||||
proc{EMWebfinger.new("asfadfasdf")}.should raise_error
|
||||
end
|
||||
>>>>>>> EM websocket cleanly merged with master. webfingering is now async
|
||||
proc{EMWebfinger.new("asfadfasdf")}.should raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe '#on_person' do
|
||||
it 'should set a callback' do
|
||||
n = EMWebfinger.new("mbs@gmail.com")
|
||||
n.stub(:fetch).and_return(true)
|
||||
|
||||
n.on_person{|person| puts "foo"}
|
||||
n.instance_variable_get(:@callbacks).count.should be 1
|
||||
end
|
||||
describe '#on_person' do
|
||||
it 'should set a callback' do
|
||||
n = EMWebfinger.new("mbs@gmail.com")
|
||||
n.stub(:fetch).and_return(true)
|
||||
|
||||
n.on_person{|person| puts "foo"}
|
||||
n.instance_variable_get(:@callbacks).count.should be 1
|
||||
end
|
||||
end
|
||||
|
||||
describe '#fetch' do
|
||||
|
|
@ -120,11 +114,6 @@ describe EMWebfinger do
|
|||
EM.stop
|
||||
}
|
||||
}
|
||||
end
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> EM websocket cleanly merged with master. webfingering is now async
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -213,40 +213,10 @@ describe Person do
|
|||
f = Person.by_account_identifier("tom@tom.joindiaspora.com")
|
||||
f.should be nil
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
describe '.local_by_account_identifier' do
|
||||
it 'should find local users people' do
|
||||
p = Person.local_by_account_identifier(user.diaspora_handle)
|
||||
p.should == user.person
|
||||
end
|
||||
|
||||
|
||||
it 'identifier should be a valid email' do
|
||||
pending "should check in the webfinger client"
|
||||
stub_success("joe.valid+email@my-address.com")
|
||||
Proc.new {
|
||||
Person.by_account_identifier("joe.valid+email@my-address.com")
|
||||
}.should_not raise_error(RuntimeError, "Identifier is invalid")
|
||||
|
||||
stub_success("not_a_@valid_email")
|
||||
Proc.new {
|
||||
Person.by_account_identifer("not_a_@valid_email")
|
||||
}.should raise_error(RuntimeError, "Identifier is invalid")
|
||||
|
||||
end
|
||||
|
||||
it 'should not accept a port number' do
|
||||
pending "should check the webfinger client"
|
||||
stub_success("eviljoe@diaspora.local:3000")
|
||||
Proc.new {
|
||||
Person.by_account_identifier('eviljoe@diaspora.local:3000')
|
||||
}.should raise_error(RuntimeError, "Identifier is invalid")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '.local_by_account_identifier' do
|
||||
it 'should find local users people' do
|
||||
p = Person.local_by_account_identifier(user.diaspora_handle)
|
||||
|
|
|
|||
Loading…
Reference in a new issue