Bugfixes and rspecs

This commit is contained in:
Christian Mehlmauer
2012-12-13 16:46:52 +01:00
parent 4d852b5983
commit 509a400add
4 changed files with 49 additions and 30 deletions

View File

@@ -32,8 +32,8 @@ module WebSite
wordpress = true
else
response = Browser.instance.get(
xmlrpc_url(),
{:follow_location => true, :max_redirects => 2}
xml_rpc_url,
{:follow_location => true, :max_redirects => 2}
)
if response.body =~ %r{XML-RPC server accepts POST requests only}i
@@ -44,8 +44,21 @@ module WebSite
wordpress
end
def xmlrpc_url
@uri.merge("xmlrpc.php").to_s
def xml_rpc_url
unless @xmlrpc_url
headers = Browser.instance.get(@uri.to_s).headers_hash
value = headers["x-pingback"]
if value.nil? or value.empty?
@xmlrpc_url = nil
else
@xmlrpc_url = value
end
end
@xmlrpc_url
end
def has_xml_rpc?
!xml_rpc_url.nil?
end
# Checks if the remote website is up.

View File

@@ -178,21 +178,4 @@ class WpTarget
end
@multisite
end
def xml_rpc_url
unless @xmlrpc_url
headers = Browser.instance.get(@uri).headers_hash
value = headers["x-pingback"]
if value.nil? or value.empty?
@xmlrpc_url = "nope"
else
@xmlrpc_url = value
end
end
@xmlrpc_url
end
def xml_rpc_enabled
xml_rpc_url != "nope"
end
end