update string blocks for new rubocop
This commit is contained in:
parent
be7264b604
commit
c0e798c55e
27 changed files with 76 additions and 136 deletions
|
|
@ -1,7 +1,6 @@
|
|||
module DiasporaFederation
|
||||
describe Entities::Relayable do
|
||||
let(:author_serialized_key) {
|
||||
<<-KEY
|
||||
let(:author_serialized_key) { <<-KEY }
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXgIBAAKBgQCxTbMp+M5sCUDVi9k1wMxedSwyLQcjBKQa0Qs6Qpnflz0k90hh
|
||||
btau0cy9jTK6S3CK2GhERXD6EecDlhZCbnSI9Bwmco5j6NbGPN5ai9tWgiBZzaEr
|
||||
|
|
@ -18,7 +17,6 @@ nRcJ3dILfGs4FFN630MBAkEA3zMOyNTeNdHrVhZc5b0qw2T6FUJGieDpOWLsff4w
|
|||
84yW10oS2CCmqEhbfh4Wu22amglytrATwD9hDzsTNAt8Mg==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
KEY
|
||||
}
|
||||
let(:author_key) { OpenSSL::PKey::RSA.new(author_serialized_key) }
|
||||
# -----BEGIN PUBLIC KEY-----
|
||||
# MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxTbMp+M5sCUDVi9k1wMxedSwy
|
||||
|
|
@ -27,8 +25,7 @@ KEY
|
|||
# g6zpg1zxGahpmxwqFQIDAQAB
|
||||
# -----END PUBLIC KEY-----
|
||||
|
||||
let(:parent_serialized_key) {
|
||||
<<-KEY
|
||||
let(:parent_serialized_key) { <<-KEY }
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXgIBAAKBgQDrOvW1UArKoUOg54XWXcTD3jU0zKG3Pm9IeaEzfQtApogQ3+M/
|
||||
F9nz0i3q8UhTDEPBQ3hMbqJ/4qfY+wFulxMR58DbqxFx9QcNZISUd0CPx/fJOYMx
|
||||
|
|
@ -45,7 +42,6 @@ yq359XWooo3N7kmduEKhAkEAppzKLuVtX1XPL4VZBex/M2ewngjkSg964BvxIBwv
|
|||
bFzeSqlMpnbEoOJ9hhx6CsP6Y7V19DRRXi0XgwcAjHLz8g==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
KEY
|
||||
}
|
||||
let(:parent_key) { OpenSSL::PKey::RSA.new(parent_serialized_key) }
|
||||
# -----BEGIN PUBLIC KEY-----
|
||||
# MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrOvW1UArKoUOg54XWXcTD3jU0
|
||||
|
|
@ -67,8 +63,7 @@ KEY
|
|||
)
|
||||
}
|
||||
|
||||
let(:legacy_comment_xml_alice) {
|
||||
<<-XML
|
||||
let(:legacy_comment_xml_alice) { <<-XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
|
|
@ -82,9 +77,7 @@ KEY
|
|||
</post>
|
||||
</XML>
|
||||
XML
|
||||
}
|
||||
let(:new_signature_comment_xml_alice) {
|
||||
<<-XML
|
||||
let(:new_signature_comment_xml_alice) { <<-XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
|
|
@ -94,9 +87,7 @@ XML
|
|||
<parent_author_signature/>
|
||||
</comment>
|
||||
XML
|
||||
}
|
||||
let(:new_data_comment_xml_alice) {
|
||||
<<-XML
|
||||
let(:new_data_comment_xml_alice) { <<-XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
|
|
@ -107,10 +98,8 @@ XML
|
|||
<parent_author_signature/>
|
||||
</comment>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:legacy_comment_xml_bob) {
|
||||
<<-XML
|
||||
let(:legacy_comment_xml_bob) { <<-XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
|
|
@ -124,9 +113,7 @@ XML
|
|||
</post>
|
||||
</XML>
|
||||
XML
|
||||
}
|
||||
let(:legacy_new_signature_comment_xml_bob) {
|
||||
<<-XML
|
||||
let(:legacy_new_signature_comment_xml_bob) { <<-XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
|
|
@ -140,9 +127,7 @@ XML
|
|||
</post>
|
||||
</XML>
|
||||
XML
|
||||
}
|
||||
let(:new_signature_comment_xml_bob) {
|
||||
<<-XML
|
||||
let(:new_signature_comment_xml_bob) { <<-XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
|
|
@ -152,9 +137,7 @@ XML
|
|||
<parent_author_signature>hWsagsczmZD6d36d6MFdTt3hKAdnRtupSIU6464G2kkMJ+WlExxMgbF6kWR+jVCBTeKipWCYK3Arnj0YkuIZM9d14bJGVMTsW/ZzNfJ69bXZhsyawI8dPnZnLVydo+hU/XmGJBEuh2TOj9Emq6/HCYiWzPTF5qhYAtyJ1oxJ4Yk=</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
}
|
||||
let(:legacy_new_data_comment_xml_bob) {
|
||||
<<-XML
|
||||
let(:legacy_new_data_comment_xml_bob) { <<-XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
|
|
@ -169,9 +152,7 @@ XML
|
|||
</post>
|
||||
</XML>
|
||||
XML
|
||||
}
|
||||
let(:new_data_comment_xml_bob) {
|
||||
<<-XML
|
||||
let(:new_data_comment_xml_bob) { <<-XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
|
|
@ -182,7 +163,6 @@ XML
|
|||
<parent_author_signature>NxXuEUVeXwUMR77osIbaNlp2oB3bpl8rBEFgQoO6cnoN5ewDbiGADK0x6EhcmJptjwhGVcZiNJNpq7k3/pjJtKaH++3ToCAtcuZoIKwPDsneLnjPhVjE2GXM1TiZKwoHrq41qSp/8Vl5UPbtC6sPiOzIvPKaILXUG8XCiVWuB0M=</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
}
|
||||
|
||||
# this was used to create the XMLs above
|
||||
context "test-data creation" do
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ module DiasporaFederation
|
|||
}
|
||||
}
|
||||
|
||||
let(:html) {
|
||||
<<-HTML
|
||||
let(:html) { <<-HTML }
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
|
|
@ -106,7 +105,7 @@ module DiasporaFederation
|
|||
</body>
|
||||
</html>
|
||||
HTML
|
||||
}
|
||||
|
||||
let(:string) { "HCard:#{data[:guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
module DiasporaFederation
|
||||
describe Discovery::HostMeta do
|
||||
let(:base_url) { "https://pod.example.tld/" }
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" type="application/xrd+xml" template="#{base_url}webfinger?q={uri}"/>
|
||||
</XRD>
|
||||
XML
|
||||
}
|
||||
|
||||
it "must not create blank instances" do
|
||||
expect { Discovery::HostMeta.new }.to raise_error NoMethodError
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ module DiasporaFederation
|
|||
}
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Subject>#{acct}</Subject>
|
||||
|
|
@ -35,7 +34,7 @@ module DiasporaFederation
|
|||
<Link rel="diaspora-public-key" type="RSA" href="#{public_key_base64}"/>
|
||||
</XRD>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "WebFinger:#{data[:acct_uri]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
module DiasporaFederation
|
||||
describe Discovery::XrdDocument do
|
||||
let(:xml) {
|
||||
<<XML
|
||||
let(:xml) { <<-XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Expires>2010-01-30T09:30:00Z</Expires>
|
||||
|
|
@ -15,7 +14,6 @@ module DiasporaFederation
|
|||
<Link rel="copyright" template="http://example.com/copyright?id={uri}"/>
|
||||
</XRD>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:data) {
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,13 +2,12 @@ module DiasporaFederation
|
|||
describe Entities::AccountDeletion do
|
||||
let(:data) { FactoryGirl.attributes_for(:account_deletion_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<account_deletion>
|
||||
<diaspora_handle>#{data[:author]}</diaspora_handle>
|
||||
</account_deletion>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "AccountDeletion:#{data[:author]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ module DiasporaFederation
|
|||
.send(:xml_elements).merge(created_at: Time.now.utc, parent: parent_entity)
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<comment>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
|
|
@ -18,7 +17,7 @@ module DiasporaFederation
|
|||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Comment:#{data[:guid]}:#{parent.guid}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ module DiasporaFederation
|
|||
describe Entities::Contact do
|
||||
let(:data) { FactoryGirl.attributes_for(:contact_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<contact>
|
||||
<author>#{data[:author]}</author>
|
||||
<recipient>#{data[:recipient]}</recipient>
|
||||
|
|
@ -11,7 +10,7 @@ module DiasporaFederation
|
|||
<sharing>#{data[:sharing]}</sharing>
|
||||
</contact>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Contact:#{data[:author]}:#{data[:recipient]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ module DiasporaFederation
|
|||
)
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<conversation>
|
||||
<diaspora_handle>#{data[:author]}</diaspora_handle>
|
||||
<guid>#{parent.guid}</guid>
|
||||
|
|
@ -30,7 +29,7 @@ module DiasporaFederation
|
|||
#{data[:messages].map {|a| a.to_xml.to_s.indent(2) }.join("\n")}
|
||||
</conversation>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Conversation:#{data[:guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
@ -38,8 +37,8 @@ XML
|
|||
it_behaves_like "an XML Entity", %i(parent parent_guid)
|
||||
|
||||
context "default values" do
|
||||
let(:minimal_xml) {
|
||||
<<-XML
|
||||
it "allows no nested messages" do
|
||||
minimal_xml = <<-XML
|
||||
<conversation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{parent.guid}</guid>
|
||||
|
|
@ -47,10 +46,8 @@ XML
|
|||
<created_at>#{data[:created_at]}</created_at>
|
||||
<participant_handles>#{data[:participants]}</participant_handles>
|
||||
</conversation>
|
||||
XML
|
||||
}
|
||||
XML
|
||||
|
||||
it "allows no nested messages" do
|
||||
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root)
|
||||
expect(parsed_instance.messages).to eq([])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ module DiasporaFederation
|
|||
).send(:xml_elements).merge(parent: parent_entity)
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<like>
|
||||
<positive>#{data[:positive]}</positive>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
|
|
@ -24,7 +23,7 @@ module DiasporaFederation
|
|||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</like>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Like:#{data[:guid]}:Post:#{parent.guid}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
@ -55,7 +54,7 @@ XML
|
|||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</like>
|
||||
XML
|
||||
XML
|
||||
|
||||
expect {
|
||||
DiasporaFederation::Entities::Like.from_xml(Nokogiri::XML::Document.parse(broken_xml).root)
|
||||
|
|
|
|||
|
|
@ -2,15 +2,14 @@ module DiasporaFederation
|
|||
describe Entities::Location do
|
||||
let(:data) { FactoryGirl.attributes_for(:location_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<location>
|
||||
<address>#{data[:address]}</address>
|
||||
<lat>#{data[:lat]}</lat>
|
||||
<lng>#{data[:lng]}</lng>
|
||||
</location>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Location" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ module DiasporaFederation
|
|||
.send(:xml_elements).merge(parent: parent_entity)
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<message>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
|
|
@ -20,7 +19,7 @@ module DiasporaFederation
|
|||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</message>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Message:#{data[:guid]}:#{parent.guid}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ module DiasporaFederation
|
|||
).send(:xml_elements).merge(parent: parent_entity)
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<participation>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<target_type>#{parent.entity_type}</target_type>
|
||||
|
|
@ -23,7 +22,7 @@ module DiasporaFederation
|
|||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</participation>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Participation:#{data[:guid]}:Post:#{parent.guid}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ module DiasporaFederation
|
|||
describe Entities::Person do
|
||||
let(:data) { FactoryGirl.attributes_for(:person_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<person>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<diaspora_handle>#{data[:author]}</diaspora_handle>
|
||||
|
|
@ -26,7 +25,7 @@ module DiasporaFederation
|
|||
<exported_key>#{data[:exported_key]}</exported_key>
|
||||
</person>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Person:#{data[:guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ module DiasporaFederation
|
|||
describe Entities::Photo do
|
||||
let(:data) { FactoryGirl.attributes_for(:photo_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<photo>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<diaspora_handle>#{data[:author]}</diaspora_handle>
|
||||
|
|
@ -17,7 +16,7 @@ module DiasporaFederation
|
|||
<width>#{data[:width]}</width>
|
||||
</photo>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Photo:#{data[:guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
@ -25,8 +24,8 @@ XML
|
|||
it_behaves_like "an XML Entity"
|
||||
|
||||
context "default values" do
|
||||
let(:minimal_xml) {
|
||||
<<-XML
|
||||
it "uses default values" do
|
||||
minimal_xml = <<-XML
|
||||
<photo>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<author>#{data[:author]}</author>
|
||||
|
|
@ -37,10 +36,8 @@ XML
|
|||
<height>#{data[:height]}</height>
|
||||
<width>#{data[:width]}</width>
|
||||
</photo>
|
||||
XML
|
||||
}
|
||||
XML
|
||||
|
||||
it "uses default values" do
|
||||
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root)
|
||||
expect(parsed_instance.public).to be_falsey
|
||||
expect(parsed_instance.text).to be_nil
|
||||
|
|
|
|||
|
|
@ -2,14 +2,13 @@ module DiasporaFederation
|
|||
describe Entities::PollAnswer do
|
||||
let(:data) { FactoryGirl.attributes_for(:poll_answer_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<poll_answer>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<answer>#{data[:answer]}</answer>
|
||||
</poll_answer>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "PollAnswer:#{data[:guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ module DiasporaFederation
|
|||
).send(:xml_elements).merge(parent: parent_entity)
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<poll_participation>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
|
|
@ -22,7 +21,7 @@ module DiasporaFederation
|
|||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</poll_participation>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "PollParticipation:#{data[:guid]}:#{parent.guid}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -2,15 +2,14 @@ module DiasporaFederation
|
|||
describe Entities::Poll do
|
||||
let(:data) { FactoryGirl.attributes_for(:poll_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<poll>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<question>#{data[:question]}</question>
|
||||
#{data[:poll_answers].map {|a| a.to_xml.to_s.indent(2) }.join("\n")}
|
||||
</poll>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Poll:#{data[:guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ module DiasporaFederation
|
|||
describe Entities::Profile do
|
||||
let(:data) { FactoryGirl.attributes_for(:profile_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<profile>
|
||||
<diaspora_handle>#{data[:author]}</diaspora_handle>
|
||||
<first_name>#{data[:first_name]}</first_name>
|
||||
|
|
@ -20,7 +19,7 @@ module DiasporaFederation
|
|||
<tag_string>#{data[:tag_string]}</tag_string>
|
||||
</profile>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Profile:#{data[:author]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
@ -28,15 +27,13 @@ XML
|
|||
it_behaves_like "an XML Entity"
|
||||
|
||||
context "default values" do
|
||||
let(:minimal_xml) {
|
||||
<<-XML
|
||||
it "uses default values" do
|
||||
minimal_xml = <<-XML
|
||||
<profile>
|
||||
<author>#{data[:author]}</author>
|
||||
</profile>
|
||||
XML
|
||||
}
|
||||
XML
|
||||
|
||||
it "uses default values" do
|
||||
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root)
|
||||
expect(parsed_instance.first_name).to be_nil
|
||||
expect(parsed_instance.last_name).to be_nil
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ module DiasporaFederation
|
|||
end
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<relayable_retraction>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
|
|
@ -31,7 +30,7 @@ module DiasporaFederation
|
|||
<target_author_signature/>
|
||||
</relayable_retraction>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "RelayableRetraction:#{data[:target_type]}:#{data[:target_guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -234,8 +234,7 @@ XML
|
|||
end
|
||||
|
||||
let(:new_signature_data) { "#{author};#{guid};#{parent_guid};#{new_property};#{property}" }
|
||||
let(:new_xml) {
|
||||
<<-XML
|
||||
let(:new_xml) { <<-XML }
|
||||
<some_relayable>
|
||||
<diaspora_handle>#{author}</diaspora_handle>
|
||||
<guid>#{guid}</guid>
|
||||
|
|
@ -246,7 +245,6 @@ XML
|
|||
<parent_author_signature>#{sign_with_key(parent_pkey, new_signature_data)}</parent_author_signature>
|
||||
</some_relayable>
|
||||
XML
|
||||
}
|
||||
|
||||
it "doesn't drop unknown properties" do
|
||||
entity = SomeRelayable.from_xml(Nokogiri::XML::Document.parse(new_xml).root)
|
||||
|
|
@ -302,7 +300,7 @@ XML
|
|||
<author_signature/>
|
||||
<parent_author_signature/>
|
||||
</some_relayable>
|
||||
XML
|
||||
XML
|
||||
|
||||
expect {
|
||||
SomeRelayable.from_xml(Nokogiri::XML::Document.parse(broken_xml).root)
|
||||
|
|
|
|||
|
|
@ -2,14 +2,13 @@ module DiasporaFederation
|
|||
describe Entities::Request do
|
||||
let(:data) { FactoryGirl.attributes_for(:request_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<request>
|
||||
<sender_handle>#{data[:author]}</sender_handle>
|
||||
<recipient_handle>#{data[:recipient]}</recipient_handle>
|
||||
</request>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Request:#{data[:author]}:#{data[:recipient]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ module DiasporaFederation
|
|||
let(:root) { FactoryGirl.create(:post, author: bob) }
|
||||
let(:data) { FactoryGirl.attributes_for(:reshare_entity, root_guid: root.guid, root_author: bob.diaspora_id) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<reshare>
|
||||
<diaspora_handle>#{data[:author]}</diaspora_handle>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
|
|
@ -15,7 +14,7 @@ module DiasporaFederation
|
|||
<public>#{data[:public]}</public>
|
||||
</reshare>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Reshare:#{data[:guid]}:#{data[:root_guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
@ -23,8 +22,8 @@ XML
|
|||
it_behaves_like "an XML Entity"
|
||||
|
||||
context "default values" do
|
||||
let(:minimal_xml) {
|
||||
<<-XML
|
||||
it "uses default values" do
|
||||
minimal_xml = <<-XML
|
||||
<reshare>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
|
|
@ -32,10 +31,8 @@ XML
|
|||
<root_diaspora_id>#{data[:root_author]}</root_diaspora_id>
|
||||
<root_guid>#{data[:root_guid]}</root_guid>
|
||||
</reshare>
|
||||
XML
|
||||
}
|
||||
XML
|
||||
|
||||
it "uses default values" do
|
||||
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root)
|
||||
expect(parsed_instance.public).to be_truthy
|
||||
expect(parsed_instance.provider_display_name).to be_nil
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@ module DiasporaFederation
|
|||
)
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<retraction>
|
||||
<diaspora_handle>#{data[:author]}</diaspora_handle>
|
||||
<post_guid>#{data[:target_guid]}</post_guid>
|
||||
<type>#{data[:target_type]}</type>
|
||||
</retraction>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "Retraction:#{data[:target_type]}:#{data[:target_guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ module DiasporaFederation
|
|||
).send(:xml_elements).merge(target: target_entity)
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<signed_retraction>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
|
|
@ -21,7 +20,7 @@ module DiasporaFederation
|
|||
<target_author_signature>#{data[:target_author_signature]}</target_author_signature>
|
||||
</signed_retraction>
|
||||
XML
|
||||
}
|
||||
|
||||
let(:string) { "SignedRetraction:#{data[:target_type]}:#{data[:target_guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ module DiasporaFederation
|
|||
)
|
||||
}
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
let(:xml) { <<-XML }
|
||||
<status_message>
|
||||
<diaspora_handle>#{data[:author]}</diaspora_handle>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
|
|
@ -52,8 +51,8 @@ module DiasporaFederation
|
|||
</location>
|
||||
<public>#{data[:public]}</public>
|
||||
</status_message>
|
||||
XML
|
||||
}
|
||||
XML
|
||||
|
||||
let(:string) { "StatusMessage:#{data[:guid]}" }
|
||||
|
||||
it_behaves_like "an Entity subclass"
|
||||
|
|
@ -61,18 +60,16 @@ module DiasporaFederation
|
|||
it_behaves_like "an XML Entity"
|
||||
|
||||
context "default values" do
|
||||
let(:minimal_xml) {
|
||||
<<-XML
|
||||
it "uses default values" do
|
||||
minimal_xml = <<-XML
|
||||
<status_message>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<created_at>#{data[:created_at]}</created_at>
|
||||
<text>#{data[:text]}</text>
|
||||
</status_message>
|
||||
XML
|
||||
}
|
||||
XML
|
||||
|
||||
it "uses default values" do
|
||||
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root)
|
||||
expect(parsed_instance.photos).to eq([])
|
||||
expect(parsed_instance.location).to be_nil
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ module DiasporaFederation
|
|||
describe Salmon::XmlPayload do
|
||||
let(:entity) { Entities::TestEntity.new(test: "asdf") }
|
||||
let(:payload) { Salmon::XmlPayload.pack(entity) }
|
||||
let(:entity_xml) {
|
||||
<<-XML.strip
|
||||
let(:entity_xml) { <<-XML.strip }
|
||||
<XML>
|
||||
<post>
|
||||
<test_entity>
|
||||
|
|
@ -12,7 +11,6 @@ module DiasporaFederation
|
|||
</post>
|
||||
</XML>
|
||||
XML
|
||||
}
|
||||
|
||||
describe ".pack" do
|
||||
it "expects an Entity as param" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue