Merge commit '77cd16f4ee7ab807df6fffb1538a6659a8182a9e' into glitch-soc/merge-upstream
Conflicts: - `app/javascript/styles/mastodon/components.scss`: Conflict caused by glitch-soc changing the path to images, and upstream removing styling using such an image. Removed the styling as upstream did. - `app/models/account.rb`: Conflict due to upstream changing lines adjacent to a change made in glitch-soc to have configurable limits. Ported upstream's changes. - `yarn.lock`: Dependencies adjacent to glitch-soc-only dependencies updated. Updated them as well.
This commit is contained in:
commit
8103e69b17
78 files changed
+2363
-2051
No files matched your search
@@ -8,4 +8,26 @@ RSpec.describe AccountAlias do
|
||||
it { is_expected.to normalize(:acct).from(' @username@domain ').to('username@domain') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Validations' do
|
||||
subject { described_class.new(account:) }
|
||||
|
||||
let(:account) { Fabricate :account }
|
||||
|
||||
it { is_expected.to_not allow_values(nil, '').for(:uri).against(:acct).with_message(not_found_message) }
|
||||
|
||||
it { is_expected.to_not allow_values(account_uri).for(:uri).against(:acct).with_message(self_move_message) }
|
||||
|
||||
def account_uri
|
||||
ActivityPub::TagManager.instance.uri_for(subject.account)
|
||||
end
|
||||
|
||||
def not_found_message
|
||||
I18n.t('migrations.errors.not_found')
|
||||
end
|
||||
|
||||
def self_move_message
|
||||
I18n.t('migrations.errors.move_to_self')
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -9,8 +9,8 @@ RSpec.describe AccountMigration do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
subject { described_class.new(account: source_account, acct: target_acct) }
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :account_migration, account: source_account }
|
||||
|
||||
let(:source_account) { Fabricate(:account) }
|
||||
let(:target_acct) { target_account.acct }
|
||||
@@ -26,9 +26,7 @@ RSpec.describe AccountMigration do
|
||||
allow(service_double).to receive(:call).with(target_acct, anything).and_return(target_account)
|
||||
end
|
||||
|
||||
it 'passes validations' do
|
||||
expect(subject).to be_valid
|
||||
end
|
||||
it { is_expected.to allow_value(target_account.acct).for(:acct) }
|
||||
end
|
||||
|
||||
context 'with unresolvable account' do
|
||||
@@ -40,17 +38,13 @@ RSpec.describe AccountMigration do
|
||||
allow(service_double).to receive(:call).with(target_acct, anything).and_return(nil)
|
||||
end
|
||||
|
||||
it 'has errors on acct field' do
|
||||
expect(subject).to model_have_error_on_field(:acct)
|
||||
end
|
||||
it { is_expected.to_not allow_value(target_acct).for(:acct) }
|
||||
end
|
||||
|
||||
context 'with a space in the domain part' do
|
||||
let(:target_acct) { 'target@remote. org' }
|
||||
|
||||
it 'has errors on acct field' do
|
||||
expect(subject).to model_have_error_on_field(:acct)
|
||||
end
|
||||
it { is_expected.to_not allow_value(target_acct).for(:acct) }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3,29 +3,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountModerationNote do
|
||||
describe 'chronological scope' do
|
||||
it 'returns account moderation notes oldest to newest' do
|
||||
account = Fabricate(:account)
|
||||
note1 = Fabricate(:account_moderation_note, target_account: account)
|
||||
note2 = Fabricate(:account_moderation_note, target_account: account)
|
||||
describe 'Scopes' do
|
||||
describe '.chronological' do
|
||||
it 'returns account moderation notes oldest to newest' do
|
||||
account = Fabricate(:account)
|
||||
note1 = Fabricate(:account_moderation_note, target_account: account)
|
||||
note2 = Fabricate(:account_moderation_note, target_account: account)
|
||||
|
||||
expect(account.targeted_moderation_notes.chronological).to eq [note1, note2]
|
||||
expect(account.targeted_moderation_notes.chronological).to eq [note1, note2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
it 'is invalid if the content is empty' do
|
||||
report = Fabricate.build(:account_moderation_note, content: '')
|
||||
expect(report.valid?).to be false
|
||||
end
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :account_moderation_note }
|
||||
|
||||
it 'is invalid if content is longer than character limit' do
|
||||
report = Fabricate.build(:account_moderation_note, content: comment_over_limit)
|
||||
expect(report.valid?).to be false
|
||||
end
|
||||
|
||||
def comment_over_limit
|
||||
Faker::Lorem.paragraph_by_chars(number: described_class::CONTENT_SIZE_LIMIT * 2)
|
||||
describe 'content' do
|
||||
it { is_expected.to_not allow_value('').for(:content) }
|
||||
it { is_expected.to validate_length_of(:content).is_at_most(described_class::CONTENT_SIZE_LIMIT) }
|
||||
end
|
||||
end
|
||||
end
|
||||
+66
-168
@@ -10,64 +10,6 @@ RSpec.describe Account do
|
||||
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
describe '#suspended_locally?' do
|
||||
context 'when the account is not suspended' do
|
||||
it 'returns false' do
|
||||
expect(subject.suspended_locally?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the account is suspended locally' do
|
||||
before do
|
||||
subject.update!(suspended_at: 1.day.ago, suspension_origin: :local)
|
||||
end
|
||||
|
||||
it 'returns true' do
|
||||
expect(subject.suspended_locally?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the account is suspended remotely' do
|
||||
before do
|
||||
subject.update!(suspended_at: 1.day.ago, suspension_origin: :remote)
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
expect(subject.suspended_locally?).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#suspend!' do
|
||||
it 'marks the account as suspended and creates a deletion request' do
|
||||
expect { subject.suspend! }
|
||||
.to change(subject, :suspended?).from(false).to(true)
|
||||
.and change(subject, :suspended_locally?).from(false).to(true)
|
||||
.and(change { AccountDeletionRequest.exists?(account: subject) }.from(false).to(true))
|
||||
end
|
||||
|
||||
context 'when the account is of a local user' do
|
||||
subject { local_user_account }
|
||||
|
||||
let!(:local_user_account) { Fabricate(:user, email: 'foo+bar@domain.org').account }
|
||||
|
||||
it 'creates a canonical domain block' do
|
||||
subject.suspend!
|
||||
expect(CanonicalEmailBlock.block?(subject.user_email)).to be true
|
||||
end
|
||||
|
||||
context 'when a canonical domain block already exists for that email' do
|
||||
before do
|
||||
Fabricate(:canonical_email_block, email: subject.user_email)
|
||||
end
|
||||
|
||||
it 'does not raise an error' do
|
||||
expect { subject.suspend! }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#follow!' do
|
||||
it 'creates a follow' do
|
||||
follow = subject.follow!(bob)
|
||||
@@ -208,16 +150,16 @@ RSpec.describe Account do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when last_webfingered_at is more than 24 hours before' do
|
||||
let(:last_webfingered_at) { 25.hours.ago }
|
||||
context 'when last_webfingered_at is before the threshold' do
|
||||
let(:last_webfingered_at) { (described_class::STALE_THRESHOLD + 1.hour).ago }
|
||||
|
||||
it 'returns true' do
|
||||
expect(account.possibly_stale?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when last_webfingered_at is less than 24 hours before' do
|
||||
let(:last_webfingered_at) { 23.hours.ago }
|
||||
context 'when last_webfingered_at is after the threshold' do
|
||||
let(:last_webfingered_at) { (described_class::STALE_THRESHOLD - 1.hour).ago }
|
||||
|
||||
it 'returns false' do
|
||||
expect(account.possibly_stale?).to be false
|
||||
@@ -752,26 +694,42 @@ RSpec.describe Account do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#prepare_contents' do
|
||||
subject { Fabricate.build :account, domain: domain, note: ' padded note ', display_name: ' padded name ' }
|
||||
describe 'Callbacks' do
|
||||
describe 'Stripping content when required' do
|
||||
context 'with a remote account' do
|
||||
subject { Fabricate.build :account, domain: 'host.example', note: ' note ', display_name: ' display name ' }
|
||||
|
||||
context 'with local account' do
|
||||
let(:domain) { nil }
|
||||
|
||||
it 'strips values' do
|
||||
expect { subject.valid? }
|
||||
.to change(subject, :note).to('padded note')
|
||||
.and(change(subject, :display_name).to('padded name'))
|
||||
it 'preserves content' do
|
||||
expect { subject.valid? }
|
||||
.to not_change(subject, :note)
|
||||
.and not_change(subject, :display_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with remote account' do
|
||||
let(:domain) { 'host.example' }
|
||||
context 'with a local account' do
|
||||
subject { Fabricate.build :account, domain: nil, note:, display_name: }
|
||||
|
||||
it 'preserves values' do
|
||||
expect { subject.valid? }
|
||||
.to not_change(subject, :note)
|
||||
.and(not_change(subject, :display_name))
|
||||
context 'with populated fields' do
|
||||
let(:note) { ' note ' }
|
||||
let(:display_name) { ' display name ' }
|
||||
|
||||
it 'strips content' do
|
||||
expect { subject.valid? }
|
||||
.to change(subject, :note).to('note')
|
||||
.and change(subject, :display_name).to('display name')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with empty fields' do
|
||||
let(:note) { nil }
|
||||
let(:display_name) { nil }
|
||||
|
||||
it 'preserves content' do
|
||||
expect { subject.valid? }
|
||||
.to not_change(subject, :note)
|
||||
.and not_change(subject, :display_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -826,22 +784,19 @@ RSpec.describe Account do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
describe 'Validations' do
|
||||
it { is_expected.to validate_presence_of(:username) }
|
||||
|
||||
context 'when is local' do
|
||||
it 'is invalid if the username is not unique in case-insensitive comparison among local accounts' do
|
||||
_account = Fabricate(:account, username: 'the_doctor')
|
||||
non_unique_account = Fabricate.build(:account, username: 'the_Doctor')
|
||||
non_unique_account.valid?
|
||||
expect(non_unique_account).to model_have_error_on_field(:username)
|
||||
context 'when account is local' do
|
||||
subject { Fabricate.build :account, domain: nil }
|
||||
|
||||
context 'with an existing differently-cased username account' do
|
||||
before { Fabricate :account, username: 'the_doctor' }
|
||||
|
||||
it { is_expected.to_not allow_value('the_Doctor').for(:username) }
|
||||
end
|
||||
|
||||
it 'is invalid if the username is reserved' do
|
||||
account = Fabricate.build(:account, username: 'support')
|
||||
account.valid?
|
||||
expect(account).to model_have_error_on_field(:username)
|
||||
end
|
||||
it { is_expected.to_not allow_value('support').for(:username) }
|
||||
|
||||
it 'is valid when username is reserved but record has already been created' do
|
||||
account = Fabricate.build(:account, username: 'support')
|
||||
@@ -849,9 +804,10 @@ RSpec.describe Account do
|
||||
expect(account.valid?).to be true
|
||||
end
|
||||
|
||||
it 'is valid if we are creating an instance actor account with a period' do
|
||||
account = Fabricate.build(:account, id: described_class::INSTANCE_ACTOR_ID, actor_type: 'Application', locked: true, username: 'example.com')
|
||||
expect(account.valid?).to be true
|
||||
context 'with the instance actor' do
|
||||
subject { Fabricate.build :account, id: described_class::INSTANCE_ACTOR_ID, actor_type: 'Application', locked: true }
|
||||
|
||||
it { is_expected.to allow_value('example.com').for(:username) }
|
||||
end
|
||||
|
||||
it 'is valid if we are creating a possibly-conflicting instance actor account' do
|
||||
@@ -860,81 +816,31 @@ RSpec.describe Account do
|
||||
expect(instance_account.valid?).to be true
|
||||
end
|
||||
|
||||
it 'is invalid if the username doesn\'t only contains letters, numbers and underscores' do
|
||||
account = Fabricate.build(:account, username: 'the-doctor')
|
||||
account.valid?
|
||||
expect(account).to model_have_error_on_field(:username)
|
||||
end
|
||||
it { is_expected.to_not allow_values('the-doctor', 'the.doctor').for(:username) }
|
||||
|
||||
it 'is invalid if the username contains a period' do
|
||||
account = Fabricate.build(:account, username: 'the.doctor')
|
||||
account.valid?
|
||||
expect(account).to model_have_error_on_field(:username)
|
||||
end
|
||||
it { is_expected.to validate_length_of(:username).is_at_most(described_class::USERNAME_LENGTH_LIMIT) }
|
||||
it { is_expected.to validate_length_of(:display_name).is_at_most(described_class::DISPLAY_NAME_LENGTH_LIMIT) }
|
||||
|
||||
it 'is invalid if the username is longer than the character limit' do
|
||||
account = Fabricate.build(:account, username: username_over_limit)
|
||||
account.valid?
|
||||
expect(account).to model_have_error_on_field(:username)
|
||||
end
|
||||
|
||||
it 'is invalid if the display name is longer than the character limit' do
|
||||
account = Fabricate.build(:account, display_name: display_name_over_limit)
|
||||
account.valid?
|
||||
expect(account).to model_have_error_on_field(:display_name)
|
||||
end
|
||||
|
||||
it 'is invalid if the note is longer than the character limit' do
|
||||
account = Fabricate.build(:account, note: account_note_over_limit)
|
||||
account.valid?
|
||||
expect(account).to model_have_error_on_field(:note)
|
||||
end
|
||||
it { is_expected.to_not allow_values(account_note_over_limit).for(:note) }
|
||||
end
|
||||
|
||||
context 'when is remote' do
|
||||
it 'is invalid if the username is same among accounts in the same normalized domain' do
|
||||
Fabricate(:account, domain: 'にゃん', username: 'username')
|
||||
account = Fabricate.build(:account, domain: 'xn--r9j5b5b', username: 'username')
|
||||
account.valid?
|
||||
expect(account).to model_have_error_on_field(:username)
|
||||
context 'when account is remote' do
|
||||
subject { Fabricate.build :account, domain: 'host.example' }
|
||||
|
||||
context 'when a normalized domain account exists' do
|
||||
subject { Fabricate.build :account, domain: 'xn--r9j5b5b' }
|
||||
|
||||
before { Fabricate(:account, domain: 'にゃん', username: 'username') }
|
||||
|
||||
it { is_expected.to_not allow_values('username', 'Username').for(:username) }
|
||||
end
|
||||
|
||||
it 'is invalid if the username is not unique in case-insensitive comparison among accounts in the same normalized domain' do
|
||||
Fabricate(:account, domain: 'にゃん', username: 'username')
|
||||
account = Fabricate.build(:account, domain: 'xn--r9j5b5b', username: 'Username')
|
||||
account.valid?
|
||||
expect(account).to model_have_error_on_field(:username)
|
||||
end
|
||||
it { is_expected.to allow_values('the-doctor', username_over_limit).for(:username) }
|
||||
it { is_expected.to_not allow_values('the doctor').for(:username) }
|
||||
|
||||
it 'is valid even if the username contains hyphens' do
|
||||
account = Fabricate.build(:account, domain: 'domain', username: 'the-doctor')
|
||||
account.valid?
|
||||
expect(account).to_not model_have_error_on_field(:username)
|
||||
end
|
||||
it { is_expected.to allow_values(display_name_over_limit).for(:display_name) }
|
||||
|
||||
it 'is invalid if the username doesn\'t only contains letters, numbers, underscores and hyphens' do
|
||||
account = Fabricate.build(:account, domain: 'domain', username: 'the doctor')
|
||||
account.valid?
|
||||
expect(account).to model_have_error_on_field(:username)
|
||||
end
|
||||
|
||||
it 'is valid even if the username is longer than the character limit' do
|
||||
account = Fabricate.build(:account, domain: 'domain', username: username_over_limit)
|
||||
account.valid?
|
||||
expect(account).to_not model_have_error_on_field(:username)
|
||||
end
|
||||
|
||||
it 'is valid even if the display name is longer than the character limit' do
|
||||
account = Fabricate.build(:account, domain: 'domain', display_name: display_name_over_limit)
|
||||
account.valid?
|
||||
expect(account).to_not model_have_error_on_field(:display_name)
|
||||
end
|
||||
|
||||
it 'is valid even if the note is longer than the character limit' do
|
||||
account = Fabricate.build(:account, domain: 'domain', note: account_note_over_limit)
|
||||
account.valid?
|
||||
expect(account).to_not model_have_error_on_field(:note)
|
||||
end
|
||||
it { is_expected.to allow_values(account_note_over_limit).for(:note) }
|
||||
end
|
||||
|
||||
def username_over_limit
|
||||
@@ -1085,14 +991,6 @@ RSpec.describe Account do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'suspended' do
|
||||
it 'returns an array of accounts who are suspended' do
|
||||
suspended_account = Fabricate(:account, suspended: true)
|
||||
_account = Fabricate(:account, suspended: false)
|
||||
expect(described_class.suspended).to contain_exactly(suspended_account)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'searchable' do
|
||||
let!(:suspended_local) { Fabricate(:account, suspended: true, username: 'suspended_local') }
|
||||
let!(:suspended_remote) { Fabricate(:account, suspended: true, domain: 'example.org', username: 'suspended_remote') }
|
||||
|
||||
@@ -5,13 +5,12 @@ require 'rails_helper'
|
||||
RSpec.describe AccountStatusesCleanupPolicy do
|
||||
let(:account) { Fabricate(:account, username: 'alice', domain: nil) }
|
||||
|
||||
describe 'validation' do
|
||||
it 'disallow remote accounts' do
|
||||
account.update(domain: 'example.com')
|
||||
account_statuses_cleanup_policy = Fabricate.build(:account_statuses_cleanup_policy, account: account)
|
||||
account_statuses_cleanup_policy.valid?
|
||||
expect(account_statuses_cleanup_policy).to model_have_error_on_field(:account)
|
||||
end
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :account_statuses_cleanup_policy }
|
||||
|
||||
let(:remote_account) { Fabricate(:account, domain: 'example.com') }
|
||||
|
||||
it { is_expected.to_not allow_value(remote_account).for(:account) }
|
||||
end
|
||||
|
||||
describe 'save hooks' do
|
||||
@@ -339,14 +338,7 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
||||
end
|
||||
|
||||
context 'when policy is set to keep DMs and reject everything else' do
|
||||
before do
|
||||
account_statuses_cleanup_policy.keep_direct = true
|
||||
account_statuses_cleanup_policy.keep_pinned = false
|
||||
account_statuses_cleanup_policy.keep_polls = false
|
||||
account_statuses_cleanup_policy.keep_media = false
|
||||
account_statuses_cleanup_policy.keep_self_fav = false
|
||||
account_statuses_cleanup_policy.keep_self_bookmark = false
|
||||
end
|
||||
before { establish_policy(keep_direct: true) }
|
||||
|
||||
it 'returns every old status except does not return the old direct message for deletion' do
|
||||
expect(subject.pluck(:id))
|
||||
@@ -356,14 +348,7 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
||||
end
|
||||
|
||||
context 'when policy is set to keep self-bookmarked toots and reject everything else' do
|
||||
before do
|
||||
account_statuses_cleanup_policy.keep_direct = false
|
||||
account_statuses_cleanup_policy.keep_pinned = false
|
||||
account_statuses_cleanup_policy.keep_polls = false
|
||||
account_statuses_cleanup_policy.keep_media = false
|
||||
account_statuses_cleanup_policy.keep_self_fav = false
|
||||
account_statuses_cleanup_policy.keep_self_bookmark = true
|
||||
end
|
||||
before { establish_policy(keep_self_bookmark: true) }
|
||||
|
||||
it 'returns every old status but does not return the old self-bookmarked message for deletion' do
|
||||
expect(subject.pluck(:id))
|
||||
@@ -373,14 +358,7 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
||||
end
|
||||
|
||||
context 'when policy is set to keep self-faved toots and reject everything else' do
|
||||
before do
|
||||
account_statuses_cleanup_policy.keep_direct = false
|
||||
account_statuses_cleanup_policy.keep_pinned = false
|
||||
account_statuses_cleanup_policy.keep_polls = false
|
||||
account_statuses_cleanup_policy.keep_media = false
|
||||
account_statuses_cleanup_policy.keep_self_fav = true
|
||||
account_statuses_cleanup_policy.keep_self_bookmark = false
|
||||
end
|
||||
before { establish_policy(keep_self_fav: true) }
|
||||
|
||||
it 'returns every old status but does not return the old self-faved message for deletion' do
|
||||
expect(subject.pluck(:id))
|
||||
@@ -390,14 +368,7 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
||||
end
|
||||
|
||||
context 'when policy is set to keep toots with media and reject everything else' do
|
||||
before do
|
||||
account_statuses_cleanup_policy.keep_direct = false
|
||||
account_statuses_cleanup_policy.keep_pinned = false
|
||||
account_statuses_cleanup_policy.keep_polls = false
|
||||
account_statuses_cleanup_policy.keep_media = true
|
||||
account_statuses_cleanup_policy.keep_self_fav = false
|
||||
account_statuses_cleanup_policy.keep_self_bookmark = false
|
||||
end
|
||||
before { establish_policy(keep_media: true) }
|
||||
|
||||
it 'returns every old status but does not return the old message with media for deletion' do
|
||||
expect(subject.pluck(:id))
|
||||
@@ -407,14 +378,7 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
||||
end
|
||||
|
||||
context 'when policy is set to keep toots with polls and reject everything else' do
|
||||
before do
|
||||
account_statuses_cleanup_policy.keep_direct = false
|
||||
account_statuses_cleanup_policy.keep_pinned = false
|
||||
account_statuses_cleanup_policy.keep_polls = true
|
||||
account_statuses_cleanup_policy.keep_media = false
|
||||
account_statuses_cleanup_policy.keep_self_fav = false
|
||||
account_statuses_cleanup_policy.keep_self_bookmark = false
|
||||
end
|
||||
before { establish_policy(keep_polls: true) }
|
||||
|
||||
it 'returns every old status but does not return the old poll message for deletion' do
|
||||
expect(subject.pluck(:id))
|
||||
@@ -424,14 +388,7 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
||||
end
|
||||
|
||||
context 'when policy is set to keep pinned toots and reject everything else' do
|
||||
before do
|
||||
account_statuses_cleanup_policy.keep_direct = false
|
||||
account_statuses_cleanup_policy.keep_pinned = true
|
||||
account_statuses_cleanup_policy.keep_polls = false
|
||||
account_statuses_cleanup_policy.keep_media = false
|
||||
account_statuses_cleanup_policy.keep_self_fav = false
|
||||
account_statuses_cleanup_policy.keep_self_bookmark = false
|
||||
end
|
||||
before { establish_policy(keep_pinned: true) }
|
||||
|
||||
it 'returns every old status but does not return the old pinned message for deletion' do
|
||||
expect(subject.pluck(:id))
|
||||
@@ -441,14 +398,7 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
||||
end
|
||||
|
||||
context 'when policy is to not keep any special messages' do
|
||||
before do
|
||||
account_statuses_cleanup_policy.keep_direct = false
|
||||
account_statuses_cleanup_policy.keep_pinned = false
|
||||
account_statuses_cleanup_policy.keep_polls = false
|
||||
account_statuses_cleanup_policy.keep_media = false
|
||||
account_statuses_cleanup_policy.keep_self_fav = false
|
||||
account_statuses_cleanup_policy.keep_self_bookmark = false
|
||||
end
|
||||
before { establish_policy }
|
||||
|
||||
it 'returns every old status but does not return the recent or unrelated statuses' do
|
||||
expect(subject.pluck(:id))
|
||||
@@ -459,14 +409,7 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
||||
end
|
||||
|
||||
context 'when policy is set to keep every category of toots' do
|
||||
before do
|
||||
account_statuses_cleanup_policy.keep_direct = true
|
||||
account_statuses_cleanup_policy.keep_pinned = true
|
||||
account_statuses_cleanup_policy.keep_polls = true
|
||||
account_statuses_cleanup_policy.keep_media = true
|
||||
account_statuses_cleanup_policy.keep_self_fav = true
|
||||
account_statuses_cleanup_policy.keep_self_bookmark = true
|
||||
end
|
||||
before { establish_policy(keep_direct: true, keep_pinned: true, keep_polls: true, keep_media: true, keep_self_fav: true, keep_self_bookmark: true) }
|
||||
|
||||
it 'returns normal statuses and does not return unrelated old status' do
|
||||
expect(subject.pluck(:id))
|
||||
@@ -502,5 +445,24 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
||||
.and include(very_old_status.id, faved_primary.id, reblogged_primary.id, reblogged_secondary.id)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def establish_policy(options = {})
|
||||
default_policy_options.merge(options).each do |attribute, value|
|
||||
account_statuses_cleanup_policy.send :"#{attribute}=", value
|
||||
end
|
||||
end
|
||||
|
||||
def default_policy_options
|
||||
{
|
||||
keep_direct: false,
|
||||
keep_media: false,
|
||||
keep_pinned: false,
|
||||
keep_polls: false,
|
||||
keep_self_bookmark: false,
|
||||
keep_self_fav: false,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,18 +67,30 @@ RSpec.describe Announcement do
|
||||
it { is_expected.to validate_presence_of(:text) }
|
||||
|
||||
describe 'ends_at' do
|
||||
it 'validates presence when starts_at is present' do
|
||||
record = Fabricate.build(:announcement, starts_at: 1.day.ago)
|
||||
context 'when starts_at is present' do
|
||||
subject { Fabricate.build :announcement, starts_at: 1.day.ago }
|
||||
|
||||
expect(record).to_not be_valid
|
||||
expect(record.errors[:ends_at]).to be_present
|
||||
it { is_expected.to validate_presence_of(:ends_at) }
|
||||
end
|
||||
|
||||
it 'does not validate presence when starts_at is missing' do
|
||||
record = Fabricate.build(:announcement, starts_at: nil)
|
||||
context 'when starts_at is missing' do
|
||||
subject { Fabricate.build :announcement, starts_at: nil }
|
||||
|
||||
expect(record).to be_valid
|
||||
expect(record.errors[:ends_at]).to_not be_present
|
||||
it { is_expected.to_not validate_presence_of(:ends_at) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'starts_at' do
|
||||
context 'when ends_at is present' do
|
||||
subject { Fabricate.build :announcement, ends_at: 1.day.ago }
|
||||
|
||||
it { is_expected.to validate_presence_of(:starts_at) }
|
||||
end
|
||||
|
||||
context 'when ends_at is missing' do
|
||||
subject { Fabricate.build :announcement, ends_at: nil }
|
||||
|
||||
it { is_expected.to_not validate_presence_of(:starts_at) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+77
-12
@@ -4,20 +4,85 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe Appeal do
|
||||
describe 'Validations' do
|
||||
it 'validates text length is under limit' do
|
||||
appeal = Fabricate.build(
|
||||
:appeal,
|
||||
strike: Fabricate(:account_warning),
|
||||
text: 'a' * described_class::TEXT_LENGTH_LIMIT * 2
|
||||
)
|
||||
subject { Fabricate.build :appeal, strike: Fabricate(:account_warning) }
|
||||
|
||||
expect(appeal).to_not be_valid
|
||||
expect(appeal).to model_have_error_on_field(:text)
|
||||
it { is_expected.to validate_length_of(:text).is_at_most(described_class::TEXT_LENGTH_LIMIT) }
|
||||
|
||||
context 'with a strike created too long ago' do
|
||||
let(:strike) { Fabricate.build :account_warning, created_at: 100.days.ago }
|
||||
|
||||
it { is_expected.to_not allow_values(strike).for(:strike).against(:base).on(:create) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'scopes' do
|
||||
describe 'approved' do
|
||||
describe 'Query methods' do
|
||||
describe '#pending?' do
|
||||
subject { Fabricate.build :appeal, approved_at:, rejected_at: }
|
||||
|
||||
context 'with not approved and not rejected' do
|
||||
let(:approved_at) { nil }
|
||||
let(:rejected_at) { nil }
|
||||
|
||||
it { expect(subject).to be_pending }
|
||||
end
|
||||
|
||||
context 'with approved and rejected' do
|
||||
let(:approved_at) { 1.day.ago }
|
||||
let(:rejected_at) { 1.day.ago }
|
||||
|
||||
it { expect(subject).to_not be_pending }
|
||||
end
|
||||
|
||||
context 'with approved and not rejected' do
|
||||
let(:approved_at) { 1.day.ago }
|
||||
let(:rejected_at) { nil }
|
||||
|
||||
it { expect(subject).to_not be_pending }
|
||||
end
|
||||
|
||||
context 'with not approved and rejected' do
|
||||
let(:approved_at) { nil }
|
||||
let(:rejected_at) { 1.day.ago }
|
||||
|
||||
it { expect(subject).to_not be_pending }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#approved?' do
|
||||
subject { Fabricate.build :appeal, approved_at: }
|
||||
|
||||
context 'with not approved' do
|
||||
let(:approved_at) { nil }
|
||||
|
||||
it { expect(subject).to_not be_approved }
|
||||
end
|
||||
|
||||
context 'with approved' do
|
||||
let(:approved_at) { 1.day.ago }
|
||||
|
||||
it { expect(subject).to be_approved }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#rejected?' do
|
||||
subject { Fabricate.build :appeal, rejected_at: }
|
||||
|
||||
context 'with not rejected' do
|
||||
let(:rejected_at) { nil }
|
||||
|
||||
it { expect(subject).to_not be_rejected }
|
||||
end
|
||||
|
||||
context 'with rejected' do
|
||||
let(:rejected_at) { 1.day.ago }
|
||||
|
||||
it { expect(subject).to be_rejected }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Scopes' do
|
||||
describe '.approved' do
|
||||
let(:approved_appeal) { Fabricate(:appeal, approved_at: 10.days.ago) }
|
||||
let(:not_approved_appeal) { Fabricate(:appeal, approved_at: nil) }
|
||||
|
||||
@@ -27,7 +92,7 @@ RSpec.describe Appeal do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'rejected' do
|
||||
describe '.rejected' do
|
||||
let(:rejected_appeal) { Fabricate(:appeal, rejected_at: 10.days.ago) }
|
||||
let(:not_rejected_appeal) { Fabricate(:appeal, rejected_at: nil) }
|
||||
|
||||
@@ -37,7 +102,7 @@ RSpec.describe Appeal do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'pending' do
|
||||
describe '.pending' do
|
||||
let(:approved_appeal) { Fabricate(:appeal, approved_at: 10.days.ago) }
|
||||
let(:rejected_appeal) { Fabricate(:appeal, rejected_at: 10.days.ago) }
|
||||
let(:pending_appeal) { Fabricate(:appeal, rejected_at: nil, approved_at: nil) }
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Account::Suspensions do
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
describe '.suspended' do
|
||||
let!(:suspended_account) { Fabricate :account, suspended: true }
|
||||
|
||||
before { Fabricate :account, suspended: false }
|
||||
|
||||
it 'returns accounts that are suspended' do
|
||||
expect(Account.suspended)
|
||||
.to contain_exactly(suspended_account)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#suspended_locally?' do
|
||||
context 'when the account is not suspended' do
|
||||
it { is_expected.to_not be_suspended_locally }
|
||||
end
|
||||
|
||||
context 'when the account is suspended locally' do
|
||||
before { subject.update!(suspended_at: 1.day.ago, suspension_origin: :local) }
|
||||
|
||||
it { is_expected.to be_suspended_locally }
|
||||
end
|
||||
|
||||
context 'when the account is suspended remotely' do
|
||||
before { subject.update!(suspended_at: 1.day.ago, suspension_origin: :remote) }
|
||||
|
||||
it { is_expected.to_not be_suspended_locally }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#suspend!' do
|
||||
it 'marks the account as suspended and creates a deletion request' do
|
||||
expect { subject.suspend! }
|
||||
.to change(subject, :suspended?).from(false).to(true)
|
||||
.and change(subject, :suspended_locally?).from(false).to(true)
|
||||
.and(change { AccountDeletionRequest.exists?(account: subject) }.from(false).to(true))
|
||||
end
|
||||
|
||||
context 'when the account is of a local user' do
|
||||
subject { local_user_account }
|
||||
|
||||
let!(:local_user_account) { Fabricate(:user, email: 'foo+bar@domain.org').account }
|
||||
|
||||
it 'creates a canonical domain block' do
|
||||
expect { subject.suspend! }
|
||||
.to change { CanonicalEmailBlock.block?(subject.user_email) }.from(false).to(true)
|
||||
end
|
||||
|
||||
context 'when a canonical domain block already exists for that email' do
|
||||
before { Fabricate(:canonical_email_block, email: subject.user_email) }
|
||||
|
||||
it 'does not raise an error' do
|
||||
expect { subject.suspend! }
|
||||
.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -6,11 +6,10 @@ RSpec.describe DomainAllow do
|
||||
describe 'Validations' do
|
||||
it { is_expected.to validate_presence_of(:domain) }
|
||||
|
||||
it 'is invalid if the same normalized domain already exists' do
|
||||
_domain_allow = Fabricate(:domain_allow, domain: 'にゃん')
|
||||
domain_allow_with_normalized_value = Fabricate.build(:domain_allow, domain: 'xn--r9j5b5b')
|
||||
domain_allow_with_normalized_value.valid?
|
||||
expect(domain_allow_with_normalized_value).to model_have_error_on_field(:domain)
|
||||
context 'when a normalized domain exists' do
|
||||
before { Fabricate(:domain_allow, domain: 'にゃん') }
|
||||
|
||||
it { is_expected.to_not allow_value('xn--r9j5b5b').for(:domain) }
|
||||
end
|
||||
end
|
||||
end
|
||||
+67
-14
@@ -3,27 +3,26 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Follow do
|
||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
describe 'validations' do
|
||||
subject { described_class.new(account: alice, target_account: bob, rate_limit: true) }
|
||||
|
||||
describe 'Associations' do
|
||||
it { is_expected.to belong_to(:account).required }
|
||||
it { is_expected.to belong_to(:target_account).required }
|
||||
end
|
||||
|
||||
it 'is invalid if account already follows too many people' do
|
||||
alice.update(following_count: FollowLimitValidator::LIMIT)
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :follow, rate_limit: true }
|
||||
|
||||
expect(subject).to_not be_valid
|
||||
expect(subject).to model_have_error_on_field(:base)
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
context 'when account follows too many people' do
|
||||
before { account.update(following_count: FollowLimitValidator::LIMIT) }
|
||||
|
||||
it { is_expected.to_not allow_value(account).for(:account).against(:base) }
|
||||
end
|
||||
|
||||
it 'is valid if account is only on the brink of following too many people' do
|
||||
alice.update(following_count: FollowLimitValidator::LIMIT - 1)
|
||||
context 'when account is on brink of following too many people' do
|
||||
before { account.update(following_count: FollowLimitValidator::LIMIT - 1) }
|
||||
|
||||
expect(subject).to be_valid
|
||||
expect(subject).to_not model_have_error_on_field(:base)
|
||||
it { is_expected.to allow_value(account).for(:account).against(:base) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -54,4 +53,58 @@ RSpec.describe Follow do
|
||||
expect(account.requested?(target_account)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe '#local?' do
|
||||
it { is_expected.to_not be_local }
|
||||
end
|
||||
|
||||
describe 'Callbacks' do
|
||||
describe 'Setting a URI' do
|
||||
context 'when URI exists' do
|
||||
subject { Fabricate.build :follow, uri: 'https://uri/value' }
|
||||
|
||||
it 'does not change' do
|
||||
expect { subject.save }
|
||||
.to not_change(subject, :uri)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when URI is blank' do
|
||||
subject { Fabricate.build :follow, uri: nil }
|
||||
|
||||
it 'populates the value' do
|
||||
expect { subject.save }
|
||||
.to change(subject, :uri).to(be_present)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Maintaining counters' do
|
||||
subject { Fabricate.build :follow, account:, target_account: }
|
||||
|
||||
let(:account) { Fabricate :account }
|
||||
let(:target_account) { Fabricate :account }
|
||||
|
||||
before do
|
||||
account.account_stat.update following_count: 123
|
||||
target_account.account_stat.update followers_count: 123
|
||||
end
|
||||
|
||||
describe 'saving the follow' do
|
||||
it 'increments counters' do
|
||||
expect { subject.save }
|
||||
.to change(account, :following_count).by(1)
|
||||
.and(change(target_account, :followers_count).by(1))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroying the follow' do
|
||||
it 'decrements counters' do
|
||||
expect { subject.destroy }
|
||||
.to change(account, :following_count).by(-1)
|
||||
.and(change(target_account, :followers_count).by(-1))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3,33 +3,17 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Form::AdminSettings do
|
||||
describe 'validations' do
|
||||
describe 'Validations' do
|
||||
describe 'site_contact_username' do
|
||||
context 'with no accounts' do
|
||||
it 'is not valid' do
|
||||
setting = described_class.new(site_contact_username: 'Test')
|
||||
setting.valid?
|
||||
|
||||
expect(setting).to model_have_error_on_field(:site_contact_username)
|
||||
end
|
||||
it { is_expected.to_not allow_value('Test').for(:site_contact_username) }
|
||||
end
|
||||
|
||||
context 'with an account' do
|
||||
before { Fabricate(:account, username: 'Glorp') }
|
||||
|
||||
it 'is not valid when account doesnt match' do
|
||||
setting = described_class.new(site_contact_username: 'Test')
|
||||
setting.valid?
|
||||
|
||||
expect(setting).to model_have_error_on_field(:site_contact_username)
|
||||
end
|
||||
|
||||
it 'is valid when account matches' do
|
||||
setting = described_class.new(site_contact_username: 'Glorp')
|
||||
setting.valid?
|
||||
|
||||
expect(setting).to_not model_have_error_on_field(:site_contact_username)
|
||||
end
|
||||
it { is_expected.to_not allow_value('Test').for(:site_contact_username) }
|
||||
it { is_expected.to allow_value('Glorp').for(:site_contact_username) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,18 +3,13 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe IpBlock do
|
||||
describe 'validations' do
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :ip_block }
|
||||
|
||||
it { is_expected.to validate_presence_of(:ip) }
|
||||
it { is_expected.to validate_presence_of(:severity) }
|
||||
|
||||
it 'validates ip uniqueness', :aggregate_failures do
|
||||
described_class.create!(ip: '127.0.0.1', severity: :no_access)
|
||||
|
||||
ip_block = described_class.new(ip: '127.0.0.1', severity: :no_access)
|
||||
|
||||
expect(ip_block).to_not be_valid
|
||||
expect(ip_block).to model_have_error_on_field(:ip)
|
||||
end
|
||||
it { is_expected.to validate_uniqueness_of(:ip) }
|
||||
end
|
||||
|
||||
describe '#to_log_human_identifier' do
|
||||
|
||||
@@ -9,26 +9,10 @@ RSpec.describe PreviewCard do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
describe 'urls' do
|
||||
it 'allows http schemes' do
|
||||
record = described_class.new(url: 'http://example.host/path')
|
||||
|
||||
expect(record).to be_valid
|
||||
end
|
||||
|
||||
it 'allows https schemes' do
|
||||
record = described_class.new(url: 'https://example.host/path')
|
||||
|
||||
expect(record).to be_valid
|
||||
end
|
||||
|
||||
it 'does not allow javascript: schemes' do
|
||||
record = described_class.new(url: 'javascript:alert()')
|
||||
|
||||
expect(record).to_not be_valid
|
||||
expect(record).to model_have_error_on_field(:url)
|
||||
end
|
||||
describe 'Validations' do
|
||||
describe 'url' do
|
||||
it { is_expected.to allow_values('http://example.host/path', 'https://example.host/path').for(:url) }
|
||||
it { is_expected.to_not allow_value('javascript:alert()').for(:url) }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3,29 +3,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ReportNote do
|
||||
describe 'chronological scope' do
|
||||
it 'returns report notes oldest to newest' do
|
||||
report = Fabricate(:report)
|
||||
note1 = Fabricate(:report_note, report: report)
|
||||
note2 = Fabricate(:report_note, report: report)
|
||||
describe 'Scopes' do
|
||||
describe '.chronological' do
|
||||
it 'returns report notes oldest to newest' do
|
||||
report = Fabricate(:report)
|
||||
note1 = Fabricate(:report_note, report: report)
|
||||
note2 = Fabricate(:report_note, report: report)
|
||||
|
||||
expect(report.notes.chronological).to eq [note1, note2]
|
||||
expect(report.notes.chronological).to eq [note1, note2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
it 'is invalid if the content is empty' do
|
||||
report = Fabricate.build(:report_note, content: '')
|
||||
expect(report.valid?).to be false
|
||||
end
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :report_note }
|
||||
|
||||
it 'is invalid if content is longer than character limit' do
|
||||
report = Fabricate.build(:report_note, content: comment_over_limit)
|
||||
expect(report.valid?).to be false
|
||||
end
|
||||
|
||||
def comment_over_limit
|
||||
Faker::Lorem.paragraph_by_chars(number: described_class::CONTENT_SIZE_LIMIT * 2)
|
||||
describe 'content' do
|
||||
it { is_expected.to_not allow_value('').for(:content) }
|
||||
it { is_expected.to validate_length_of(:content).is_at_most(described_class::CONTENT_SIZE_LIMIT) }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3,53 +3,17 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe WebauthnCredential do
|
||||
describe 'validations' do
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :webauthn_credential }
|
||||
|
||||
it { is_expected.to validate_presence_of(:external_id) }
|
||||
it { is_expected.to validate_presence_of(:public_key) }
|
||||
it { is_expected.to validate_presence_of(:nickname) }
|
||||
it { is_expected.to validate_presence_of(:sign_count) }
|
||||
|
||||
it 'is invalid if already exist a webauthn credential with the same external id' do
|
||||
Fabricate(:webauthn_credential, external_id: '_Typ0ygudDnk9YUVWLQayw')
|
||||
new_webauthn_credential = Fabricate.build(:webauthn_credential, external_id: '_Typ0ygudDnk9YUVWLQayw')
|
||||
it { is_expected.to validate_uniqueness_of(:external_id) }
|
||||
it { is_expected.to validate_uniqueness_of(:nickname).scoped_to(:user_id) }
|
||||
|
||||
new_webauthn_credential.valid?
|
||||
|
||||
expect(new_webauthn_credential).to model_have_error_on_field(:external_id)
|
||||
end
|
||||
|
||||
it 'is invalid if user already registered a webauthn credential with the same nickname' do
|
||||
user = Fabricate(:user)
|
||||
Fabricate(:webauthn_credential, user_id: user.id, nickname: 'USB Key')
|
||||
new_webauthn_credential = Fabricate.build(:webauthn_credential, user_id: user.id, nickname: 'USB Key')
|
||||
|
||||
new_webauthn_credential.valid?
|
||||
|
||||
expect(new_webauthn_credential).to model_have_error_on_field(:nickname)
|
||||
end
|
||||
|
||||
it 'is invalid if sign_count is not a number' do
|
||||
webauthn_credential = Fabricate.build(:webauthn_credential, sign_count: 'invalid sign_count')
|
||||
|
||||
webauthn_credential.valid?
|
||||
|
||||
expect(webauthn_credential).to model_have_error_on_field(:sign_count)
|
||||
end
|
||||
|
||||
it 'is invalid if sign_count is negative number' do
|
||||
webauthn_credential = Fabricate.build(:webauthn_credential, sign_count: -1)
|
||||
|
||||
webauthn_credential.valid?
|
||||
|
||||
expect(webauthn_credential).to model_have_error_on_field(:sign_count)
|
||||
end
|
||||
|
||||
it 'is invalid if sign_count is greater than the limit' do
|
||||
webauthn_credential = Fabricate.build(:webauthn_credential, sign_count: (described_class::SIGN_COUNT_LIMIT * 2))
|
||||
|
||||
webauthn_credential.valid?
|
||||
|
||||
expect(webauthn_credential).to model_have_error_on_field(:sign_count)
|
||||
end
|
||||
it { is_expected.to validate_numericality_of(:sign_count).only_integer.is_greater_than_or_equal_to(0).is_less_than_or_equal_to(described_class::SIGN_COUNT_LIMIT - 1) }
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user