闭社主体 forked from https://github.com/tootsuite/mastodon
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.

45 lines
1.2 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. sender.update!(uri: ActivityPub::TagManager.instance.uri_for(sender))
  9. end
  10. let(:modified_sender) do
  11. sender.dup.tap do |modified_sender|
  12. modified_sender.display_name = 'Totally modified now'
  13. end
  14. end
  15. let(:actor_json) do
  16. ActiveModelSerializers::SerializableResource.new(modified_sender, serializer: ActivityPub::ActorSerializer, key_transform: :camel_lower).as_json
  17. end
  18. let(:json) do
  19. {
  20. '@context': 'https://www.w3.org/ns/activitystreams',
  21. id: 'foo',
  22. type: 'Update',
  23. actor: ActivityPub::TagManager.instance.uri_for(sender),
  24. object: actor_json,
  25. }.with_indifferent_access
  26. end
  27. describe '#perform' do
  28. subject { described_class.new(json, sender) }
  29. before do
  30. subject.perform
  31. end
  32. it 'updates profile' do
  33. expect(sender.reload.display_name).to eq 'Totally modified now'
  34. end
  35. end
  36. end