parent
c01fdb6e1c
commit
30cc330747
4 changed files with 53 additions and 28 deletions
|
|
@ -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
|
||||
|
|
|
|||
43
spec/lib/h_card_spec.rb
Normal file
43
spec/lib/h_card_spec.rb
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
describe HCard do
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe HCard do
|
||||
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
|
||||
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
|
||||
Loading…
Reference in a new issue