1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Add Tag#formatted_name for admin views

This commit is contained in:
Emelia Smith 2024-07-27 17:09:41 +02:00
parent 7fe71e3fde
commit a6385b7da8
No known key found for this signature in database
4 changed files with 18 additions and 5 deletions

View file

@ -75,6 +75,10 @@ class Tag < ApplicationRecord
attributes['display_name'] || name
end
def formatted_name
"##{display_name}"
end
def usable
boolean_with_default('usable', true)
end

View file

@ -2,8 +2,7 @@
.batch-table__row__content.batch-table__row__content--padded.pending-account
.pending-account__header
%strong
= link_to admin_tag_path(tag.id) do
= t('admin.tags.tag_name', name: tag.display_name)
= link_to tag.formatted_name, admin_tag_path(tag.id)
%br/

View file

@ -4,9 +4,7 @@
.batch-table__row__content.pending-account
.pending-account__header
= link_to admin_tag_path(tag.id) do
= material_symbol 'tag'
= tag.display_name
= link_to tag.formatted_name, admin_tag_path(tag.id)
%br/

View file

@ -112,6 +112,18 @@ RSpec.describe Tag do
end
end
describe '#formatted_name' do
it 'returns name with a proceeding hash symbol' do
tag = Fabricate(:tag, name: 'foo')
expect(tag.formatted_name).to eq '#foo'
end
it 'returns display_name with a proceeding hash symbol, if display name present' do
tag = Fabricate(:tag, name: 'foobar', display_name: 'FooBar')
expect(tag.formatted_name).to eq '#FooBar'
end
end
describe '.recently_used' do
let(:account) { Fabricate(:account) }
let(:other_person_status) { Fabricate(:status) }