account_moderation_notes_helper_spec.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Admin::AccountModerationNotesHelper do
  4. include AccountsHelper
  5. describe '#admin_account_link_to' do
  6. context 'when Account is nil' do
  7. let(:account) { nil }
  8. it 'returns nil' do
  9. expect(helper.admin_account_link_to(account)).to be_nil
  10. end
  11. end
  12. context 'with account' do
  13. let(:account) { Fabricate(:account) }
  14. it 'calls #link_to' do
  15. allow(helper).to receive(:link_to)
  16. helper.admin_account_link_to(account)
  17. expect(helper).to have_received(:link_to).with(
  18. admin_account_path(account.id),
  19. class: name_tag_classes(account),
  20. title: account.acct
  21. )
  22. end
  23. end
  24. end
  25. describe '#admin_account_inline_link_to' do
  26. context 'when Account is nil' do
  27. let(:account) { nil }
  28. it 'returns nil' do
  29. expect(helper.admin_account_inline_link_to(account)).to be_nil
  30. end
  31. end
  32. context 'with account' do
  33. let(:account) { Fabricate(:account) }
  34. it 'calls #link_to' do
  35. result = helper.admin_account_inline_link_to(account)
  36. expect(result).to match(name_tag_classes(account, true))
  37. expect(result).to match(account.acct)
  38. expect(result).to match(admin_account_path(account.id))
  39. end
  40. end
  41. end
  42. end