From 25b5b8d8881c9c63938365d84cd6fb45fc26c1a3 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 23 Oct 2021 17:46:48 +0200 Subject: [PATCH] Add test for optional old_identity on AccountMigration --- .../entities/account_migration_spec.rb | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/spec/lib/diaspora_federation/entities/account_migration_spec.rb b/spec/lib/diaspora_federation/entities/account_migration_spec.rb index 4145aa7..1910234 100644 --- a/spec/lib/diaspora_federation/entities/account_migration_spec.rb +++ b/spec/lib/diaspora_federation/entities/account_migration_spec.rb @@ -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 + + #{data[:author]} + + #{data[:profile].author} + true + false + false + + #{data[:signature]} + #{data[:author]} + +XML + + entity = Entities::AccountMigration.new(hash) + expect(entity.to_xml.to_s.strip).to eq(expected_xml.strip) + end end end end