1
0

accounts_helper_spec.rb 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AccountsHelper do
  4. describe '#display_name' do
  5. it 'uses the display name when it exists' do
  6. account = Account.new(display_name: 'Display', username: 'Username')
  7. expect(helper.display_name(account)).to eq 'Display'
  8. end
  9. it 'uses the username when display name is nil' do
  10. account = Account.new(display_name: nil, username: 'Username')
  11. expect(helper.display_name(account)).to eq 'Username'
  12. end
  13. end
  14. describe '#acct' do
  15. it 'is fully qualified for local accounts' do
  16. allow(Rails.configuration.x).to receive(:local_domain).and_return('local_domain')
  17. account = Account.new(domain: nil, username: 'user')
  18. acct = helper.acct(account)
  19. expect(acct).to eq '@user@local_domain'
  20. end
  21. it 'is fully qualified for remote accounts' do
  22. account = Account.new(domain: 'foreign_server.com', username: 'user')
  23. acct = helper.acct(account)
  24. expect(acct).to eq '@user@foreign_server.com'
  25. end
  26. end
  27. end