diff --git a/app/models/tag.rb b/app/models/tag.rb index 3fdf4416ed3..9006e1f25d9 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -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 diff --git a/app/views/admin/tags/_tag.html.haml b/app/views/admin/tags/_tag.html.haml index 97b78238e8a..322eee0407f 100644 --- a/app/views/admin/tags/_tag.html.haml +++ b/app/views/admin/tags/_tag.html.haml @@ -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/ diff --git a/app/views/admin/trends/tags/_tag.html.haml b/app/views/admin/trends/tags/_tag.html.haml index 8cc0d713b9e..b1e714a9124 100644 --- a/app/views/admin/trends/tags/_tag.html.haml +++ b/app/views/admin/trends/tags/_tag.html.haml @@ -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/ diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index ae0c5591467..ff0a0551133 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -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) }