~cytrogen/masto-fe

ref: 8b5c61ae3a744fc847194fe784c5370c6208a012 masto-fe/spec/services/fetch_remote_status_service_spec.rb -rw-r--r-- 879 bytes
8b5c61ae — renovate[bot] Update formatjs monorepo (#26955) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe FetchRemoteStatusService, type: :service do
  let(:account) { Fabricate(:account, domain: 'example.org', uri: 'https://example.org/foo') }
  let(:prefetched_body) { nil }

  let(:note) do
    {
      '@context': 'https://www.w3.org/ns/activitystreams',
      id: 'https://example.org/@foo/1234',
      type: 'Note',
      content: 'Lorem ipsum',
      attributedTo: ActivityPub::TagManager.instance.uri_for(account),
    }
  end

  context 'when protocol is :activitypub' do
    subject { described_class.new.call(note[:id], prefetched_body: prefetched_body) }

    let(:prefetched_body) { Oj.dump(note) }

    before do
      subject
    end

    it 'creates status' do
      status = account.statuses.first

      expect(status).to_not be_nil
      expect(status.text).to eq 'Lorem ipsum'
    end
  end
end