2018-12-07 16:39:20 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-07 20:26:43 +02:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2023-05-04 05:49:53 +02:00
|
|
|
RSpec.describe Admin::AccountModerationNotesHelper do
|
2019-10-24 22:50:09 +02:00
|
|
|
include AccountsHelper
|
2018-12-07 16:39:20 +01:00
|
|
|
|
|
|
|
describe '#admin_account_link_to' do
|
2024-06-17 14:20:57 +02:00
|
|
|
subject { helper.admin_account_link_to(account) }
|
|
|
|
|
2023-05-04 05:49:08 +02:00
|
|
|
context 'when Account is nil' do
|
2018-12-07 16:39:20 +01:00
|
|
|
let(:account) { nil }
|
|
|
|
|
|
|
|
it 'returns nil' do
|
2024-06-17 14:20:57 +02:00
|
|
|
expect(subject).to be_nil
|
2018-12-07 16:39:20 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with account' do
|
|
|
|
let(:account) { Fabricate(:account) }
|
|
|
|
|
2024-06-17 14:20:57 +02:00
|
|
|
it 'returns a labeled avatar link to the account' do
|
|
|
|
expect(parsed_html.a[:href]).to eq admin_account_path(account.id)
|
|
|
|
expect(parsed_html.a[:class]).to eq 'name-tag'
|
|
|
|
expect(parsed_html.a.span.text).to eq account.acct
|
2018-12-07 16:39:20 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#admin_account_inline_link_to' do
|
2024-06-17 14:20:57 +02:00
|
|
|
subject { helper.admin_account_inline_link_to(account) }
|
|
|
|
|
2023-05-04 05:49:08 +02:00
|
|
|
context 'when Account is nil' do
|
2018-12-07 16:39:20 +01:00
|
|
|
let(:account) { nil }
|
|
|
|
|
|
|
|
it 'returns nil' do
|
2024-06-17 14:20:57 +02:00
|
|
|
expect(subject).to be_nil
|
2018-12-07 16:39:20 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with account' do
|
|
|
|
let(:account) { Fabricate(:account) }
|
|
|
|
|
2024-06-17 14:20:57 +02:00
|
|
|
it 'returns an inline link to the account' do
|
|
|
|
expect(parsed_html.a[:href]).to eq admin_account_path(account.id)
|
|
|
|
expect(parsed_html.a[:class]).to eq 'inline-name-tag'
|
|
|
|
expect(parsed_html.a.span.text).to eq account.acct
|
2018-12-07 16:39:20 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2024-06-17 14:20:57 +02:00
|
|
|
|
|
|
|
def parsed_html
|
|
|
|
Nokogiri::Slop(subject)
|
|
|
|
end
|
2017-10-07 20:26:43 +02:00
|
|
|
end
|