Merge branch 'stable' into develop

This commit is contained in:
Jonne Haß 2015-05-16 12:48:41 +02:00
commit ca33e984d3
4 changed files with 53 additions and 28 deletions

View file

@ -42,6 +42,7 @@ Ruby 2.0 is no longer officially supported.
* 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)

View file

@ -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
View 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

View file

@ -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