2023-02-22 00:55:31 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-10-24 20:50:09 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2023-05-04 03:49:53 +00:00
|
|
|
RSpec.describe AccountsHelper do
|
2019-10-24 20:50:09 +00:00
|
|
|
describe '#display_name' do
|
|
|
|
it 'uses the display name when it exists' do
|
2023-02-18 22:38:14 +00:00
|
|
|
account = Account.new(display_name: 'Display', username: 'Username')
|
2019-10-24 20:50:09 +00:00
|
|
|
|
2023-02-18 22:38:14 +00:00
|
|
|
expect(helper.display_name(account)).to eq 'Display'
|
2019-10-24 20:50:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'uses the username when display name is nil' do
|
2023-02-18 22:38:14 +00:00
|
|
|
account = Account.new(display_name: nil, username: 'Username')
|
2019-10-24 20:50:09 +00:00
|
|
|
|
2023-02-18 22:38:14 +00:00
|
|
|
expect(helper.display_name(account)).to eq 'Username'
|
2019-10-24 20:50:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#acct' do
|
2024-11-16 20:48:10 +00:00
|
|
|
it 'is fully qualified for local accounts' do
|
2019-10-24 20:50:09 +00:00
|
|
|
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
|
|
|
|
|
2024-11-16 20:48:10 +00:00
|
|
|
it 'is fully qualified for remote accounts' do
|
2019-10-24 20:50:09 +00:00
|
|
|
account = Account.new(domain: 'foreign_server.com', username: 'user')
|
|
|
|
|
|
|
|
acct = helper.acct(account)
|
|
|
|
|
|
|
|
expect(acct).to eq '@user@foreign_server.com'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|