Don't add author_signature if author also is parent author
This fully completes #64
This commit is contained in:
parent
aa40c3e8cc
commit
162c2cf21b
2 changed files with 18 additions and 2 deletions
|
|
@ -120,7 +120,7 @@ module DiasporaFederation
|
|||
# @return [Hash] properties with updated signatures
|
||||
def enriched_properties
|
||||
super.merge(additional_data).tap do |hash|
|
||||
hash[:author_signature] = author_signature || sign_with_author
|
||||
hash[:author_signature] = author_signature || sign_with_author unless author == parent.root.author
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -129,7 +129,8 @@ module DiasporaFederation
|
|||
# @return [Hash] sorted xml elements
|
||||
def xml_elements
|
||||
data = super
|
||||
order = signature_order + %i[author_signature]
|
||||
order = signature_order
|
||||
order += %i[author_signature] unless author == parent.root.author
|
||||
order.map {|element| [element, data[element].to_s] }.to_h
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -237,6 +237,21 @@ module DiasporaFederation
|
|||
}.to raise_error Entities::Relayable::AuthorPrivateKeyNotFound
|
||||
end
|
||||
|
||||
it "does not add author_signature when author is also the root author" do
|
||||
expected_xml = <<~XML
|
||||
<some_relayable>
|
||||
<author>#{author}</author>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<property>#{property}</property>
|
||||
</some_relayable>
|
||||
XML
|
||||
|
||||
xml = Entities::SomeRelayable.new(hash.merge(parent: Fabricate(:related_entity, author: author))).to_xml
|
||||
|
||||
expect(xml.to_s.strip).to eq(expected_xml.strip)
|
||||
end
|
||||
|
||||
it "adds 'false' booleans" do
|
||||
expected_xml = <<~XML
|
||||
<test_relayable_with_boolean>
|
||||
|
|
|
|||
Loading…
Reference in a new issue