mirror of
https://github.com/mastodon/mastodon.git
synced 2024-10-20 16:46:08 +00:00
115dab78f1
Fix #271 Add back the `GET /api/v1/trends` API with the caveat that it does not return tags that have not been allowed to trend by the staff. When a hashtag begins to trend (internally) and that hashtag has not been previously reviewed by the staff, the staff is notified. The new admin UI for hashtags allows filtering hashtags by where they are used (e.g. in the profile directory), whether they have been reviewed or are pending reviewal, they show by how many people the hashtag is used in the directory, how many people used it today, how many statuses with it have been created today, and it allows fixing the name of the hashtag to make it more readable. The disallowed hashtags feature has been reworked. It is now controlled from the admin UI for hashtags instead of from the file `config/settings.yml`
49 lines
1.4 KiB
Ruby
49 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe DisallowedHashtagsValidator, type: :validator do
|
|
let(:disallowed_tags) { [] }
|
|
|
|
describe '#validate' do
|
|
before do
|
|
disallowed_tags.each { |name| Fabricate(:tag, name: name, usable: false) }
|
|
described_class.new.validate(status)
|
|
end
|
|
|
|
let(:status) { double(errors: errors, local?: local, reblog?: reblog, text: disallowed_tags.map { |x| '#' + x }.join(' ')) }
|
|
let(:errors) { double(add: nil) }
|
|
|
|
context 'for a remote reblog' do
|
|
let(:local) { false }
|
|
let(:reblog) { true }
|
|
|
|
it 'does not add errors' do
|
|
expect(errors).not_to have_received(:add).with(:text, any_args)
|
|
end
|
|
end
|
|
|
|
context 'for a local original status' do
|
|
let(:local) { true }
|
|
let(:reblog) { false }
|
|
|
|
context 'when does not contain any disallowed hashtags' do
|
|
let(:disallowed_tags) { [] }
|
|
|
|
it 'does not add errors' do
|
|
expect(errors).not_to have_received(:add).with(:text, any_args)
|
|
end
|
|
end
|
|
|
|
context 'when contains disallowed hashtags' do
|
|
let(:disallowed_tags) { %w(a b c) }
|
|
|
|
it 'adds an error' do
|
|
expect(errors).to have_received(:add)
|
|
.with(:text, I18n.t('statuses.disallowed_hashtags', tags: disallowed_tags.join(', '), count: disallowed_tags.size))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|