Merge remote-tracking branch 'parent/main' into upstream-20240112

This commit is contained in:
KMY 2024-01-12 14:48:17 +09:00
commit e65fb9fb51
333 changed files with 2661 additions and 1461 deletions

View file

@ -79,7 +79,7 @@ RSpec.describe ActivityPub::OutboxesController do
it 'returns orderedItems with public or unlisted statuses' do
expect(body[:orderedItems]).to be_an Array
expect(body[:orderedItems].size).to eq 2
expect(body[:orderedItems].all? { |item| item[:to].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:cc].include?(ActivityPub::TagManager::COLLECTIONS[:public]) }).to be true
expect(body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
end
it_behaves_like 'cacheable response'
@ -132,7 +132,7 @@ RSpec.describe ActivityPub::OutboxesController do
json = body_as_json
expect(json[:orderedItems]).to be_an Array
expect(json[:orderedItems].size).to eq 2
expect(json[:orderedItems].all? { |item| item[:to].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:cc].include?(ActivityPub::TagManager::COLLECTIONS[:public]) }).to be true
expect(json[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
end
it 'returns private Cache-Control header' do
@ -158,7 +158,7 @@ RSpec.describe ActivityPub::OutboxesController do
json = body_as_json
expect(json[:orderedItems]).to be_an Array
expect(json[:orderedItems].size).to eq 3
expect(json[:orderedItems].all? { |item| item[:to].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:cc].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:to].include?(account_followers_url(account, ActionMailer::Base.default_url_options)) }).to be true
expect(json[:orderedItems].all? { |item| targets_public_collection?(item) || targets_followers_collection?(item, account) }).to be true
end
it 'returns private Cache-Control header' do
@ -217,4 +217,20 @@ RSpec.describe ActivityPub::OutboxesController do
end
end
end
private
def ap_public_collection
ActivityPub::TagManager::COLLECTIONS[:public]
end
def targets_public_collection?(item)
item[:to].include?(ap_public_collection) || item[:cc].include?(ap_public_collection)
end
def targets_followers_collection?(item, account)
item[:to].include?(
account_followers_url(account, ActionMailer::Base.default_url_options)
)
end
end

View file

@ -84,7 +84,7 @@ RSpec.describe ActivityPub::RepliesController do
expect(page_json).to be_a Hash
expect(page_json[:items]).to be_an Array
expect(page_json[:items].size).to eq 1
expect(page_json[:items].all? { |item| item[:to].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:cc].include?(ActivityPub::TagManager::COLLECTIONS[:public]) }).to be true
expect(page_json[:items].all? { |item| targets_public_collection?(item) }).to be true
end
context 'when there are few self-replies' do
@ -117,8 +117,7 @@ RSpec.describe ActivityPub::RepliesController do
it 'only inlines items that are local and public or unlisted replies' do
inlined_replies = page_json[:items].select { |x| x.is_a?(Hash) }
public_collection = ActivityPub::TagManager::COLLECTIONS[:public]
expect(inlined_replies.all? { |item| item[:to].include?(public_collection) || item[:cc].include?(public_collection) }).to be true
expect(inlined_replies.all? { |item| targets_public_collection?(item) }).to be true
expect(inlined_replies.all? { |item| ActivityPub::TagManager.instance.local_uri?(item[:id]) }).to be true
end
@ -194,4 +193,14 @@ RSpec.describe ActivityPub::RepliesController do
end
end
end
private
def ap_public_collection
ActivityPub::TagManager::COLLECTIONS[:public]
end
def targets_public_collection?(item)
item[:to].include?(ap_public_collection) || item[:cc].include?(ap_public_collection)
end
end

View file

@ -44,7 +44,7 @@ RSpec.describe Admin::Disputes::AppealsController do
expect(response).to redirect_to(disputes_strike_path(appeal.strike))
end
it 'notifies target account about approved appeal' do
it 'notifies target account about approved appeal', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at)))
@ -62,7 +62,7 @@ RSpec.describe Admin::Disputes::AppealsController do
expect(response).to redirect_to(disputes_strike_path(appeal.strike))
end
it 'notifies target account about rejected appeal' do
it 'notifies target account about rejected appeal', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at)))

View file

@ -176,7 +176,7 @@ RSpec.describe Admin::DomainBlocksController do
end
end
describe 'PUT #update' do
describe 'PUT #update', :sidekiq_inline do
subject do
post :update, params: { :id => domain_block.id, :domain_block => { domain: 'example.com', severity: new_severity }, 'confirm' => '' }
end

View file

@ -35,6 +35,16 @@ RSpec.describe Admin::EmailDomainBlocksController do
describe 'POST #create' do
context 'when resolve button is pressed' do
before do
resolver = instance_double(Resolv::DNS)
allow(resolver).to receive(:getresources)
.with('example.com', Resolv::DNS::Resource::IN::MX)
.and_return([])
allow(resolver).to receive(:getresources).with('example.com', Resolv::DNS::Resource::IN::A).and_return([])
allow(resolver).to receive(:getresources).with('example.com', Resolv::DNS::Resource::IN::AAAA).and_return([])
allow(resolver).to receive(:timeouts=).and_return(nil)
allow(Resolv::DNS).to receive(:open).and_yield(resolver)
post :create, params: { email_domain_block: { domain: 'example.com' } }
end

View file

@ -11,7 +11,7 @@ describe Admin::ResetsController do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
end
describe 'POST #create' do
describe 'POST #create', :sidekiq_inline do
it 'redirects to admin accounts page' do
expect do
post :create, params: { account_id: account.id }

View file

@ -13,7 +13,7 @@ RSpec.describe Api::V1::ConversationsController do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
describe 'GET #index', :sidekiq_inline do
let(:scopes) { 'read:statuses' }
before do

View file

@ -9,7 +9,7 @@ describe Api::V1::Statuses::ReblogsController do
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write:statuses', application: app) }
context 'with an oauth token', :sidekiq_fake do
context 'with an oauth token' do
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
@ -46,7 +46,7 @@ describe Api::V1::Statuses::ReblogsController do
end
end
describe 'POST #destroy' do
describe 'POST #destroy', :sidekiq_inline do
context 'with public status' do
let(:status) { Fabricate(:status, account: user.account) }

View file

@ -5,7 +5,7 @@ require 'rails_helper'
describe Api::V1::StreamingController do
around do |example|
before = Rails.configuration.x.streaming_api_base_url
Rails.configuration.x.streaming_api_base_url = Rails.configuration.x.web_domain
Rails.configuration.x.streaming_api_base_url = "wss://#{Rails.configuration.x.web_domain}"
example.run
Rails.configuration.x.streaming_api_base_url = before
end

View file

@ -138,7 +138,7 @@ RSpec.describe Auth::SessionsController do
expect(controller.current_user).to eq user
end
it 'sends a suspicious sign-in mail' do
it 'sends a suspicious sign-in mail', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.suspicious_sign_in.subject'))

View file

@ -75,7 +75,7 @@ describe UserTrackingConcern do
expect(redis.ttl("account:#{user.account_id}:regeneration")).to be >= 0
end
it 'regenerates feed when sign in is older than two weeks' do
it 'regenerates feed when sign in is older than two weeks', :sidekiq_inline do
get :show
expect_updated_sign_in_at(user)

View file

@ -17,7 +17,7 @@ RSpec.describe Disputes::AppealsController do
post :create, params: { strike_id: strike.id, appeal: { text: 'Foo' } }
end
it 'notifies staff about new appeal' do
it 'notifies staff about new appeal', :sidekiq_inline do
expect(ActionMailer::Base.deliveries.first.to).to eq([admin.email])
end

View file

@ -50,7 +50,7 @@ describe Settings::DeletesController do
delete :destroy, params: { form_delete_confirmation: { password: 'petsmoldoggos' } }
end
it 'removes user record and redirects', :aggregate_failures do
it 'removes user record and redirects', :aggregate_failures, :sidekiq_inline do
expect(response).to redirect_to '/auth/sign_in'
expect(User.find_by(id: user.id)).to be_nil
expect(user.account.reload).to be_suspended

View file

@ -38,7 +38,7 @@ describe Settings::ExportsController do
expect(response).to redirect_to(settings_export_path)
end
it 'queues BackupWorker job by 1', :sidekiq_fake do
it 'queues BackupWorker job by 1' do
expect do
post :create
end.to change(BackupWorker.jobs, :size).by(1)

View file

@ -43,10 +43,20 @@ describe Settings::FeaturedTagsController do
end
describe 'GET to #index' do
let(:tag) { Fabricate(:tag) }
before do
status = Fabricate :status, account: user.account
status.tags << tag
end
it 'responds with success' do
get :index
expect(response).to have_http_status(200)
expect(response.body).to include(
settings_featured_tags_path(featured_tag: { name: tag.name })
)
end
end

View file

@ -6,6 +6,7 @@ describe Settings::LoginActivitiesController do
render_views
let!(:user) { Fabricate(:user) }
let!(:login_activity) { Fabricate :login_activity, user: user }
before do
sign_in user, scope: :user
@ -19,6 +20,10 @@ describe Settings::LoginActivitiesController do
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
expect(response.body)
.to include(login_activity.user_agent)
.and include(login_activity.authentication_method)
.and include(login_activity.ip.to_s)
end
end
end

View file

@ -48,7 +48,7 @@ describe 'Admin::Accounts' do
end
end
context 'with action of `reject`' do
context 'with action of `reject`', :sidekiq_inline do
it 'rejects and removes the account' do
batch_checkbox_for(unapproved_user_account).check

View file

@ -34,7 +34,7 @@ RSpec.describe ActivityPub::Activity::Create do
stub_request(:get, 'http://example.com/invalid-conversation').to_return(status: 404)
end
describe 'processing posts received out of order', :sidekiq_fake do
describe 'processing posts received out of order' do
let(:follower) { Fabricate(:account, username: 'bob') }
let(:object_json) do
@ -1076,7 +1076,7 @@ RSpec.describe ActivityPub::Activity::Create do
expect(status.mentions.map(&:account_id)).to contain_exactly(recipient.id, ancestor_account.id, mentioned_account.id, local_mentioned_account.id)
end
it 'forwards to observers' do
it 'forwards to observers', :sidekiq_inline do
expect(a_request(:post, 'http://or.example.com/actor/inbox')).to have_been_made.once
expect(a_request(:post, 'http://example.com/bob/inbox')).to have_been_made.once
end
@ -1119,7 +1119,7 @@ RSpec.describe ActivityPub::Activity::Create do
expect(status.mentions.map(&:account_id)).to contain_exactly(recipient.id, ancestor_account.id, mentioned_account.id, local_mentioned_account.id, new_mentioned_account.id, new_local_mentioned_account.id)
end
it 'forwards to observers' do
it 'forwards to observers', :sidekiq_inline do
expect(a_request(:post, 'http://or.example.com/actor/inbox')).to have_been_made.once
expect(a_request(:post, 'http://example.com/bob/inbox')).to have_been_made.once
expect(a_request(:post, 'http://example.com/alice/inbox')).to have_been_made.once
@ -1172,7 +1172,7 @@ RSpec.describe ActivityPub::Activity::Create do
expect(status.mentioned_accounts.map(&:uri)).to include 'https://foo.test'
end
it 'forwards to observers' do
it 'forwards to observers', :sidekiq_inline do
expect(a_request(:post, 'https://foo.test/inbox')).to have_been_made.once
end
end
@ -1189,7 +1189,7 @@ RSpec.describe ActivityPub::Activity::Create do
expect(status.mentions.map(&:account_id)).to contain_exactly(recipient.id)
end
it 'do not forward to observers' do
it 'do not forward to observers', :sidekiq_inline do
expect(a_request(:post, 'http://or.example.com/actor/inbox')).to_not have_been_made
expect(a_request(:post, 'http://example.com/bob/inbox')).to_not have_been_made
end

View file

@ -47,7 +47,7 @@ RSpec.describe ActivityPub::Activity::Delete do
expect(Status.find_by(id: status.id)).to be_nil
end
it 'sends delete activity to followers of rebloggers' do
it 'sends delete activity to followers of rebloggers', :sidekiq_inline do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
@ -91,7 +91,7 @@ RSpec.describe ActivityPub::Activity::Delete do
subject.perform
end
it 'forwards to parent status holder' do
it 'forwards to parent status holder', :sidekiq_inline do
expect(a_request(:post, 'https://example.com/inbox').with(body: hash_including({
type: 'Delete',
signature: 'foo',

View file

@ -381,7 +381,7 @@ RSpec.describe ActivityPub::Activity::Follow do
stub_request(:post, 'https://example.com/inbox')
end
it 'marks me as idle and the friend as accepted' do
it 'marks me as idle and the friend as accepted', :sidekiq_inline do
subject.perform
expect(friend.reload.they_are_accepted?).to be true
expect(friend.i_am_idle?).to be true
@ -429,7 +429,7 @@ RSpec.describe ActivityPub::Activity::Follow do
stub_request(:post, 'https://example.com/inbox')
end
it 'marks the friend as accepted' do
it 'marks the friend as accepted', :sidekiq_inline do
subject.perform
friend = FriendDomain.find_by(domain: 'abc.com')
@ -449,7 +449,7 @@ RSpec.describe ActivityPub::Activity::Follow do
stub_request(:post, 'https://example.com/inbox')
end
it 'marks the friend as accepted' do
it 'marks the friend as accepted', :sidekiq_inline do
subject.perform
friend = FriendDomain.find_by(domain: 'abc.com')

View file

@ -38,7 +38,7 @@ RSpec.describe ActivityPub::Activity::Move do
subject.perform
end
context 'when all conditions are met' do
context 'when all conditions are met', :sidekiq_inline do
it 'sets moved account on old account' do
expect(old_account.reload.moved_to_account_id).to eq new_account.id
end

View file

@ -143,7 +143,7 @@ RSpec.describe ActivityPub::Activity::Update do
subject.perform
end
it 'forwards to parent status holder' do
it 'forwards to parent status holder', :sidekiq_inline do
expect(a_request(:post, 'https://example.com/inbox').with(body: hash_including({
type: 'Update',
signature: 'foo',

View file

@ -125,5 +125,17 @@ describe ContentSecurityPolicy do
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.s3.example')
end
end
context 'when PAPERCLIP_ROOT_URL is configured' do
around do |example|
ClimateControl.modify PAPERCLIP_ROOT_URL: 'https://paperclip-host.example' do
example.run
end
end
it 'uses the provided URL in the content security policy' do
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://paperclip-host.example')
end
end
end
end

View file

@ -183,6 +183,21 @@ describe Mastodon::CLI::Media do
.to output_results('Downloaded 1 media')
end
end
context 'with --days option' do
before do
Fabricate(:media_attachment, remote_url: 'https://example.com/image.jpg', id: Mastodon::Snowflake.id_at(50.days.ago))
Fabricate(:media_attachment, remote_url: 'https://example.com/image.jpg', id: Mastodon::Snowflake.id_at(5.days.ago))
Fabricate(:media_attachment, remote_url: '', id: Mastodon::Snowflake.id_at(5.days.ago))
end
let(:options) { { days: 10 } }
it 'redownloads the attachment file for the remote records more recent than the option' do
expect { subject }
.to output_results('Downloaded 1 media')
end
end
end
describe '#remove_orphans' do

View file

@ -33,14 +33,12 @@ describe RequestPool do
subject
threads = Array.new(3) do
threads = Array.new(5) do
Thread.new do
2.times do
subject.with('http://example.com') do |http_client|
http_client.get('/').flush
# Nudge scheduler to yield and exercise the full pool
sleep(0)
end
subject.with('http://example.com') do |http_client|
http_client.get('/').flush
# Nudge scheduler to yield and exercise the full pool
sleep(0.01)
end
end
end

View file

@ -521,9 +521,11 @@ RSpec.describe Account do
results = account.excluded_from_timeline_account_ids
expect(results.size).to eq 3
expect(results).to include(block.target_account.id)
expect(results).to include(mute.target_account.id)
expect(results).to include(block_by.account.id)
expect(results).to include(
block.target_account.id,
mute.target_account.id,
block_by.account.id
)
end
end
@ -1218,4 +1220,27 @@ RSpec.describe Account do
expect(subject.reload.followers_count).to eq 15
end
end
describe '.followable_by' do
context 'with follows and follow requests' do
let!(:account) { Fabricate(:account) }
let!(:eligible_account) { Fabricate(:account) }
let!(:following_account) { Fabricate(:account) }
let!(:follow_requested_account) { Fabricate(:account) }
before do
Fabricate :follow, account: account, target_account: following_account
Fabricate :follow_request, account: account, target_account: follow_requested_account
end
it 'returns accounts not already following or requested to follow' do
results = described_class.followable_by(account)
expect(results)
.to include(eligible_account)
.and not_include(following_account)
.and not_include(follow_requested_account)
end
end
end
end

View file

@ -46,7 +46,7 @@ RSpec.describe Admin::AccountAction do
expect(target_account).to be_suspended
end
it 'queues Admin::SuspensionWorker by 1', :sidekiq_fake do
it 'queues Admin::SuspensionWorker by 1' do
expect do
subject
end.to change { Admin::SuspensionWorker.jobs.size }.by 1

View file

@ -25,22 +25,6 @@ describe Announcement do
end
end
describe '#without_muted' do
let!(:announcement) { Fabricate(:announcement) }
let(:account) { Fabricate(:account) }
let(:muted_announcement) { Fabricate(:announcement) }
before do
Fabricate(:announcement_mute, account: account, announcement: muted_announcement)
end
it 'returns the announcements not muted by the account' do
results = described_class.without_muted(account)
expect(results).to include(announcement)
expect(results).to_not include(muted_announcement)
end
end
context 'with timestamped announcements' do
let!(:adam_announcement) { Fabricate(:announcement, starts_at: 100.days.ago, scheduled_at: 10.days.ago, published_at: 10.days.ago, ends_at: 5.days.from_now) }
let!(:brenda_announcement) { Fabricate(:announcement, starts_at: 10.days.ago, scheduled_at: 100.days.ago, published_at: 10.days.ago, ends_at: 5.days.from_now) }
@ -129,32 +113,6 @@ describe Announcement do
end
end
describe '#time_range?' do
it 'returns false when starts_at and ends_at are missing' do
record = Fabricate.build(:announcement, starts_at: nil, ends_at: nil)
expect(record.time_range?).to be(false)
end
it 'returns false when starts_at is present and ends_at is missing' do
record = Fabricate.build(:announcement, starts_at: 5.days.from_now, ends_at: nil)
expect(record.time_range?).to be(false)
end
it 'returns false when starts_at is missing and ends_at is present' do
record = Fabricate.build(:announcement, starts_at: nil, ends_at: 5.days.from_now)
expect(record.time_range?).to be(false)
end
it 'returns true when starts_at and ends_at are present' do
record = Fabricate.build(:announcement, starts_at: 5.days.from_now, ends_at: 10.days.from_now)
expect(record.time_range?).to be(true)
end
end
describe '#reactions' do
context 'with announcement_reactions present' do
let!(:account) { Fabricate(:account) }

View file

@ -124,12 +124,23 @@ RSpec.describe CustomEmoji do
end
end
describe 'pre_validation' do
let(:custom_emoji) { Fabricate(:custom_emoji, domain: 'wWw.MaStOdOn.CoM') }
describe 'Normalizations' do
describe 'downcase domain value' do
context 'with a mixed case domain value' do
it 'normalizes the value to downcased' do
custom_emoji = Fabricate.build(:custom_emoji, domain: 'wWw.MaStOdOn.CoM')
it 'downcases' do
custom_emoji.valid?
expect(custom_emoji.domain).to eq('www.mastodon.com')
expect(custom_emoji.domain).to eq('www.mastodon.com')
end
end
context 'with a nil domain value' do
it 'leaves the value as nil' do
custom_emoji = Fabricate.build(:custom_emoji, domain: nil)
expect(custom_emoji.domain).to be_nil
end
end
end
end
end

View file

@ -0,0 +1,35 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe CustomFilter do
describe 'Validations' do
it 'requires presence of title' do
record = described_class.new(title: '')
record.valid?
expect(record).to model_have_error_on_field(:title)
end
it 'requires presence of context' do
record = described_class.new(context: nil)
record.valid?
expect(record).to model_have_error_on_field(:context)
end
it 'requires non-empty of context' do
record = described_class.new(context: [])
record.valid?
expect(record).to model_have_error_on_field(:context)
end
it 'requires valid context value' do
record = described_class.new(context: ['invalid'])
record.valid?
expect(record).to model_have_error_on_field(:context)
end
end
end

View file

@ -10,7 +10,7 @@ describe FriendDomain do
end
describe '#follow!' do
it 'call inbox' do
it 'call inbox', :sidekiq_inline do
friend.update(active_state: :accepted, passive_state: :accepted)
friend.follow!
expect(friend.active_follow_activity_id).to_not be_nil
@ -27,7 +27,7 @@ describe FriendDomain do
end
describe '#unfollow!' do
it 'call inbox' do
it 'call inbox', :sidekiq_inline do
friend.update(active_follow_activity_id: 'ohagi', active_state: :accepted, passive_state: :accepted)
friend.unfollow!
expect(friend.active_follow_activity_id).to be_nil
@ -46,7 +46,7 @@ describe FriendDomain do
end
describe '#accept!' do
it 'call inbox' do
it 'call inbox', :sidekiq_inline do
friend.update(passive_follow_activity_id: 'ohagi', active_state: :accepted, passive_state: :pending)
friend.accept!
expect(friend.they_are_accepted?).to be true
@ -61,7 +61,7 @@ describe FriendDomain do
end
describe '#reject!' do
it 'call inbox' do
it 'call inbox', :sidekiq_inline do
friend.update(passive_follow_activity_id: 'ohagi', active_state: :accepted, passive_state: :pending)
friend.reject!
expect(friend.they_are_rejected?).to be true
@ -76,7 +76,7 @@ describe FriendDomain do
end
describe '#delete!' do
it 'call inbox' do
it 'call inbox', :sidekiq_inline do
friend.update(active_state: :pending)
friend.destroy
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({

View file

@ -58,6 +58,88 @@ RSpec.describe Notification do
end
end
describe 'Setting account from activity_type' do
context 'when activity_type is a Status' do
it 'sets the notification from_account correctly' do
status = Fabricate(:status)
notification = Fabricate.build(:notification, activity_type: 'Status', activity: status)
expect(notification.from_account).to eq(status.account)
end
end
context 'when activity_type is a Follow' do
it 'sets the notification from_account correctly' do
follow = Fabricate(:follow)
notification = Fabricate.build(:notification, activity_type: 'Follow', activity: follow)
expect(notification.from_account).to eq(follow.account)
end
end
context 'when activity_type is a Favourite' do
it 'sets the notification from_account correctly' do
favourite = Fabricate(:favourite)
notification = Fabricate.build(:notification, activity_type: 'Favourite', activity: favourite)
expect(notification.from_account).to eq(favourite.account)
end
end
context 'when activity_type is a FollowRequest' do
it 'sets the notification from_account correctly' do
follow_request = Fabricate(:follow_request)
notification = Fabricate.build(:notification, activity_type: 'FollowRequest', activity: follow_request)
expect(notification.from_account).to eq(follow_request.account)
end
end
context 'when activity_type is a Poll' do
it 'sets the notification from_account correctly' do
poll = Fabricate(:poll)
notification = Fabricate.build(:notification, activity_type: 'Poll', activity: poll)
expect(notification.from_account).to eq(poll.account)
end
end
context 'when activity_type is a Report' do
it 'sets the notification from_account correctly' do
report = Fabricate(:report)
notification = Fabricate.build(:notification, activity_type: 'Report', activity: report)
expect(notification.from_account).to eq(report.account)
end
end
context 'when activity_type is a Mention' do
it 'sets the notification from_account correctly' do
mention = Fabricate(:mention)
notification = Fabricate.build(:notification, activity_type: 'Mention', activity: mention)
expect(notification.from_account).to eq(mention.status.account)
end
end
context 'when activity_type is an Account' do
it 'sets the notification from_account correctly' do
account = Fabricate(:account)
notification = Fabricate.build(:notification, activity_type: 'Account', account: account)
expect(notification.account).to eq(account)
end
end
end
describe '.preload_cache_collection_target_statuses' do
subject do
described_class.preload_cache_collection_target_statuses(notifications) do |target_statuses|

View file

@ -13,189 +13,65 @@ RSpec.describe Setting do
end
describe '.[]' do
let(:key) { 'key' }
let(:cache_key) { 'cache-key' }
let(:cache_value) { 'cache-value' }
before do
allow(described_class).to receive(:rails_initialized?).and_return(rails_initialized)
allow(described_class).to receive(:cache_key).with(key).and_return(cache_key)
end
let(:key) { 'key' }
context 'when rails_initialized? is falsey' do
let(:rails_initialized) { false }
it 'calls RailsSettings::Base#[]' do
allow(RailsSettings::Base).to receive(:[]).with(key)
described_class[key]
expect(RailsSettings::Base).to have_received(:[]).with(key)
end
end
context 'when rails_initialized? is truthy' do
context 'when Rails.cache does not exists' do
before do
allow(RailsSettings::Base).to receive(:cache_key).with(key, nil).and_return(cache_key)
allow(described_class).to receive(:default_settings).and_return(default_settings)
Fabricate(:setting, var: key, value: 42) if save_setting
Rails.cache.delete(cache_key)
end
let(:rails_initialized) { true }
let(:cache_key) { 'cache-key' }
let(:cache_value) { 'cache-value' }
let(:default_value) { 'default_value' }
let(:default_settings) { { key => default_value } }
let(:save_setting) { true }
it 'calls not RailsSettings::Base#[]' do
allow(RailsSettings::Base).to receive(:[]).with(key)
described_class[key]
expect(RailsSettings::Base).to_not have_received(:[]).with(key)
end
context 'when Rails.cache does not exists' do
before do
allow(RailsSettings::Settings).to receive(:object).with(key).and_return(object)
allow(described_class).to receive(:default_settings).and_return(default_settings)
settings_double = instance_double(Settings::ScopedSettings, thing_scoped: records)
allow(Settings::ScopedSettings).to receive(:new).and_return(settings_double)
Rails.cache.delete(cache_key)
end
let(:object) { nil }
let(:default_value) { 'default_value' }
let(:default_settings) { { key => default_value } }
let(:records) { [Fabricate(:setting, var: key, value: nil)] }
it 'calls RailsSettings::Settings.object' do
allow(RailsSettings::Settings).to receive(:object).with(key)
described_class[key]
expect(RailsSettings::Settings).to have_received(:object).with(key)
end
context 'when RailsSettings::Settings.object returns truthy' do
let(:object) { db_val }
let(:db_val) { instance_double(described_class, value: 'db_val') }
context 'when default_value is a Hash' do
let(:default_value) { { default_value: 'default_value' } }
it 'calls default_value.with_indifferent_access.merge!' do
indifferent_hash = instance_double(Hash, merge!: nil)
allow(default_value).to receive(:with_indifferent_access).and_return(indifferent_hash)
described_class[key]
expect(default_value).to have_received(:with_indifferent_access)
expect(indifferent_hash).to have_received(:merge!).with(db_val.value)
end
end
context 'when default_value is not a Hash' do
let(:default_value) { 'default_value' }
it 'returns db_val.value' do
expect(described_class[key]).to be db_val.value
end
end
end
context 'when RailsSettings::Settings.object returns falsey' do
let(:object) { nil }
it 'returns default_settings[key]' do
expect(described_class[key]).to be default_settings[key]
end
end
end
context 'when Rails.cache exists' do
before do
Rails.cache.write(cache_key, cache_value)
end
it 'does not query the database' do
context 'when the setting has been saved to database' do
it 'returns the value from database' do
callback = double
allow(callback).to receive(:call)
ActiveSupport::Notifications.subscribed callback, 'sql.active_record' do
described_class[key]
expect(described_class[key]).to eq 42
end
expect(callback).to_not have_received(:call)
end
it 'returns the cached value' do
expect(described_class[key]).to eq cache_value
end
end
end
end
describe '.all_as_records' do
before do
settings_double = instance_double(Settings::ScopedSettings, thing_scoped: records)
allow(Settings::ScopedSettings).to receive(:new).and_return(settings_double)
allow(described_class).to receive(:default_settings).and_return(default_settings)
end
let(:key) { 'key' }
let(:default_value) { 'default_value' }
let(:default_settings) { { key => default_value } }
let(:original_setting) { Fabricate(:setting, var: key, value: nil) }
let(:records) { [original_setting] }
it 'returns a Hash' do
expect(described_class.all_as_records).to be_a Hash
end
context 'when records includes Setting with var as the key' do
let(:records) { [original_setting] }
it 'includes the original Setting' do
setting = described_class.all_as_records[key]
expect(setting).to eq original_setting
end
end
context 'when records includes nothing' do
let(:records) { [] }
context 'when default_value is not a Hash' do
it 'includes Setting with value of default_value' do
setting = described_class.all_as_records[key]
expect(setting).to be_a described_class
expect(setting).to have_attributes(var: key)
expect(setting).to have_attributes(value: 'default_value')
expect(callback).to have_received(:call)
end
end
context 'when default_value is a Hash' do
let(:default_value) { { 'foo' => 'fuga' } }
context 'when the setting has not been saved to database' do
let(:save_setting) { false }
it 'returns {}' do
expect(described_class.all_as_records).to eq({})
it 'returns default_settings[key]' do
expect(described_class[key]).to be default_settings[key]
end
end
end
end
describe '.default_settings' do
subject { described_class.default_settings }
before do
allow(RailsSettings::Default).to receive(:enabled?).and_return(enabled)
end
context 'when RailsSettings::Default.enabled? is false' do
let(:enabled) { false }
it 'returns {}' do
expect(subject).to eq({})
context 'when Rails.cache exists' do
before do
Rails.cache.write(cache_key, cache_value)
end
end
context 'when RailsSettings::Settings.enabled? is true' do
let(:enabled) { true }
it 'does not query the database' do
callback = double
allow(callback).to receive(:call)
ActiveSupport::Notifications.subscribed callback, 'sql.active_record' do
described_class[key]
end
expect(callback).to_not have_received(:call)
end
it 'returns instance of RailsSettings::Default' do
expect(subject).to be_a RailsSettings::Default
it 'returns the cached value' do
expect(described_class[key]).to eq cache_value
end
end
end

View file

@ -38,27 +38,53 @@ RSpec.describe User do
user.save(validate: false)
expect(user.valid?).to be true
end
end
it 'cleans out invalid locale' do
user = Fabricate.build(:user, locale: 'toto')
expect(user.valid?).to be true
expect(user.locale).to be_nil
describe 'Normalizations' do
describe 'locale' do
it 'preserves valid locale' do
user = Fabricate.build(:user, locale: 'en')
expect(user.locale).to eq('en')
end
it 'cleans out invalid locale' do
user = Fabricate.build(:user, locale: 'toto')
expect(user.locale).to be_nil
end
end
it 'cleans out invalid timezone' do
user = Fabricate.build(:user, time_zone: 'toto')
expect(user.valid?).to be true
expect(user.time_zone).to be_nil
describe 'time_zone' do
it 'preserves valid timezone' do
user = Fabricate.build(:user, time_zone: 'UTC')
expect(user.time_zone).to eq('UTC')
end
it 'cleans out invalid timezone' do
user = Fabricate.build(:user, time_zone: 'toto')
expect(user.time_zone).to be_nil
end
end
it 'cleans out empty string from languages' do
user = Fabricate.build(:user, chosen_languages: [''])
user.valid?
expect(user.chosen_languages).to be_nil
describe 'languages' do
it 'preserves valid options for languages' do
user = Fabricate.build(:user, chosen_languages: ['en', 'fr', ''])
expect(user.chosen_languages).to eq(['en', 'fr'])
end
it 'cleans out empty string from languages' do
user = Fabricate.build(:user, chosen_languages: [''])
expect(user.chosen_languages).to be_nil
end
end
end
describe 'scopes' do
describe 'scopes', :sidekiq_inline do
describe 'recent' do
it 'returns an array of recent users ordered by id' do
first_user = Fabricate(:user)
@ -452,7 +478,7 @@ RSpec.describe User do
expect(user.confirmed_at).to be_present
end
it 'delivers mails' do
it 'delivers mails', :sidekiq_inline do
expect(ActionMailer::Base.deliveries.count).to eq 2
end
end

View file

@ -26,7 +26,6 @@ Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
ActiveRecord::Migration.maintain_test_schema!
WebMock.disable_net_connect!(allow: Chewy.settings[:host], allow_localhost: RUN_SYSTEM_SPECS)
Sidekiq::Testing.inline!
Sidekiq.logger = nil
# System tests config
@ -96,11 +95,8 @@ RSpec.configure do |config|
self.use_transactional_tests = true
end
config.around(:each, :sidekiq_fake) do |example|
Sidekiq::Testing.fake! do
example.run
Sidekiq::Worker.clear_all
end
config.around(:each, :sidekiq_inline) do |example|
Sidekiq::Testing.inline!(&example)
end
config.before :each, type: :cli do
@ -111,21 +107,8 @@ RSpec.configure do |config|
Capybara.current_driver = :rack_test
end
config.around :each, type: :system do |example|
driven_by :selenium, using: :headless_chrome, screen_size: [1600, 1200]
# The streaming server needs access to the database
# but with use_transactional_tests every transaction
# is rolled-back, so the streaming server never sees the data
# So we disable this feature for system tests, and use DatabaseCleaner to clean
# the database tables between each test
self.use_transactional_tests = false
DatabaseCleaner.cleaning do
example.run
end
self.use_transactional_tests = true
config.before do |example|
allow(Resolv::DNS).to receive(:open).and_raise('Real DNS queries are disabled, stub Resolv::DNS as needed') unless example.metadata[:type] == :system
end
config.before do |example|

View file

@ -177,7 +177,9 @@ RSpec.describe 'IP Blocks' do
let(:params) { { severity: 'sign_up_requires_approval', comment: 'Decreasing severity' } }
it 'returns the correct ip block', :aggregate_failures do
subject
expect { subject }
.to change_severity_level
.and change_comment_value
expect(response).to have_http_status(200)
expect(body_as_json).to match(hash_including({
@ -187,12 +189,12 @@ RSpec.describe 'IP Blocks' do
}))
end
it 'updates the severity correctly' do
expect { subject }.to change { ip_block.reload.severity }.from('no_access').to('sign_up_requires_approval')
def change_severity_level
change { ip_block.reload.severity }.from('no_access').to('sign_up_requires_approval')
end
it 'updates the comment correctly' do
expect { subject }.to change { ip_block.reload.comment }.from('Spam').to('Decreasing severity')
def change_comment_value
change { ip_block.reload.comment }.from('Spam').to('Decreasing severity')
end
context 'when ip block does not exist' do

View file

@ -32,18 +32,18 @@ describe 'Links' do
it_behaves_like 'forbidden for wrong role', ''
it 'returns http success' do
subject
expect { subject }
.to change_link_trendable_to_true
expect(response).to have_http_status(200)
expects_correct_link_data
end
it 'sets the link as trendable' do
expect { subject }.to change { preview_card.reload.trendable }.from(false).to(true)
def change_link_trendable_to_true
change { preview_card.reload.trendable }.from(false).to(true)
end
it 'returns the link data' do
subject
def expects_correct_link_data
expect(body_as_json).to match(
a_hash_including(
url: preview_card.url,
@ -85,13 +85,14 @@ describe 'Links' do
it_behaves_like 'forbidden for wrong role', ''
it 'returns http success' do
subject
expect { subject }
.to_not change_link_trendable
expect(response).to have_http_status(200)
end
it 'does not set the link as trendable' do
expect { subject }.to_not(change { preview_card.reload.trendable })
def change_link_trendable
change { preview_card.reload.trendable }
end
it 'returns the link data' do

View file

@ -147,7 +147,7 @@ RSpec.describe 'FeaturedTags' do
expect(body).to be_empty
end
it 'deletes the featured tag' do
it 'deletes the featured tag', :sidekiq_inline do
delete "/api/v1/featured_tags/#{id}", headers: headers
featured_tag = FeaturedTag.find_by(id: id)

View file

@ -8,7 +8,7 @@ RSpec.describe 'Notifications' do
let(:scopes) { 'read:notifications write:notifications' }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
describe 'GET /api/v1/notifications' do
describe 'GET /api/v1/notifications', :sidekiq_inline do
subject do
get '/api/v1/notifications', headers: headers, params: params
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe 'Favourites' do
RSpec.describe 'Favourites', :sidekiq_inline do
let(:user) { Fabricate(:user) }
let(:scopes) { 'write:favourites' }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
@ -70,7 +70,7 @@ RSpec.describe 'Favourites' do
end
end
describe 'POST /api/v1/statuses/:status_id/unfavourite', :sidekiq_fake do
describe 'POST /api/v1/statuses/:status_id/unfavourite' do
subject do
post "/api/v1/statuses/#{status.id}/unfavourite", headers: headers
end
@ -88,9 +88,7 @@ RSpec.describe 'Favourites' do
subject
expect(response).to have_http_status(200)
expect(user.account.favourited?(status)).to be true
UnfavouriteWorker.drain
expect(user.account.favourited?(status)).to be false
end
@ -113,9 +111,7 @@ RSpec.describe 'Favourites' do
subject
expect(response).to have_http_status(200)
expect(user.account.favourited?(status)).to be true
UnfavouriteWorker.drain
expect(user.account.favourited?(status)).to be false
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Home' do
describe 'Home', :sidekiq_inline do
let(:user) { Fabricate(:user) }
let(:scopes) { 'read:statuses' }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe Account::StatusesSearch do
describe Account::StatusesSearch, :sidekiq_inline do
describe 'a non-indexable account becoming indexable' do
let(:account) { Account.find_by(username: 'search_test_account_1') }

View file

@ -225,7 +225,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
end
end
context 'with statuses referencing other statuses' do
context 'with statuses referencing other statuses', :sidekiq_inline do
before do
stub_const 'ActivityPub::FetchRemoteStatusService::DISCOVERIES_PER_REQUEST', 5
end

View file

@ -447,7 +447,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
end
end
it 'creates accounts without exceeding rate limit' do
it 'creates accounts without exceeding rate limit', :sidekiq_inline do
expect { subject.call('user1', 'foo.test', payload) }
.to create_some_remote_accounts
.and create_fewer_than_rate_limit_accounts

View file

@ -41,7 +41,7 @@ RSpec.describe AuthorizeFollowService, type: :service do
expect(bob.following?(sender)).to be true
end
it 'sends an accept activity' do
it 'sends an accept activity', :sidekiq_inline do
expect(a_request(:post, bob.inbox_url)).to have_been_made.once
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe BatchedRemoveStatusService, type: :service do
RSpec.describe BatchedRemoveStatusService, :sidekiq_inline, type: :service do
subject { described_class.new }
let!(:alice) { Fabricate(:account) }

View file

@ -90,7 +90,7 @@ RSpec.describe BlockDomainService, type: :service do
expect(already_banned_account.reload.silenced_at).to_not eq DomainBlock.find_by(domain: 'evil.org').created_at
end
it 'leaves the domains status and attachments, but clears media' do
it 'leaves the domains status and attachments, but clears media', :sidekiq_inline do
expect { bad_status_plain.reload }.to_not raise_error
expect { bad_status_with_attachment.reload }.to_not raise_error
expect { bad_attachment.reload }.to_not raise_error

View file

@ -31,7 +31,7 @@ RSpec.describe BlockService, type: :service do
expect(sender.blocking?(bob)).to be true
end
it 'sends a block activity' do
it 'sends a block activity', :sidekiq_inline do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
end

View file

@ -12,7 +12,7 @@ RSpec.describe BulkImportService do
import.update(total_items: import.rows.count)
end
describe '#call', :sidekiq_fake do
describe '#call' do
context 'when importing follows' do
let(:import_type) { 'following' }
let(:overwrite) { false }

View file

@ -110,7 +110,7 @@ RSpec.describe DeleteAccountService, type: :service do
end
end
describe '#call on local account' do
describe '#call on local account', :sidekiq_inline do
before do
stub_request(:post, remote_alice.inbox_url).to_return(status: 201)
stub_request(:post, remote_bob.inbox_url).to_return(status: 201)
@ -131,7 +131,7 @@ RSpec.describe DeleteAccountService, type: :service do
end
end
describe '#call on remote account' do
describe '#call on remote account', :sidekiq_inline do
before do
stub_request(:post, account.inbox_url).to_return(status: 201)
end

View file

@ -88,11 +88,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_account(bob, alice) }
let!(:empty_antenna) { antenna_with_account(tom, bob) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -100,7 +100,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
context 'when blocked' do
let!(:empty_antenna) { antenna_with_account(ohagi, alice) }
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -109,7 +109,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
let(:last_active_at_tom) { Time.now.utc.ago(1.year) }
let!(:empty_antenna) { antenna_with_account(tom, alice) }
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -119,11 +119,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_domain(bob, 'fast.example.com') }
let!(:empty_antenna) { antenna_with_domain(tom, 'ohagi.example.com') }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -133,18 +133,18 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_domain(bob, 'cb6e6126.ngrok.io') }
let!(:empty_antenna) { antenna_with_domain(tom, 'ohagi.example.com') }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
context 'when local timeline is disabled' do
let(:ltl_enabled) { false }
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -155,11 +155,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_tag(bob, 'hoge') }
let!(:empty_antenna) { antenna_with_tag(tom, 'hog') }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -168,11 +168,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_keyword(bob, 'body') }
let!(:empty_antenna) { antenna_with_keyword(tom, 'anime') }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -182,11 +182,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_keyword(bob, 'some') }
let!(:empty_antenna) { antenna_with_keyword(tom, 'anime') }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -196,11 +196,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_keyword(bob, 'body') }
let!(:empty_antenna) { antenna_with_keyword(tom, 'anime') }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -210,11 +210,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_domain(bob, 'fast.example.com', exclude_accounts: [tom.id]) }
let!(:empty_antenna) { antenna_with_domain(tom, 'fast.example.com', exclude_accounts: [alice.id]) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -224,11 +224,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_domain(bob, 'fast.example.com', exclude_keywords: ['aaa']) }
let!(:empty_antenna) { antenna_with_domain(tom, 'fast.example.com', exclude_keywords: ['body']) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -238,11 +238,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_domain(bob, 'fast.example.com') }
let!(:empty_antenna) { antenna_with_domain(tom, 'fast.example.com', exclude_tags: [Tag.find_or_create_by_names(['hoge']).first.id]) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -252,11 +252,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_keyword(bob, 'body', exclude_domains: ['ohagi.example.com']) }
let!(:empty_antenna) { antenna_with_keyword(tom, 'body', exclude_domains: ['fast.example.com']) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -265,7 +265,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_keyword(bob, 'body') }
let!(:empty_antenna) { antenna_with_keyword(tom, 'body') }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to include status.id
end
@ -276,7 +276,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:empty_antenna) { antenna_with_keyword(tom, 'body') }
[1, 2, 3, 4, 5].each do |_|
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to include status.id
end
@ -287,7 +287,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_keyword(bob, 'body', insert_feeds: true) }
let!(:empty_antenna) { antenna_with_keyword(tom, 'body', insert_feeds: true) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(home_feed_of(bob)).to include status.id
expect(antenna_feed_of(empty_antenna)).to include status.id
@ -299,7 +299,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
let!(:antenna) { antenna_with_keyword(bob, 'body', insert_feeds: true, list: list(bob)) }
let!(:empty_antenna) { antenna_with_keyword(tom, 'body', insert_feeds: true, list: list(tom)) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(list_feed_of(antenna.list)).to include status.id
expect(antenna_feed_of(empty_antenna)).to include status.id
@ -313,11 +313,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
let(:visibility) { :unlisted }
context 'when public searchability' do
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -325,11 +325,11 @@ RSpec.describe DeliveryAntennaService, type: :service do
context 'when public_unlisted searchability' do
let(:searchability) { :public_unlisted }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -337,7 +337,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
context 'when private searchability' do
let(:searchability) { :private }
it 'not detecting antenna' do
it 'not detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -350,7 +350,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
let(:visibility) { :unlisted }
context 'when public searchability' do
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to include status.id
end
@ -359,7 +359,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
context 'when public_unlisted searchability' do
let(:searchability) { :public_unlisted }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to include status.id
end
@ -368,7 +368,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
context 'when private searchability' do
let(:searchability) { :private }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to include status.id
end
@ -379,7 +379,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
let(:mode) { :stl }
let!(:antenna) { antenna_with_keyword(bob, 'anime', stl: true) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end
@ -388,7 +388,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
let(:mode) { :ltl }
let!(:antenna) { antenna_with_keyword(bob, 'anime', ltl: true) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end
@ -397,7 +397,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
let(:mode) { :stl }
let!(:antenna) { antenna_with_keyword(bob, 'anime', exclude_keywords: ['body'], stl: true) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end
@ -406,7 +406,7 @@ RSpec.describe DeliveryAntennaService, type: :service do
let(:mode) { :ltl }
let!(:antenna) { antenna_with_keyword(bob, 'anime', exclude_keywords: ['body'], ltl: true) }
it 'detecting antenna' do
it 'detecting antenna', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end

View file

@ -168,7 +168,7 @@ RSpec.describe EmojiReactService, type: :service do
stub_request(:post, 'https://author.foo.bar/inbox')
end
it 'react with emoji' do
it 'react with emoji', :sidekiq_inline do
expect(subject.count).to eq 1
expect(a_request(:post, 'https://author.foo.bar/inbox').with(body: hash_including({
type: 'Like',
@ -185,7 +185,7 @@ RSpec.describe EmojiReactService, type: :service do
stub_request(:post, 'https://foo.bar/inbox')
end
it 'react with emoji' do
it 'react with emoji', :sidekiq_inline do
expect(subject.count).to eq 1
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
type: 'Like',
@ -204,7 +204,7 @@ RSpec.describe EmojiReactService, type: :service do
stub_request(:post, 'https://foo.bar/inbox')
end
it 'react with emoji' do
it 'react with emoji', :sidekiq_inline do
expect(subject.count).to eq 1
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
type: 'Like',
@ -220,7 +220,7 @@ RSpec.describe EmojiReactService, type: :service do
stub_request(:post, 'https://foo.bar/inbox')
end
it 'react with emoji' do
it 'react with emoji', :sidekiq_inline do
expect(subject.count).to eq 1
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
type: 'Like',
@ -236,7 +236,7 @@ RSpec.describe EmojiReactService, type: :service do
stub_request(:post, 'https://foo.bar/inbox')
end
it 'react with emoji' do
it 'react with emoji', :sidekiq_inline do
expect(subject.count).to eq 1
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
type: 'Like',

View file

@ -37,6 +37,8 @@ RSpec.describe FanOutOnWriteService, type: :service do
ProcessMentionsService.new.call(status)
ProcessHashtagsService.new.call(status)
Fabricate(:media_attachment, status: status, account: alice)
allow(redis).to receive(:publish)
tag = status.tags.first
@ -83,38 +85,43 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when status is public' do
let(:visibility) { 'public' }
it 'is added to the home feed of its author' do
it 'is added to the home feed of its author', :sidekiq_inline do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of a follower' do
it 'is added to the home feed of the mentioned follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
end
it 'is added to the home feed of a follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
expect(home_feed_of(tom)).to include status.id
end
it 'is added to the tag follower' do
it 'is added to the tag follower', :sidekiq_inline do
expect(home_feed_of(tagf)).to include status.id
end
it 'is broadcast to the hashtag stream' do
it 'is broadcast to the hashtag stream', :sidekiq_inline do
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge:local', anything)
end
it 'is broadcast to the public stream' do
it 'is broadcast to the public stream', :sidekiq_inline do
expect(redis).to have_received(:publish).with('timeline:public', anything)
expect(redis).to have_received(:publish).with('timeline:public:local', anything)
expect(redis).to have_received(:publish).with('timeline:public:media', anything)
end
context 'when local timeline is disabled' do
context 'when local timeline is disabled', :sidekiq_inline do
let(:ltl_enabled) { false }
it 'is broadcast to the hashtag stream' do
it 'is broadcast to the hashtag stream', :sidekiq_inline do
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge:local', anything)
end
it 'is broadcast to the public stream' do
it 'is broadcast to the public stream', :sidekiq_inline do
expect(redis).to have_received(:publish).with('timeline:public', anything)
expect(redis).to_not have_received(:publish).with('timeline:public:local', anything)
end
@ -124,7 +131,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:list) { list_with_account(bob, alice) }
let!(:empty_list) { Fabricate(:list, account: tom) }
it 'is added to the list feed of list follower' do
it 'is added to the list feed of list follower', :sidekiq_inline do
expect(list_feed_of(list)).to include status.id
expect(list_feed_of(empty_list)).to_not include status.id
end
@ -134,7 +141,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_account(bob, alice) }
let!(:empty_antenna) { antenna_with_account(tom, bob) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -142,7 +149,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when subscription is blocked' do
let(:subscription_policy) { :block }
it 'is not added to the antenna feed' do
it 'is not added to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
end
end
@ -151,14 +158,14 @@ RSpec.describe FanOutOnWriteService, type: :service do
let(:subscription_policy) { :followers_only }
let!(:antenna) { antenna_with_account(ohagi, alice) }
it 'is not added to the antenna feed' do
it 'is not added to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
end
context 'with following' do
let!(:antenna) { antenna_with_account(bob, alice) }
it 'is added to the antenna feed' do
it 'is added to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end
@ -174,7 +181,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
end
context 'with listening tag' do
it 'is added to the antenna feed' do
it 'is added to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end
@ -182,7 +189,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'with listening tag but sender is limiting subscription' do
let(:subscription_policy) { :block }
it 'does not add to the antenna feed' do
it 'does not add to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
end
end
@ -197,7 +204,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
subject.call(status)
end
it 'is added to the antenna feed' do
it 'is added to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end
@ -208,7 +215,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_options(bob, stl: true) }
let!(:empty_antenna) { antenna_with_options(tom) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -216,7 +223,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when subscription is blocked' do
let(:subscription_policy) { :block }
it 'is added to the antenna feed' do
it 'is added to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end
@ -235,7 +242,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_options(bob, ltl: true) }
let!(:empty_antenna) { antenna_with_options(tom) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -243,7 +250,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when subscription is blocked' do
let(:subscription_policy) { :block }
it 'is added to the antenna feed' do
it 'is added to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end
@ -251,14 +258,14 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when local timeline is disabled' do
let(:ltl_enabled) { false }
it 'is not added to the antenna feed of antenna follower' do
it 'is not added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
end
context 'when handling status updates', :sidekiq_fake do
context 'when handling status updates' do
before do
subject.call(status)
@ -267,8 +274,6 @@ RSpec.describe FanOutOnWriteService, type: :service do
status.snapshot!(account_id: status.account_id)
redis.set("subscribed:timeline:#{eve.id}:notifications", '1')
Sidekiq::Worker.clear_all
end
it 'pushes the update to mentioned users through the notifications streaming channel' do
@ -281,23 +286,23 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when status is limited' do
let(:visibility) { 'limited' }
it 'is added to the home feed of its author' do
it 'is added to the home feed of its author', :sidekiq_inline do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of the mentioned follower' do
it 'is added to the home feed of the mentioned follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
end
it 'is not added to the home feed of the other follower' do
it 'is not added to the home feed of the other follower', :sidekiq_inline do
expect(home_feed_of(tom)).to_not include status.id
end
it 'is not added to the tag follower' do
it 'is not added to the tag follower', :sidekiq_inline do
expect(home_feed_of(tagf)).to_not include status.id
end
it 'is not broadcast publicly' do
it 'is not broadcast publicly', :sidekiq_inline do
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
end
@ -306,7 +311,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:list) { list_with_account(bob, alice) }
let!(:empty_list) { list_with_account(tom, alice) }
it 'is added to the list feed of list follower' do
it 'is added to the list feed of list follower', :sidekiq_inline do
expect(list_feed_of(list)).to include status.id
expect(list_feed_of(empty_list)).to_not include status.id
end
@ -316,7 +321,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_account(bob, alice) }
let!(:empty_antenna) { antenna_with_account(tom, alice) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -326,7 +331,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_options(bob, stl: true) }
let!(:empty_antenna) { antenna_with_options(tom, stl: true) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -335,7 +340,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'with LTL antenna' do
let!(:empty_antenna) { antenna_with_options(bob, ltl: true) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -344,29 +349,33 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when status is private' do
let(:visibility) { 'private' }
it 'is added to the home feed of its author' do
it 'is added to the home feed of its author', :sidekiq_inline do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of a follower' do
it 'is added to the home feed of a follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
expect(home_feed_of(tom)).to include status.id
end
it 'is not added to the tag follower' do
it 'is not added to the tag follower', :sidekiq_inline do
expect(home_feed_of(tagf)).to_not include status.id
end
it 'is not broadcast publicly' do
it 'is not broadcast publicly', :sidekiq_inline do
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
end
it 'is added to the home feed of the mentioned follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
end
context 'with list' do
let!(:list) { list_with_account(bob, alice) }
let!(:empty_list) { list_with_account(ohagi, bob) }
it 'is added to the list feed of list follower' do
it 'is added to the list feed of list follower', :sidekiq_inline do
expect(list_feed_of(list)).to include status.id
expect(list_feed_of(empty_list)).to_not include status.id
end
@ -376,7 +385,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_account(bob, alice) }
let!(:empty_antenna) { antenna_with_account(ohagi, alice) }
it 'is added to the list feed of list follower' do
it 'is added to the list feed of list follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -386,7 +395,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_options(bob, stl: true) }
let!(:empty_antenna) { antenna_with_options(ohagi, stl: true) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -394,7 +403,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when local timeline is disabled' do
let(:ltl_enabled) { false }
it 'is not added to the antenna feed of antenna follower' do
it 'is not added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -404,14 +413,14 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'with LTL antenna' do
let!(:empty_antenna) { antenna_with_options(bob, ltl: true) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
context 'when local timeline is disabled' do
let(:ltl_enabled) { false }
it 'is not added to the antenna feed of antenna follower' do
it 'is not added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -421,20 +430,20 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when status is public_unlisted' do
let(:visibility) { 'public_unlisted' }
it 'is added to the home feed of its author' do
it 'is added to the home feed of its author', :sidekiq_inline do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of a follower' do
it 'is added to the home feed of a follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
expect(home_feed_of(tom)).to include status.id
end
it 'is added to the tag follower' do
it 'is added to the tag follower', :sidekiq_inline do
expect(home_feed_of(tagf)).to include status.id
end
it 'is broadcast publicly' do
it 'is broadcast publicly', :sidekiq_inline do
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to have_received(:publish).with('timeline:public:local', anything)
expect(redis).to have_received(:publish).with('timeline:public', anything)
@ -443,12 +452,12 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when local timeline is disabled' do
let(:ltl_enabled) { false }
it 'is broadcast to the hashtag stream' do
it 'is broadcast to the hashtag stream', :sidekiq_inline do
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge:local', anything)
end
it 'is broadcast to the public stream' do
it 'is broadcast to the public stream', :sidekiq_inline do
expect(redis).to have_received(:publish).with('timeline:public', anything)
expect(redis).to_not have_received(:publish).with('timeline:public:local', anything)
end
@ -458,7 +467,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:list) { list_with_account(bob, alice) }
let!(:empty_list) { list_with_account(ohagi, bob) }
it 'is added to the list feed of list follower' do
it 'is added to the list feed of list follower', :sidekiq_inline do
expect(list_feed_of(list)).to include status.id
expect(list_feed_of(empty_list)).to_not include status.id
end
@ -468,7 +477,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_account(bob, alice) }
let!(:empty_antenna) { antenna_with_account(tom, bob) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -476,7 +485,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when subscription is blocked' do
let(:subscription_policy) { :block }
it 'is not added to the antenna feed' do
it 'is not added to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
end
end
@ -486,7 +495,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_options(bob, stl: true) }
let!(:empty_antenna) { antenna_with_options(tom) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -494,7 +503,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when subscription is blocked' do
let(:subscription_policy) { :block }
it 'is added to the antenna feed' do
it 'is added to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end
@ -502,7 +511,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when local timeline is disabled' do
let(:ltl_enabled) { false }
it 'is not added to the antenna feed of antenna follower' do
it 'is not added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -513,7 +522,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_options(bob, ltl: true) }
let!(:empty_antenna) { antenna_with_options(tom) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -521,7 +530,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when subscription is blocked' do
let(:subscription_policy) { :block }
it 'is added to the antenna feed' do
it 'is added to the antenna feed', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
end
end
@ -529,7 +538,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when local timeline is disabled' do
let(:ltl_enabled) { false }
it 'is not added to the antenna feed of antenna follower' do
it 'is not added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -540,20 +549,20 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when status is unlisted' do
let(:visibility) { 'unlisted' }
it 'is added to the home feed of its author' do
it 'is added to the home feed of its author', :sidekiq_inline do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of a follower' do
it 'is added to the home feed of a follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
expect(home_feed_of(tom)).to include status.id
end
it 'is added to the tag follower' do
it 'is added to the tag follower', :sidekiq_inline do
expect(home_feed_of(tagf)).to include status.id
end
it 'is not broadcast publicly' do
it 'is not broadcast publicly', :sidekiq_inline do
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
end
@ -561,12 +570,12 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'with searchability public_unlisted' do
let(:searchability) { 'public_unlisted' }
it 'is broadcast to the hashtag stream' do
it 'is broadcast to the hashtag stream', :sidekiq_inline do
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge:local', anything)
end
it 'is added to the tag follower' do
it 'is added to the tag follower', :sidekiq_inline do
expect(home_feed_of(tagf)).to include status.id
end
end
@ -574,12 +583,12 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'with searchability private' do
let(:searchability) { 'private' }
it 'is not broadcast to the hashtag stream' do
it 'is not broadcast to the hashtag stream', :sidekiq_inline do
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge:local', anything)
end
it 'is not added to the tag follower' do
it 'is not added to the tag follower', :sidekiq_inline do
expect(home_feed_of(tagf)).to_not include status.id
end
end
@ -587,7 +596,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when local timeline is disabled' do
let(:ltl_enabled) { false }
it 'is broadcast to the hashtag stream' do
it 'is broadcast to the hashtag stream', :sidekiq_inline do
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge:local', anything)
end
@ -597,7 +606,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:list) { list_with_account(bob, alice) }
let!(:empty_list) { list_with_account(ohagi, bob) }
it 'is added to the list feed of list follower' do
it 'is added to the list feed of list follower', :sidekiq_inline do
expect(list_feed_of(list)).to include status.id
expect(list_feed_of(empty_list)).to_not include status.id
end
@ -607,7 +616,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_account(bob, alice) }
let!(:empty_antenna) { antenna_with_account(ohagi, alice) }
it 'is added to the list feed of list follower' do
it 'is added to the list feed of list follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -617,7 +626,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_options(bob, stl: true) }
let!(:empty_antenna) { antenna_with_options(ohagi, stl: true) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -625,7 +634,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when local timeline is disabled' do
let(:ltl_enabled) { false }
it 'is not added to the antenna feed of antenna follower' do
it 'is not added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -635,14 +644,14 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'with LTL antenna' do
let!(:empty_antenna) { antenna_with_options(bob, ltl: true) }
it 'is added to the antenna feed of antenna follower' do
it 'is added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
context 'when local timeline is disabled' do
let(:ltl_enabled) { false }
it 'is not added to the antenna feed of antenna follower' do
it 'is not added to the antenna feed of antenna follower', :sidekiq_inline do
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
end
@ -651,7 +660,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'with non-public searchability' do
let(:searchability) { 'direct' }
it 'hashtag-timeline is not detected' do
it 'hashtag-timeline is not detected', :sidekiq_inline do
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
end
@ -661,23 +670,23 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when status is direct' do
let(:visibility) { 'direct' }
it 'is added to the home feed of its author' do
it 'is added to the home feed of its author', :sidekiq_inline do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of the mentioned follower' do
it 'is added to the home feed of the mentioned follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
end
it 'is not added to the home feed of the other follower' do
it 'is not added to the home feed of the other follower', :sidekiq_inline do
expect(home_feed_of(tom)).to_not include status.id
end
it 'is not added to the tag follower' do
it 'is not added to the tag follower', :sidekiq_inline do
expect(home_feed_of(tagf)).to_not include status.id
end
it 'is not broadcast publicly' do
it 'is not broadcast publicly', :sidekiq_inline do
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
end
@ -686,7 +695,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:list) { list_with_account(bob, alice) }
let!(:empty_list) { list_with_account(ohagi, bob) }
it 'is added to the list feed of list follower' do
it 'is added to the list feed of list follower', :sidekiq_inline do
expect(list_feed_of(list)).to_not include status.id
expect(list_feed_of(empty_list)).to_not include status.id
end
@ -696,7 +705,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
let!(:antenna) { antenna_with_account(bob, alice) }
let!(:empty_antenna) { antenna_with_account(ohagi, alice) }
it 'is added to the list feed of list follower' do
it 'is added to the list feed of list follower', :sidekiq_inline do
expect(antenna_feed_of(antenna)).to_not include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
@ -724,28 +733,28 @@ RSpec.describe FanOutOnWriteService, type: :service do
end
context 'when public visibility' do
it 'does not create notification' do
it 'does not create notification', :sidekiq_inline do
notification = Notification.find_by(account: bob, type: 'mention')
expect(notification).to be_nil
end
it 'creates notification for active mention' do
it 'creates notification for active mention', :sidekiq_inline do
notification = Notification.find_by(account: tom, type: 'mention')
expect(notification).to_not be_nil
expect(notification.mention.status_id).to eq status.id
end
it 'inserts home feed for reply' do
it 'inserts home feed for reply', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
end
it 'inserts home feed for non-replied but mentioned and following replied account' do
it 'inserts home feed for non-replied but mentioned and following replied account', :sidekiq_inline do
expect(home_feed_of(zilu)).to include status.id
end
it 'does not insert home feed for non-replied, non-following replied account but mentioned' do
it 'does not insert home feed for non-replied, non-following replied account but mentioned', :sidekiq_inline do
expect(home_feed_of(tom)).to_not include status.id
end
end
@ -753,29 +762,29 @@ RSpec.describe FanOutOnWriteService, type: :service do
context 'when limited visibility' do
let(:visibility) { :limited }
it 'creates notification' do
it 'creates notification', :sidekiq_inline do
notification = Notification.find_by(account: bob, type: 'mention')
expect(notification).to_not be_nil
expect(notification.mention.status_id).to eq status.id
end
it 'creates notification for other conversation account' do
it 'creates notification for other conversation account', :sidekiq_inline do
notification = Notification.find_by(account: ohagi, type: 'mention')
expect(notification).to_not be_nil
expect(notification.mention.status_id).to eq status.id
end
it 'inserts home feed for reply' do
it 'inserts home feed for reply', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
end
it 'inserts home feed for non-replied but mentioned and following replied account' do
it 'inserts home feed for non-replied but mentioned and following replied account', :sidekiq_inline do
expect(home_feed_of(zilu)).to include status.id
end
it 'does not insert home feed for non-replied, non-following replied account but mentioned' do
it 'does not insert home feed for non-replied, non-following replied account but mentioned', :sidekiq_inline do
expect(home_feed_of(tom)).to_not include status.id
end
end
@ -791,21 +800,21 @@ RSpec.describe FanOutOnWriteService, type: :service do
subject.call(status, update: true)
end
it 'notified to boosted account' do
it 'notified to boosted account', :sidekiq_inline do
notification = Notification.find_by(account: bob, type: 'update')
expect(notification).to_not be_nil
expect(notification.activity_id).to eq status.id
end
it 'notified to quoted account' do
it 'notified to quoted account', :sidekiq_inline do
notification = Notification.find_by(account: tom, type: 'update')
expect(notification).to_not be_nil
expect(notification.activity_id).to eq status.id
end
it 'notified not to non-boosted account' do
it 'notified not to non-boosted account', :sidekiq_inline do
notification = Notification.find_by(account: ohagi, type: 'update')
expect(notification).to be_nil

View file

@ -33,7 +33,7 @@ RSpec.describe FavouriteService, type: :service do
expect(status.favourites.first).to_not be_nil
end
it 'sends a like activity' do
it 'sends a like activity', :sidekiq_inline do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
end

View file

@ -150,7 +150,7 @@ RSpec.describe FollowService, type: :service do
expect(FollowRequest.find_by(account: sender, target_account: bob)).to_not be_nil
end
it 'sends a follow activity to the inbox' do
it 'sends a follow activity to the inbox', :sidekiq_inline do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ImportService, type: :service do
RSpec.describe ImportService, :sidekiq_inline, type: :service do
include RoutingHelper
let!(:account) { Fabricate(:account, locked: false) }

View file

@ -17,7 +17,7 @@ RSpec.describe MuteService, type: :service do
redis.del(home_timeline_key)
end
it "clears account's statuses" do
it "clears account's statuses", :sidekiq_inline do
FeedManager.instance.push_to_home(account, status)
FeedManager.instance.push_to_home(account, other_account_status)

View file

@ -166,7 +166,7 @@ RSpec.describe NotifyService, type: :service do
context 'when email notification is enabled' do
let(:enabled) { true }
it 'sends email' do
it 'sends email', :sidekiq_inline do
expect { subject }.to change(ActionMailer::Base.deliveries, :count).by(1)
end
end

View file

@ -34,14 +34,14 @@ RSpec.describe ProcessReferencesService, type: :service do
context 'when a simple case' do
let(:text) { "Hello RT #{target_status_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'RT'
expect(notify?).to be true
end
it 'not quote' do
it 'not quote', :sidekiq_inline do
expect(status.quote).to be_nil
end
end
@ -51,7 +51,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:target_status2_uri) { ActivityPub::TagManager.instance.uri_for(target_status2) }
let(:text) { "Hello RT #{target_status_uri}\nBT #{target_status2_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 2
expect(subject).to include [target_status.id, 'RT']
expect(subject).to include [target_status2.id, 'BT']
@ -64,7 +64,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "Hello RT #{target_status_uri}" }
let(:visibility) { :private }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'RT'
@ -76,7 +76,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "Hello RT #{target_status_uri}" }
let(:target_status_visibility) { :private }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 0
expect(notify?).to be false
end
@ -85,7 +85,7 @@ RSpec.describe ProcessReferencesService, type: :service do
context 'with quote' do
let(:text) { "Hello QT #{target_status_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
@ -99,7 +99,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { 'Hello' }
let(:quote_urls) { [ActivityPub::TagManager.instance.uri_for(target_status)] }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
@ -113,7 +113,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "Hello QT #{target_status_uri}" }
let(:quote_urls) { [ActivityPub::TagManager.instance.uri_for(target_status)] }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
@ -127,7 +127,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "Hello RE #{target_status_uri}" }
let(:quote_urls) { [ActivityPub::TagManager.instance.uri_for(target_status)] }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
@ -141,7 +141,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "Hello QT #{target_status_uri}" }
let(:allow_quote) { false }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'BT'
@ -155,7 +155,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:target_status2_uri) { ActivityPub::TagManager.instance.uri_for(target_status2) }
let(:text) { "Hello QT #{target_status_uri}\nBT #{target_status2_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 2
expect(subject).to include [target_status.id, 'QT']
expect(subject).to include [target_status2.id, 'BT']
@ -169,7 +169,7 @@ RSpec.describe ProcessReferencesService, type: :service do
context 'when url only' do
let(:text) { "Hello #{target_status_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 0
expect(notify?).to be false
end
@ -197,7 +197,7 @@ RSpec.describe ProcessReferencesService, type: :service do
stub_request(:get, 'https://example.com/not_found').to_return(status: 404)
end
it 'reference it' do
it 'reference it', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject[0][1]).to eq 'BT'
@ -209,7 +209,7 @@ RSpec.describe ProcessReferencesService, type: :service do
context 'with fetch_remote later' do
let(:fetch_remote) { false }
it 'reference it' do
it 'reference it', :sidekiq_inline do
ids = subject.pluck(0)
expect(ids.size).to eq 1
@ -223,7 +223,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:fetch_remote) { false }
let(:text) { "RT #{ActivityPub::TagManager.instance.uri_for(target_status)} BT https://example.com/test_post" }
it 'reference it' do
it 'reference it', :sidekiq_inline do
expect(subject.size).to eq 2
expect(subject).to include [target_status.id, 'RT']
expect(subject.pluck(1)).to include 'BT'
@ -236,7 +236,7 @@ RSpec.describe ProcessReferencesService, type: :service do
context 'with not exists reference' do
let(:text) { 'BT https://example.com/not_found' }
it 'reference it' do
it 'reference it', :sidekiq_inline do
expect(subject.size).to eq 0
end
end
@ -259,7 +259,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { 'BT:https://example.com/test_post' }
shared_examples 'reference once' do |uri, url|
it 'reference it' do
it 'reference it', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject[0][1]).to eq 'BT'
@ -299,7 +299,7 @@ RSpec.describe ProcessReferencesService, type: :service do
it_behaves_like 'reference once', 'https://example.com/test_post', 'https://example.com/test_post_ohagi'
it 'do not request to uri' do
it 'do not request to uri', :sidekiq_inline do
subject
expect(a_request(:get, 'https://example.com/test_post_ohagi')).to_not have_been_made
end
@ -335,7 +335,7 @@ RSpec.describe ProcessReferencesService, type: :service do
context 'when add reference to empty' do
let(:new_text) { "BT #{target_status_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject).to include target_status.id
expect(notify?).to be true
@ -346,7 +346,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "BT #{target_status_uri}" }
let(:new_text) { "BT #{target_status_uri}\nBT #{target_status2_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 2
expect(subject).to include target_status.id
expect(subject).to include target_status2.id
@ -358,7 +358,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "BT #{target_status_uri}" }
let(:new_text) { "BT #{target_status_uri}\nBT #{target_status_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject).to include target_status.id
end
@ -368,7 +368,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "BT #{target_status_uri}" }
let(:new_text) { 'Hello' }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 0
expect(notify?).to be false
end
@ -378,7 +378,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "QT #{target_status_uri}" }
let(:new_text) { 'Hello' }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 0
expect(status.quote).to be_nil
expect(notify?).to be false
@ -389,7 +389,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "BT #{target_status_uri}" }
let(:new_text) { "BT #{target_status2_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject).to include target_status2.id
expect(notify?(target_status2.id)).to be true
@ -400,7 +400,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "QT #{target_status_uri}" }
let(:new_text) { "QT #{target_status2_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject).to include target_status2.id
expect(status.quote).to_not be_nil
@ -413,7 +413,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "QT #{target_status_uri}" }
let(:new_text) { "RT #{target_status_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject).to include target_status.id
expect(status.quote).to be_nil
@ -425,7 +425,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:text) { "RT #{target_status_uri}" }
let(:new_text) { "QT #{target_status_uri}" }
it 'post status' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject).to include target_status.id
expect(status.quote).to_not be_nil

View file

@ -87,7 +87,7 @@ RSpec.describe ReblogService, type: :service do
expect(ActivityPub::DistributionWorker).to have_received(:perform_async)
end
it 'sends an announce activity to the author' do
it 'sends an announce activity to the author', :sidekiq_inline do
expect(a_request(:post, bob.inbox_url)).to have_been_made.once
end
end

View file

@ -41,7 +41,7 @@ RSpec.describe RejectFollowService, type: :service do
expect(bob.following?(sender)).to be false
end
it 'sends a reject activity' do
it 'sends a reject activity', :sidekiq_inline do
expect(a_request(:post, bob.inbox_url)).to have_been_made.once
end
end

View file

@ -33,7 +33,7 @@ RSpec.describe RemoveFromFollowersService, type: :service do
expect(bob.followed_by?(sender)).to be false
end
it 'sends a reject activity' do
it 'sends a reject activity', :sidekiq_inline do
expect(a_request(:post, sender.inbox_url)).to have_been_made.once
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe RemoveStatusService, type: :service do
RSpec.describe RemoveStatusService, :sidekiq_inline, type: :service do
subject { described_class.new }
let!(:alice) { Fabricate(:account) }
@ -22,7 +22,8 @@ RSpec.describe RemoveStatusService, type: :service do
end
context 'when removed status is not a reblog' do
let!(:status) { PostStatusService.new.call(alice, text: "Hello @#{bob.pretty_acct} ThisIsASecret") }
let!(:media_attachment) { Fabricate(:media_attachment, account: alice) }
let!(:status) { PostStatusService.new.call(alice, text: "Hello @#{bob.pretty_acct} ThisIsASecret", media_ids: [media_attachment.id]) }
before do
FavouriteService.new.call(jeff, status)
@ -39,6 +40,14 @@ RSpec.describe RemoveStatusService, type: :service do
expect(HomeFeed.new(jeff).get(10).pluck(:id)).to_not include(status.id)
end
it 'publishes to public media timeline' do
allow(redis).to receive(:publish).with(any_args)
subject.call(status)
expect(redis).to have_received(:publish).with('timeline:public:media', Oj.dump(event: :delete, payload: status.id.to_s))
end
it 'sends Delete activity to followers' do
subject.call(status)
expect(a_request(:post, hank.shared_inbox_url).with(
@ -118,7 +127,7 @@ RSpec.describe RemoveStatusService, type: :service do
)).to have_been_made.once
end
it 'do not send Delete activity to followers' do
it 'do not send Delete activity to followers', :sidekiq_inline do
subject.call(status)
expect(a_request(:post, hank.inbox_url)).to_not have_been_made
expect(a_request(:post, hank.shared_inbox_url)).to_not have_been_made

View file

@ -23,7 +23,7 @@ RSpec.describe ReportService, type: :service do
stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
end
context 'when forward is true' do
context 'when forward is true', :sidekiq_inline do
let(:forward) { true }
it 'sends ActivityPub payload when forward is true' do
@ -53,7 +53,7 @@ RSpec.describe ReportService, type: :service do
end
context 'when forward_to_domains includes only the replied-to domain' do
it 'sends ActivityPub payload only to the author of the replied-to post' do
it 'sends ActivityPub payload only to the author of the replied-to post', :sidekiq_inline do
subject.call(source_account, remote_account, status_ids: [reported_status.id], forward: forward, forward_to_domains: [remote_thread_account.domain])
expect(a_request(:post, 'http://foo.com/inbox')).to have_been_made
expect(a_request(:post, 'http://example.com/inbox')).to_not have_been_made
@ -61,7 +61,7 @@ RSpec.describe ReportService, type: :service do
end
context 'when forward_to_domains does not include the replied-to domain' do
it 'does not send ActivityPub payload to the author of the replied-to post' do
it 'does not send ActivityPub payload to the author of the replied-to post', :sidekiq_inline do
subject.call(source_account, remote_account, status_ids: [reported_status.id], forward: forward)
expect(a_request(:post, 'http://foo.com/inbox')).to_not have_been_made
end
@ -89,7 +89,7 @@ RSpec.describe ReportService, type: :service do
end
context 'when forward is false' do
it 'does not send anything' do
it 'does not send anything', :sidekiq_inline do
subject.call(source_account, remote_account, forward: forward)
expect(a_request(:post, 'http://example.com/inbox')).to_not have_been_made
end

View file

@ -199,7 +199,7 @@ RSpec.describe ResolveAccountService, type: :service do
expect(account.uri).to eq 'https://ap.example.com/users/foo'
end
it 'merges accounts' do
it 'merges accounts', :sidekiq_inline do
account = subject.call('foo@ap.example.com')
expect(status.reload.account_id).to eq account.id

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe SuspendAccountService, type: :service do
RSpec.describe SuspendAccountService, :sidekiq_inline, type: :service do
shared_examples 'common behavior' do
subject { described_class.new.call(account) }
@ -16,17 +16,24 @@ RSpec.describe SuspendAccountService, type: :service do
list.accounts << account
account.suspend!
Fabricate(:media_attachment, file: attachment_fixture('boop.ogg'), account: account)
end
it 'unmerges from feeds of local followers and preserves suspended flag' do
it 'unmerges from feeds of local followers and changes file mode and preserves suspended flag' do
expect { subject }
.to_not change_suspended_flag
.to change_file_mode
.and not_change_suspended_flag
expect(FeedManager.instance).to have_received(:unmerge_from_home).with(account, local_follower)
expect(FeedManager.instance).to have_received(:unmerge_from_list).with(account, list)
end
def change_suspended_flag
change(account, :suspended?)
def change_file_mode
change { File.stat(account.media_attachments.first.file.path).mode }
end
def not_change_suspended_flag
not_change(account, :suspended?)
end
end

View file

@ -90,7 +90,7 @@ RSpec.describe UnEmojiReactService, type: :service do
stub_request(:post, 'https://author.foo.bar/inbox')
end
it 'react with emoji' do
it 'react with emoji', :sidekiq_inline do
expect(subject.count).to eq 0
expect(a_request(:post, 'https://author.foo.bar/inbox').with(body: hash_including({
type: 'Undo',
@ -107,7 +107,7 @@ RSpec.describe UnEmojiReactService, type: :service do
stub_request(:post, 'https://foo.bar/inbox')
end
it 'react with emoji' do
it 'react with emoji', :sidekiq_inline do
expect(subject.count).to eq 0
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
type: 'Undo',
@ -127,7 +127,7 @@ RSpec.describe UnEmojiReactService, type: :service do
stub_request(:post, 'https://foo.bar/inbox')
end
it 'react with emoji' do
it 'react with emoji', :sidekiq_inline do
expect(subject.count).to eq 0
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
type: 'Undo',
@ -145,7 +145,7 @@ RSpec.describe UnEmojiReactService, type: :service do
stub_request(:post, 'https://foo.bar/inbox')
end
it 'react with emoji' do
it 'react with emoji', :sidekiq_inline do
expect(subject.count).to eq 0
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
type: 'Undo',
@ -163,7 +163,7 @@ RSpec.describe UnEmojiReactService, type: :service do
stub_request(:post, 'https://foo.bar/inbox')
end
it 'react with emoji' do
it 'react with emoji', :sidekiq_inline do
expect(subject.count).to eq 0
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
type: 'Undo',

View file

@ -12,7 +12,7 @@ RSpec.describe UnallowDomainService, type: :service do
let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) }
let!(:domain_allow) { Fabricate(:domain_allow, domain: 'evil.org') }
context 'with limited federation mode' do
context 'with limited federation mode', :sidekiq_inline do
before do
allow(Rails.configuration.x).to receive(:limited_federation_mode).and_return(true)
end

View file

@ -33,7 +33,7 @@ RSpec.describe UnblockService, type: :service do
expect(sender.blocking?(bob)).to be false
end
it 'sends an unblock activity' do
it 'sends an unblock activity', :sidekiq_inline do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
end

View file

@ -20,7 +20,7 @@ RSpec.describe UnfollowService, type: :service do
end
end
describe 'remote ActivityPub' do
describe 'remote ActivityPub', :sidekiq_inline do
let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
before do
@ -38,7 +38,7 @@ RSpec.describe UnfollowService, type: :service do
end
end
describe 'remote ActivityPub (reverse)' do
describe 'remote ActivityPub (reverse)', :sidekiq_inline do
let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
before do

View file

@ -45,7 +45,7 @@ RSpec.describe UnsuspendAccountService, type: :service do
remote_follower.follow!(account)
end
it 'merges back into feeds of local followers and sends update' do
it 'merges back into feeds of local followers and sends update', :sidekiq_inline do
subject
expect_feeds_merged

View file

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe UpdateAccountService, type: :service do
subject { described_class.new }
describe 'switching form locked to unlocked accounts' do
describe 'switching form locked to unlocked accounts', :sidekiq_inline do
let(:account) { Fabricate(:account, locked: true) }
let(:alice) { Fabricate(:account) }
let(:bob) { Fabricate(:account) }

View file

@ -111,7 +111,7 @@ RSpec.describe UpdateStatusService, type: :service do
end
end
context 'when poll changes', :sidekiq_fake do
context 'when poll changes' do
let(:account) { Fabricate(:account) }
let!(:status) { Fabricate(:status, text: 'Foo', account: account, poll_attributes: { options: %w(Foo Bar), account: account, multiple: false, hide_totals: false, expires_at: 7.days.from_now }) }
let!(:poll) { status.poll }

31
spec/support/capybara.rb Normal file
View file

@ -0,0 +1,31 @@
# frozen_string_literal: true
Capybara.server_host = 'localhost'
Capybara.server_port = 3000
Capybara.app_host = "http://#{Capybara.server_host}:#{Capybara.server_port}"
require 'selenium/webdriver'
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.register_driver :headless_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument '--headless=new'
options.add_argument '--window-size=1680,1050'
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
options: options
)
end
Capybara.javascript_driver = :headless_chrome
RSpec.configure do |config|
config.before(:each, type: :system) do
driven_by Capybara.javascript_driver
end
end

View file

@ -95,6 +95,19 @@ RSpec.configure do |config|
end
end
config.around :each, type: :system do |example|
# Streaming server needs DB access but `use_transactional_tests` rolls back
# every transaction. Disable this feature for streaming tests, and use
# DatabaseCleaner to clean the database tables between each test.
self.use_transactional_tests = false
DatabaseCleaner.cleaning do
example.run
end
self.use_transactional_tests = true
end
private
def streaming_server_manager

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'NewStatuses' do
describe 'NewStatuses', :sidekiq_inline do
include ProfileStories
subject { page }

View file

@ -0,0 +1,33 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'ShareEntrypoint' do
include ProfileStories
subject { page }
let(:email) { 'test@example.com' }
let(:password) { 'password' }
let(:confirmed_at) { Time.zone.now }
let(:finished_onboarding) { true }
before do
as_a_logged_in_user
visit share_path
end
it 'can be used to post a new status' do
expect(subject).to have_css('div#mastodon-compose')
expect(subject).to have_css('.compose-form__publish-button-wrapper > button')
status_text = 'This is a new status!'
within('.compose-form') do
fill_in "What's on your mind?", with: status_text
click_on 'Publish!'
end
expect(subject).to have_css('.notification-bar-message', text: 'Post published.')
end
end

View file

@ -111,7 +111,7 @@ describe EmailMxValidator do
allow(resolver).to receive(:getresources).with('example.com', Resolv::DNS::Resource::IN::A).and_return([])
allow(resolver).to receive(:getresources).with('example.com', Resolv::DNS::Resource::IN::AAAA).and_return([])
allow(resolver).to receive(:getresources).with('mail.example.com', Resolv::DNS::Resource::IN::A).and_return([instance_double(Resolv::DNS::Resource::IN::A, address: '2.3.4.5')])
allow(resolver).to receive(:getresources).with('mail.example.com', Resolv::DNS::Resource::IN::AAAA).and_return([instance_double(Resolv::DNS::Resource::IN::A, address: 'fd00::2')])
allow(resolver).to receive(:getresources).with('mail.example.com', Resolv::DNS::Resource::IN::AAAA).and_return([instance_double(Resolv::DNS::Resource::IN::AAAA, address: 'fd00::2')])
allow(resolver).to receive(:timeouts=).and_return(nil)
allow(Resolv::DNS).to receive(:open).and_yield(resolver)

View file

@ -14,7 +14,7 @@ describe BackupWorker do
let(:backup) { Fabricate(:backup) }
let!(:other_backup) { Fabricate(:backup, user: backup.user) }
it 'sends the backup to the service and removes other backups' do
it 'sends the backup to the service and removes other backups', :sidekiq_inline do
expect do
worker.perform(backup.id)
end.to change(UserMailer.deliveries, :size).by(1)

View file

@ -73,19 +73,19 @@ describe FeedInsertWorker do
end
context 'with notification' do
it 'skips notification when unset' do
it 'skips notification when unset', :sidekiq_inline do
subject.perform(status.id, follower.id)
expect(notify?(follower, 'status', status.id)).to be false
end
it 'pushes notification when read status is set' do
it 'pushes notification when read status is set', :sidekiq_inline do
Fabricate(:follow, account: follower, target_account: status.account, notify: true)
subject.perform(status.id, follower.id)
expect(notify?(follower, 'status', status.id)).to be true
end
it 'skips notification when the account is registered list but not notify' do
it 'skips notification when the account is registered list but not notify', :sidekiq_inline do
follower.follow!(status.account)
list = Fabricate(:list, account: follower)
Fabricate(:list_account, list: list, account: status.account)
@ -97,7 +97,7 @@ describe FeedInsertWorker do
expect(list_status).to be_nil
end
it 'pushes notification when the account is registered list' do
it 'pushes notification when the account is registered list', :sidekiq_inline do
follower.follow!(status.account)
list = Fabricate(:list, account: follower, notify: true)
Fabricate(:list_account, list: list, account: status.account)

View file

@ -104,7 +104,7 @@ describe MoveWorker do
end
shared_examples 'lists handling' do
it 'puts the new account on the list and makes valid lists', sidekiq: :inline do
it 'puts the new account on the list and makes valid lists', :sidekiq_inline do
subject.perform(source_account.id, target_account.id)
expect(list.accounts.include?(target_account)).to be true
@ -159,7 +159,7 @@ describe MoveWorker do
describe '#perform' do
context 'when both accounts are distant' do
it 'calls UnfollowFollowWorker', :sidekiq_fake do
it 'calls UnfollowFollowWorker' do
subject.perform(source_account.id, target_account.id)
expect(UnfollowFollowWorker).to have_enqueued_sidekiq_job(local_follower.id, source_account.id, target_account.id, false)
end
@ -170,7 +170,7 @@ describe MoveWorker do
context 'when target account is local' do
let(:target_account) { Fabricate(:account) }
it 'calls UnfollowFollowWorker', :sidekiq_fake do
it 'calls UnfollowFollowWorker' do
subject.perform(source_account.id, target_account.id)
expect(UnfollowFollowWorker).to have_enqueued_sidekiq_job(local_follower.id, source_account.id, target_account.id, true)
end

View file

@ -10,7 +10,7 @@ describe PollExpirationNotifyWorker do
let(:remote?) { false }
let(:poll_vote) { Fabricate(:poll_vote, poll: poll) }
describe '#perform', :sidekiq_fake do
describe '#perform' do
it 'runs without error for missing record' do
expect { worker.perform(nil) }.to_not raise_error
end