Skip to content
Extraits de code Groupes Projets
Valider 30cc3307 rédigé par Benjamin Neff's avatar Benjamin Neff Validation de Jonne Haß
Parcourir les fichiers

fix empty searchable in hcard, parse empty as false

closes #5962
parent c01fdb6e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -27,6 +27,7 @@
* Fix inactive user removal not respecting configuration for daily limits [#5953](https://github.com/diaspora/diaspora/pull/5953)
* Fix missing localization of inactive user removal warning emails [#5950](https://github.com/diaspora/diaspora/issues/5950)
* Fix fetching for public post while Webfingering [#5958](https://github.com/diaspora/diaspora/pull/5958)
* Handle empty searchable in HCard gracefully [#5962](https://github.com/diaspora/diaspora/pull/5962)
## Features
* Hide post title of limited post in comment notification email [#5843](https://github.com/diaspora/diaspora/pull/5843)
......
......@@ -3,19 +3,19 @@
# the COPYRIGHT file.
module HCard
def self.parse doc
def self.parse(doc)
{
:given_name => doc.css(".given_name").text,
:family_name => doc.css(".family_name").text,
:url => doc.css("#pod_location").text,
:photo => doc.css(".entity_photo .photo[src]").attribute('src').text,
:photo_small => doc.css(".entity_photo_small .photo[src]").attribute('src').text,
:photo_medium => doc.css(".entity_photo_medium .photo[src]").attribute('src').text,
:searchable => doc.css(".searchable").text
given_name: doc.css(".given_name").text,
family_name: doc.css(".family_name").text,
url: doc.css("#pod_location").text,
photo: doc.css(".entity_photo .photo[src]").attribute("src").text,
photo_small: doc.css(".entity_photo_small .photo[src]").attribute("src").text,
photo_medium: doc.css(".entity_photo_medium .photo[src]").attribute("src").text,
searchable: doc.css(".searchable").text == "true"
}
end
def self.build(raw_hcard)
self.parse Nokogiri::HTML(raw_hcard)
parse Nokogiri::HTML(raw_hcard)
end
end
......@@ -2,11 +2,11 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
require "spec_helper"
describe HCard do
it 'should parse an hcard' do
raw_hcard = hcard_response
it "should parse an hcard" do
raw_hcard = hcard_response
hcard = HCard.build raw_hcard
expect(hcard[:family_name].include?("Hamiltom")).to be true
expect(hcard[:given_name].include?("Alex")).to be true
......@@ -14,6 +14,30 @@ describe HCard do
expect(hcard[:photo_medium].include?("thumb_medium")).to be true
expect(hcard[:photo_small].include?("thumb_small")).to be true
expect(hcard[:url]).to eq("http://localhost:3000/")
expect(hcard[:searchable]).to eq("false")
expect(hcard[:searchable]).to eq(false)
end
it "should parse an hcard with searchable true" do
raw_hcard = hcard_response.sub("<span class='searchable'>false</span>", "<span class='searchable'>true</span>")
hcard = HCard.build raw_hcard
expect(hcard[:family_name].include?("Hamiltom")).to be true
expect(hcard[:given_name].include?("Alex")).to be true
expect(hcard[:photo].include?("thumb_large")).to be true
expect(hcard[:photo_medium].include?("thumb_medium")).to be true
expect(hcard[:photo_small].include?("thumb_small")).to be true
expect(hcard[:url]).to eq("http://localhost:3000/")
expect(hcard[:searchable]).to eq(true)
end
it "should parse an hcard with empty searchable" do
raw_hcard = hcard_response.sub("<span class='searchable'>false</span>", "<span class='searchable'></span>")
hcard = HCard.build raw_hcard
expect(hcard[:family_name].include?("Hamiltom")).to be true
expect(hcard[:given_name].include?("Alex")).to be true
expect(hcard[:photo].include?("thumb_large")).to be true
expect(hcard[:photo_medium].include?("thumb_medium")).to be true
expect(hcard[:photo_small].include?("thumb_small")).to be true
expect(hcard[:url]).to eq("http://localhost:3000/")
expect(hcard[:searchable]).to eq(false)
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter