mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 16:59:41 +00:00
Merge commit '5dc634796aba951f6a085e1ed0e1b807e25d7d41' into glitch-soc/merge-upstream
This commit is contained in:
@@ -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) }
|
||||
|
||||
@@ -78,12 +78,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
|
||||
|
||||
@@ -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|
|
||||
|
||||
Reference in New Issue
Block a user