diff options
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/activitypub/fetch_remote_status_service_spec.rb | 10 | ||||
-rw-r--r-- | spec/services/notify_service_spec.rb | 20 | ||||
-rw-r--r-- | spec/services/precompute_feed_service_spec.rb | 2 |
3 files changed, 27 insertions, 5 deletions
diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index ad26abc5b..a533e8413 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -21,6 +21,8 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do describe '#call' do before do + sender.update(uri: ActivityPub::TagManager.instance.uri_for(sender)) + stub_request(:head, 'https://example.com/watch?v=12345').to_return(status: 404, body: '') subject.call(object[:id], prefetched_body: Oj.dump(object)) end @@ -48,13 +50,13 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do { type: 'Link', mimeType: 'application/x-bittorrent', - href: 'https://example.com/12345.torrent', + href: "https://#{valid_domain}/12345.torrent", }, { type: 'Link', mimeType: 'text/html', - href: 'https://example.com/watch?v=12345', + href: "https://#{valid_domain}/watch?v=12345", }, ], } @@ -64,8 +66,8 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do status = sender.statuses.first expect(status).to_not be_nil - expect(status.url).to eq 'https://example.com/watch?v=12345' - expect(strip_tags(status.text)).to eq 'Nyan Cat 10 hours remix https://example.com/watch?v=12345' + expect(status.url).to eq "https://#{valid_domain}/watch?v=12345" + expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remix https://#{valid_domain}/watch?v=12345" end end end diff --git a/spec/services/notify_service_spec.rb b/spec/services/notify_service_spec.rb index eb6210a1e..bb7601e76 100644 --- a/spec/services/notify_service_spec.rb +++ b/spec/services/notify_service_spec.rb @@ -48,6 +48,26 @@ RSpec.describe NotifyService do is_expected.to_not change(Notification, :count) end + describe 'reblogs' do + let(:status) { Fabricate(:status, account: Fabricate(:account)) } + let(:activity) { Fabricate(:status, account: sender, reblog: status) } + + it 'shows reblogs by default' do + recipient.follow!(sender) + is_expected.to change(Notification, :count) + end + + it 'shows reblogs when explicitly enabled' do + recipient.follow!(sender, reblogs: true) + is_expected.to change(Notification, :count) + end + + it 'hides reblogs when disabled' do + recipient.follow!(sender, reblogs: false) + is_expected.to_not change(Notification, :count) + end + end + context 'for direct messages' do let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct)) } diff --git a/spec/services/precompute_feed_service_spec.rb b/spec/services/precompute_feed_service_spec.rb index d1ef6c184..396a3c3fb 100644 --- a/spec/services/precompute_feed_service_spec.rb +++ b/spec/services/precompute_feed_service_spec.rb @@ -16,7 +16,7 @@ RSpec.describe PrecomputeFeedService do subject.call(account) - expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq status.id.to_f + expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to be_within(0.1).of(status.id.to_f) end it 'does not raise an error even if it could not find any status' do |