diff --git a/lib/diaspora_federation/entities/relayable.rb b/lib/diaspora_federation/entities/relayable.rb index 04de399..a442788 100644 --- a/lib/diaspora_federation/entities/relayable.rb +++ b/lib/diaspora_federation/entities/relayable.rb @@ -162,7 +162,12 @@ module DiasporaFederation # The order for signing # @return [Array] def signature_order - xml_order.nil? ? self.class::LEGACY_SIGNATURE_ORDER : xml_order.reject {|name| name =~ /signature/ } + if xml_order + prop_names = self.class.class_props.keys.map(&:to_s) + xml_order.reject {|name| name =~ /signature/ }.map {|name| prop_names.include?(name) ? name.to_sym : name } + else + self.class::LEGACY_SIGNATURE_ORDER + end end # @return [String] signature data string diff --git a/spec/lib/diaspora_federation/entities/relayable_spec.rb b/spec/lib/diaspora_federation/entities/relayable_spec.rb index b5b3041..5ab0fae 100644 --- a/spec/lib/diaspora_federation/entities/relayable_spec.rb +++ b/spec/lib/diaspora_federation/entities/relayable_spec.rb @@ -146,12 +146,7 @@ module DiasporaFederation end describe "#to_xml" do - it "adds new unknown xml elements to the xml again" do - hash.merge!(author_signature: "aa", parent_author_signature: "bb") - xml_order = [:author, :guid, :parent_guid, :property, "new_property"] - xml = SomeRelayable.new(hash, xml_order, "new_property" => new_property).to_xml - - expected_xml = <<-XML + let(:expected_xml) { <<-XML } #{author} #{guid} @@ -163,6 +158,19 @@ module DiasporaFederation XML + it "adds new unknown xml elements to the xml again" do + hash.merge!(author_signature: "aa", parent_author_signature: "bb") + xml_order = [:author, :guid, :parent_guid, :property, "new_property"] + xml = SomeRelayable.new(hash, xml_order, "new_property" => new_property).to_xml + + expect(xml.to_s.strip).to eq(expected_xml.strip) + end + + it "converts strings in xml_order to symbol if needed" do + hash.merge!(author_signature: "aa", parent_author_signature: "bb") + xml_order = %w(author guid parent_guid property new_property) + xml = SomeRelayable.new(hash, xml_order, "new_property" => new_property).to_xml + expect(xml.to_s.strip).to eq(expected_xml.strip) end