Add test for optional old_identity on AccountMigration

This commit is contained in:
Benjamin Neff 2021-10-23 17:46:48 +02:00
parent 78ee282c9c
commit 25b5b8d888
No known key found for this signature in database
GPG key ID: 971464C3F1A90194

View file

@ -6,11 +6,11 @@ module DiasporaFederation
let(:new_diaspora_id) { new_user.diaspora_id }
let(:data) {
hash.tap {|hash|
hash.dup.tap {|data|
properties = described_class.new(hash).send(:enriched_properties)
hash[:signature] = properties[:signature]
hash[:profile] = Entities::Profile.new(hash[:profile].to_h.tap {|profile| profile[:edited_at] = nil })
hash[:remote_photo_path] = "http://localhost:3000/uploads/images/"
data[:signature] = properties[:signature]
data[:profile] = Entities::Profile.new(hash[:profile].to_h.tap {|profile| profile[:edited_at] = nil })
data[:remote_photo_path] = "http://localhost:3000/uploads/images/"
}
}
let(:signature_data) { "AccountMigration:#{old_diaspora_id}:#{new_diaspora_id}" }
@ -245,6 +245,25 @@ XML
expect(parsed_instance.old_identity).to eq(data[:author])
expect(parsed_instance.remote_photo_path).to be_nil
end
it "adds old_identity when author is the old identity" do
expected_xml = <<-XML
<account_migration>
<author>#{data[:author]}</author>
<profile>
<author>#{data[:profile].author}</author>
<searchable>true</searchable>
<public>false</public>
<nsfw>false</nsfw>
</profile>
<signature>#{data[:signature]}</signature>
<old_identity>#{data[:author]}</old_identity>
</account_migration>
XML
entity = Entities::AccountMigration.new(hash)
expect(entity.to_xml.to_s.strip).to eq(expected_xml.strip)
end
end
end
end