Fixes WebSite#xml_rpc_url bug (Thanks Patrick for the report)

This commit is contained in:
erwanlr
2013-03-04 16:34:49 +01:00
parent 80c817b2e2
commit 8bc8d7e7cd
2 changed files with 38 additions and 12 deletions

View File

@@ -79,17 +79,43 @@ describe 'WebSite' do
end
describe '#xml_rpc_url' do
it 'should return the correct url : http://example.localhost/xmlrpc.php' do
xmlrpc = 'http://example.localhost/xmlrpc.php'
stub_request(:get, web_site.url).
to_return(status: 200, headers: { 'X-Pingback' => xmlrpc })
context 'when the x-pingback is' do
web_site.xml_rpc_url.should === xmlrpc
end
context 'correctly supplied' do
it 'returns the url in the header : http://example.localhost/xmlrpc.php' do
xmlrpc = 'http://example.localhost/xmlrpc.php'
stub_request(:get, web_site.url).
to_return(status: 200, headers: { 'X-Pingback' => xmlrpc })
web_site.xml_rpc_url.should === xmlrpc
end
end
context 'not supplied' do
it 'returns nil' do
stub_request(:get, web_site.url).to_return(status: 200)
web_site.xml_rpc_url.should be_nil
end
context 'but there is another header field' do
it 'returns nil' do
stub_request(:get, web_site.url).
to_return(status:200, headers: { 'another-field' => 'which we do not care' })
web_site.xml_rpc_url.should be_nil
end
end
end
context 'empty' do
it 'returns nil' do
stub_request(:get, web_site.url).
to_return(status: 200, headers: { 'X-Pingback' => '' })
web_site.xml_rpc_url.should be_nil
end
end
it 'should return nil' do
stub_request(:get, web_site.url).to_return(status: 200)
web_site.xml_rpc_url.should be_nil
end
end