Merge branch 'main' into glitch-soc/merge-upstream

Conflicts:
- `app/validators/status_length_validator.rb`:
  Upstream changes too close to glitch-soc MAX_CHARS changes, but not a real
  conflict.
  Applied upstream changes.
- `package.json`:
  glitch-soc-only dependency textually too close to a dependency updated
  upstream, not a real conflict.
  Applied upstream changes.
This commit is contained in:
Claire
2021-03-02 12:06:58 +01:00
44 changed files with 915 additions and 741 deletions

View File

@@ -17,7 +17,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
let(:blocked_email) { true }
it 'calls errors.add' do
expect(errors).to have_received(:add).with(:email, I18n.t('users.blocked_email_provider'))
expect(errors).to have_received(:add).with(:email, :blocked)
end
end
@@ -25,7 +25,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
let(:blocked_email) { false }
it 'not calls errors.add' do
expect(errors).not_to have_received(:add).with(:email, I18n.t('users.blocked_email_provider'))
expect(errors).not_to have_received(:add).with(:email, :blocked)
end
end
end

View File

@@ -47,6 +47,14 @@ describe StatusLengthValidator do
expect(status.errors).to_not have_received(:add)
end
it 'does not count non-autolinkable URLs as 23 characters flat' do
text = ('a' * 476) + "http://#{'b' * 30}.com/example"
status = double(spoiler_text: '', text: text, errors: double(add: nil), local?: true, reblog?: false)
subject.validate(status)
expect(status.errors).to have_received(:add)
end
it 'counts only the front part of remote usernames' do
username = '@alice'
chars = StatusLengthValidator::MAX_CHARS - 1 - username.length

View File

@@ -13,7 +13,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do
let(:account) { double(username: username, errors: errors) }
let(:errors ) { double(add: nil) }
context '@username.nil?' do
context '@username.blank?' do
let(:username) { nil }
it 'not calls errors.add' do
@@ -21,14 +21,14 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do
end
end
context '!@username.nil?' do
let(:username) { '' }
context '!@username.blank?' do
let(:username) { 'f' }
context 'reserved_username?' do
let(:reserved_username) { true }
it 'calls erros.add' do
expect(errors).to have_received(:add).with(:username, I18n.t('accounts.reserved_username'))
expect(errors).to have_received(:add).with(:username, :reserved)
end
end