|
|
|
@ -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|
|
|
|
|
|