mastodon/spec/helpers/accounts_helper_spec.rb
Matt Jankowski a1ac2a73ff
Some checks failed
Check i18n / check-i18n (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (ruby) (push) Has been cancelled
Check formatting / lint (push) Has been cancelled
Haml Linting / lint (push) Has been cancelled
Ruby Linting / lint (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
Ruby Testing / build (production) (push) Has been cancelled
Ruby Testing / build (test) (push) Has been cancelled
Ruby Testing / test (.ruby-version) (push) Has been cancelled
Ruby Testing / test (3.2) (push) Has been cancelled
Ruby Testing / Libvips tests (.ruby-version) (push) Has been cancelled
Ruby Testing / Libvips tests (3.2) (push) Has been cancelled
Ruby Testing / End to End testing (.ruby-version) (push) Has been cancelled
Ruby Testing / End to End testing (3.2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Bundler Audit / security (push) Has been cancelled
Remove remnants of embed views (#32419)
2024-11-16 20:48:10 +00:00

39 lines
1.0 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe AccountsHelper do
describe '#display_name' do
it 'uses the display name when it exists' do
account = Account.new(display_name: 'Display', username: 'Username')
expect(helper.display_name(account)).to eq 'Display'
end
it 'uses the username when display name is nil' do
account = Account.new(display_name: nil, username: 'Username')
expect(helper.display_name(account)).to eq 'Username'
end
end
describe '#acct' do
it 'is fully qualified for local accounts' do
allow(Rails.configuration.x).to receive(:local_domain).and_return('local_domain')
account = Account.new(domain: nil, username: 'user')
acct = helper.acct(account)
expect(acct).to eq '@user@local_domain'
end
it 'is fully qualified for remote accounts' do
account = Account.new(domain: 'foreign_server.com', username: 'user')
acct = helper.acct(account)
expect(acct).to eq '@user@foreign_server.com'
end
end
end