You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

  1. require 'rails_helper'
  2. RSpec.describe ActivityPub::Activity::Update do
  3. let!(:sender) { Fabricate(:account) }
  4. before do
  5. stub_request(:get, actor_json[:outbox]).to_return(status: 404)
  6. stub_request(:get, actor_json[:followers]).to_return(status: 404)
  7. stub_request(:get, actor_json[:following]).to_return(status: 404)
  8. stub_request(:get, actor_json[:featured]).to_return(status: 404)
  9. sender.update!(uri: ActivityPub::TagManager.instance.uri_for(sender))
  10. end
  11. let(:modified_sender) do
  12. sender.dup.tap do |modified_sender|
  13. modified_sender.display_name = 'Totally modified now'
  14. end
  15. end
  16. let(:actor_json) do
  17. ActiveModelSerializers::SerializableResource.new(modified_sender, serializer: ActivityPub::ActorSerializer, key_transform: :camel_lower).as_json
  18. end
  19. let(:json) do
  20. {
  21. '@context': 'https://www.w3.org/ns/activitystreams',
  22. id: 'foo',
  23. type: 'Update',
  24. actor: ActivityPub::TagManager.instance.uri_for(sender),
  25. object: actor_json,
  26. }.with_indifferent_access
  27. end
  28. describe '#perform' do
  29. subject { described_class.new(json, sender) }
  30. before do
  31. subject.perform
  32. end
  33. it 'updates profile' do
  34. expect(sender.reload.display_name).to eq 'Totally modified now'
  35. end
  36. end
  37. end