2023-02-21 19:55:31 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-05 20:51:56 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-03-13 04:39:26 -04:00
|
|
|
RSpec.describe MuteService do
|
2022-03-28 06:43:58 -04:00
|
|
|
subject { described_class.new.call(account, target_account) }
|
2017-05-06 10:31:07 -04:00
|
|
|
|
|
|
|
let(:account) { Fabricate(:account) }
|
|
|
|
let(:target_account) { Fabricate(:account) }
|
|
|
|
|
|
|
|
describe 'home timeline' do
|
|
|
|
let(:status) { Fabricate(:status, account: target_account) }
|
|
|
|
let(:other_account_status) { Fabricate(:status) }
|
|
|
|
let(:home_timeline_key) { FeedManager.instance.key(:home, account.id) }
|
|
|
|
|
|
|
|
before do
|
2022-04-28 11:47:34 -04:00
|
|
|
redis.del(home_timeline_key)
|
2017-05-06 10:31:07 -04:00
|
|
|
end
|
|
|
|
|
2024-07-08 12:01:08 -04:00
|
|
|
it "clears account's statuses", :inline_jobs do
|
2017-11-17 18:16:48 -05:00
|
|
|
FeedManager.instance.push_to_home(account, status)
|
|
|
|
FeedManager.instance.push_to_home(account, other_account_status)
|
2017-05-06 10:31:07 -04:00
|
|
|
|
2022-03-28 06:43:58 -04:00
|
|
|
expect { subject }.to change {
|
2022-04-28 11:47:34 -04:00
|
|
|
redis.zrange(home_timeline_key, 0, -1)
|
2017-05-06 10:31:07 -04:00
|
|
|
}.from([status.id.to_s, other_account_status.id.to_s]).to([other_account_status.id.to_s])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'mutes account' do
|
2022-03-28 06:43:58 -04:00
|
|
|
expect { subject }.to change {
|
2017-05-06 10:31:07 -04:00
|
|
|
account.muting?(target_account)
|
|
|
|
}.from(false).to(true)
|
|
|
|
end
|
2017-11-14 21:56:41 -05:00
|
|
|
|
|
|
|
context 'without specifying a notifications parameter' do
|
|
|
|
it 'mutes notifications from the account' do
|
2022-03-28 06:43:58 -04:00
|
|
|
expect { subject }.to change {
|
2017-11-14 21:56:41 -05:00
|
|
|
account.muting_notifications?(target_account)
|
|
|
|
}.from(false).to(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a true notifications parameter' do
|
2022-03-28 06:43:58 -04:00
|
|
|
subject { described_class.new.call(account, target_account, notifications: true) }
|
2017-11-14 21:56:41 -05:00
|
|
|
|
|
|
|
it 'mutes notifications from the account' do
|
2022-03-28 06:43:58 -04:00
|
|
|
expect { subject }.to change {
|
2017-11-14 21:56:41 -05:00
|
|
|
account.muting_notifications?(target_account)
|
|
|
|
}.from(false).to(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a false notifications parameter' do
|
2022-03-28 06:43:58 -04:00
|
|
|
subject { described_class.new.call(account, target_account, notifications: false) }
|
2017-11-14 21:56:41 -05:00
|
|
|
|
|
|
|
it 'does not mute notifications from the account' do
|
2022-03-28 06:43:58 -04:00
|
|
|
expect { subject }.to_not change {
|
2017-11-14 21:56:41 -05:00
|
|
|
account.muting_notifications?(target_account)
|
|
|
|
}.from(false)
|
|
|
|
end
|
|
|
|
end
|
2017-02-05 20:51:56 -05:00
|
|
|
end
|