account_alias_spec.rb 855 B

123456789101112131415161718192021222324252627282930313233
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AccountAlias do
  4. describe 'Normalizations' do
  5. describe 'acct' do
  6. it { is_expected.to normalize(:acct).from(' @username@domain ').to('username@domain') }
  7. end
  8. end
  9. describe 'Validations' do
  10. subject { described_class.new(account:) }
  11. let(:account) { Fabricate :account }
  12. it { is_expected.to_not allow_values(nil, '').for(:uri).against(:acct).with_message(not_found_message) }
  13. it { is_expected.to_not allow_values(account_uri).for(:uri).against(:acct).with_message(self_move_message) }
  14. def account_uri
  15. ActivityPub::TagManager.instance.uri_for(subject.account)
  16. end
  17. def not_found_message
  18. I18n.t('migrations.errors.not_found')
  19. end
  20. def self_move_message
  21. I18n.t('migrations.errors.move_to_self')
  22. end
  23. end
  24. end