Merge upstream tag 'v3.5.2'
This commit is contained in:
commit
d161ca885c
2205 changed files with 91260 additions and 41616 deletions
|
|
@ -1,9 +1,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe NotifyService, type: :service do
|
||||
subject do
|
||||
-> { described_class.new.call(recipient, type, activity) }
|
||||
end
|
||||
subject { described_class.new.call(recipient, type, activity) }
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:recipient) { user.account }
|
||||
|
|
@ -11,42 +9,42 @@ RSpec.describe NotifyService, type: :service do
|
|||
let(:activity) { Fabricate(:follow, account: sender, target_account: recipient) }
|
||||
let(:type) { :follow }
|
||||
|
||||
it { is_expected.to change(Notification, :count).by(1) }
|
||||
it { expect { subject }.to change(Notification, :count).by(1) }
|
||||
|
||||
it 'does not notify when sender is blocked' do
|
||||
recipient.block!(sender)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'does not notify when sender is muted with hide_notifications' do
|
||||
recipient.mute!(sender, notifications: true)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'does notify when sender is muted without hide_notifications' do
|
||||
recipient.mute!(sender, notifications: false)
|
||||
is_expected.to change(Notification, :count)
|
||||
expect { subject }.to change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'does not notify when sender\'s domain is blocked' do
|
||||
recipient.block_domain!(sender.domain)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'does still notify when sender\'s domain is blocked but sender is followed' do
|
||||
recipient.block_domain!(sender.domain)
|
||||
recipient.follow!(sender)
|
||||
is_expected.to change(Notification, :count)
|
||||
expect { subject }.to change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'does not notify when sender is silenced and not followed' do
|
||||
sender.silence!
|
||||
is_expected.to_not change(Notification, :count)
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'does not notify when recipient is suspended' do
|
||||
recipient.suspend!
|
||||
is_expected.to_not change(Notification, :count)
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
context 'for direct messages' do
|
||||
|
|
@ -61,7 +59,7 @@ RSpec.describe NotifyService, type: :service do
|
|||
let(:enabled) { true }
|
||||
|
||||
it 'does not notify' do
|
||||
is_expected.to_not change(Notification, :count)
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
context 'if the message chain is initiated by recipient, but is not direct message' do
|
||||
|
|
@ -70,10 +68,22 @@ RSpec.describe NotifyService, type: :service do
|
|||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: reply_to)) }
|
||||
|
||||
it 'does not notify' do
|
||||
is_expected.to_not change(Notification, :count)
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
end
|
||||
|
||||
context 'if the message chain is initiated by recipient, but without a mention to the sender, even if the sender sends multiple messages in a row' do
|
||||
let(:reply_to) { Fabricate(:status, account: recipient) }
|
||||
let!(:mention) { Fabricate(:mention, account: sender, status: reply_to) }
|
||||
let(:dummy_reply) { Fabricate(:status, account: sender, visibility: :direct, thread: reply_to) }
|
||||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: dummy_reply)) }
|
||||
|
||||
it 'does not notify' do
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
end
|
||||
|
||||
<<<<<<< HEAD
|
||||
context 'if the message chain is initiated by recipient, but without a mention to the sender, even if the sender sends multiple messages in a row' do
|
||||
let(:reply_to) { Fabricate(:status, account: recipient) }
|
||||
let!(:mention) { Fabricate(:mention, account: sender, status: reply_to) }
|
||||
|
|
@ -85,13 +95,15 @@ RSpec.describe NotifyService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
=======
|
||||
>>>>>>> v3.5.2
|
||||
context 'if the message chain is initiated by the recipient with a mention to the sender' do
|
||||
let(:reply_to) { Fabricate(:status, account: recipient, visibility: :direct) }
|
||||
let!(:mention) { Fabricate(:mention, account: sender, status: reply_to) }
|
||||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: reply_to)) }
|
||||
|
||||
it 'does notify' do
|
||||
is_expected.to change(Notification, :count)
|
||||
expect { subject }.to change(Notification, :count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -100,7 +112,7 @@ RSpec.describe NotifyService, type: :service do
|
|||
let(:enabled) { false }
|
||||
|
||||
it 'does notify' do
|
||||
is_expected.to change(Notification, :count)
|
||||
expect { subject }.to change(Notification, :count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -112,17 +124,17 @@ RSpec.describe NotifyService, type: :service do
|
|||
|
||||
it 'shows reblogs by default' do
|
||||
recipient.follow!(sender)
|
||||
is_expected.to change(Notification, :count)
|
||||
expect { subject }.to change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'shows reblogs when explicitly enabled' do
|
||||
recipient.follow!(sender, reblogs: true)
|
||||
is_expected.to change(Notification, :count)
|
||||
expect { subject }.to change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'shows reblogs when disabled' do
|
||||
recipient.follow!(sender, reblogs: false)
|
||||
is_expected.to change(Notification, :count)
|
||||
expect { subject }.to change(Notification, :count)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -134,12 +146,12 @@ RSpec.describe NotifyService, type: :service do
|
|||
|
||||
it 'does not notify when conversation is muted' do
|
||||
recipient.mute_conversation!(activity.status.conversation)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'does not notify when it is a reply to a blocked user' do
|
||||
recipient.block!(asshole)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -147,7 +159,7 @@ RSpec.describe NotifyService, type: :service do
|
|||
let(:sender) { recipient }
|
||||
|
||||
it 'does not notify when recipient is the sender' do
|
||||
is_expected.to_not change(Notification, :count)
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -163,7 +175,7 @@ RSpec.describe NotifyService, type: :service do
|
|||
let(:enabled) { true }
|
||||
|
||||
it 'sends email' do
|
||||
is_expected.to change(ActionMailer::Base.deliveries, :count).by(1)
|
||||
expect { subject }.to change(ActionMailer::Base.deliveries, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -171,7 +183,7 @@ RSpec.describe NotifyService, type: :service do
|
|||
let(:enabled) { false }
|
||||
|
||||
it "doesn't send email" do
|
||||
is_expected.to_not change(ActionMailer::Base.deliveries, :count).from(0)
|
||||
expect { subject }.to_not change(ActionMailer::Base.deliveries, :count).from(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue