From 8b1d3b91b77535a761d41aaf8638fdb668ffadde Mon Sep 17 00:00:00 2001 From: Pia B Date: Tue, 9 Jun 2026 15:57:01 +0200 Subject: [PATCH] add request spec and change selection --- app/controllers/admin/tags_controller.rb | 2 +- app/models/admin/action_log_filter.rb | 2 ++ app/models/tag.rb | 2 +- app/views/admin/tags/show.html.haml | 2 +- spec/requests/admin/tags_spec.rb | 13 +++++++++++++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index e64a5952152..449422c202f 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -17,7 +17,7 @@ module Admin authorize @tag, :show? @time_period = report_range - @action_logs = Admin::ActionLogFilter.new(action_type: :update_tag).results.limit(5) + @action_logs = Admin::ActionLogFilter.new(target_tag: @tag.formatted_name).results.limit(5) end def update diff --git a/app/models/admin/action_log_filter.rb b/app/models/admin/action_log_filter.rb index 1fee59e650b..02980d06477 100644 --- a/app/models/admin/action_log_filter.rb +++ b/app/models/admin/action_log_filter.rb @@ -117,6 +117,8 @@ class Admin::ActionLogFilter when 'target_domain' normalized_domain = TagManager.instance.normalize_domain(value) latest_action_logs.where(human_identifier: normalized_domain, target_type: INSTANCE_TARGET_TYPES) + when 'target_tag' + latest_action_logs.where(human_identifier: value) else raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end diff --git a/app/models/tag.rb b/app/models/tag.rb index 763df252f02..6ac34832f8f 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -111,7 +111,7 @@ class Tag < ApplicationRecord end def to_log_human_identifier - "##{display_name}" + formatted_name end class << self diff --git a/app/views/admin/tags/show.html.haml b/app/views/admin/tags/show.html.haml index 96df006b85a..ea40801e95e 100644 --- a/app/views/admin/tags/show.html.haml +++ b/app/views/admin/tags/show.html.haml @@ -95,7 +95,7 @@ %hr.spacer/ %h3= t('admin.tags.audit_log.title') - - if @action_logs.empty? + - if @action_logs.nil? %p= t('accounts.nothing_here') - else .report-notes diff --git a/spec/requests/admin/tags_spec.rb b/spec/requests/admin/tags_spec.rb index 653c5bd9356..543102e1ebe 100644 --- a/spec/requests/admin/tags_spec.rb +++ b/spec/requests/admin/tags_spec.rb @@ -15,4 +15,17 @@ RSpec.describe 'Admin Tags' do .to have_http_status(400) end end + + describe 'update tag' do + before { sign_in Fabricate(:admin_user) } + + let(:tag) { Fabricate :tag, name: '#supertag' } + + it 'redirects to tag page and saves log action for tag' do + put admin_tag_path(tag.id, params: { tag: { trendable: true } }) + + expect(response).to have_http_status(302) + expect(Admin::ActionLog.last.human_identifier).to eq(tag.formatted_name) + end + end end