about summary refs log tree commit diff
path: root/app/helpers/admin
diff options
context:
space:
mode:
authorysksn <bluewhale1982@gmail.com>2019-03-16 00:57:23 +0900
committerYamagishi Kazutoshi <ykzts@desire.sh>2019-03-16 00:57:23 +0900
commit782b622f5f295fc9d91bb2461dc049f55766af9c (patch)
treeea92ae0238eaaa45204fa7b0b5ecc6240fc90b9c /app/helpers/admin
parent8347479f5d801b6b9756e804b62e04e517fed196 (diff)
Add specs for action log helper (#9605)
* Add specs for ActionLogHelper

* Make some methods private

methods below never referenced from outside of their module:

- #linkable_log_target
- #log_target_from_history
Diffstat (limited to 'app/helpers/admin')
-rw-r--r--app/helpers/admin/action_logs_helper.rb72
1 files changed, 36 insertions, 36 deletions
diff --git a/app/helpers/admin/action_logs_helper.rb b/app/helpers/admin/action_logs_helper.rb
index 359d60b60..e5fbb1500 100644
--- a/app/helpers/admin/action_logs_helper.rb
+++ b/app/helpers/admin/action_logs_helper.rb
@@ -9,42 +9,6 @@ module Admin::ActionLogsHelper
     end
   end
 
-  def linkable_log_target(record)
-    case record.class.name
-    when 'Account'
-      link_to record.acct, admin_account_path(record.id)
-    when 'User'
-      link_to record.account.acct, admin_account_path(record.account_id)
-    when 'CustomEmoji'
-      record.shortcode
-    when 'Report'
-      link_to "##{record.id}", admin_report_path(record)
-    when 'DomainBlock', 'EmailDomainBlock'
-      link_to record.domain, "https://#{record.domain}"
-    when 'Status'
-      link_to record.account.acct, TagManager.instance.url_for(record)
-    when 'AccountWarning'
-      link_to record.target_account.acct, admin_account_path(record.target_account_id)
-    end
-  end
-
-  def log_target_from_history(type, attributes)
-    case type
-    when 'CustomEmoji'
-      attributes['shortcode']
-    when 'DomainBlock', 'EmailDomainBlock'
-      link_to attributes['domain'], "https://#{attributes['domain']}"
-    when 'Status'
-      tmp_status = Status.new(attributes.except('reblogs_count', 'favourites_count'))
-
-      if tmp_status.account
-        link_to tmp_status.account&.acct || "##{tmp_status.account_id}", admin_account_path(tmp_status.account_id)
-      else
-        I18n.t('admin.action_logs.deleted_status')
-      end
-    end
-  end
-
   def relevant_log_changes(log)
     if log.target_type == 'CustomEmoji' && [:enable, :disable, :destroy].include?(log.action)
       log.recorded_changes.slice('domain')
@@ -111,4 +75,40 @@ module Admin::ActionLogsHelper
   def opposite_verbs?(log)
     %w(DomainBlock EmailDomainBlock AccountWarning).include?(log.target_type)
   end
+
+  def linkable_log_target(record)
+    case record.class.name
+    when 'Account'
+      link_to record.acct, admin_account_path(record.id)
+    when 'User'
+      link_to record.account.acct, admin_account_path(record.account_id)
+    when 'CustomEmoji'
+      record.shortcode
+    when 'Report'
+      link_to "##{record.id}", admin_report_path(record)
+    when 'DomainBlock', 'EmailDomainBlock'
+      link_to record.domain, "https://#{record.domain}"
+    when 'Status'
+      link_to record.account.acct, TagManager.instance.url_for(record)
+    when 'AccountWarning'
+      link_to record.target_account.acct, admin_account_path(record.target_account_id)
+    end
+  end
+
+  def log_target_from_history(type, attributes)
+    case type
+    when 'CustomEmoji'
+      attributes['shortcode']
+    when 'DomainBlock', 'EmailDomainBlock'
+      link_to attributes['domain'], "https://#{attributes['domain']}"
+    when 'Status'
+      tmp_status = Status.new(attributes.except('reblogs_count', 'favourites_count'))
+
+      if tmp_status.account
+        link_to tmp_status.account&.acct || "##{tmp_status.account_id}", admin_account_path(tmp_status.account_id)
+      else
+        I18n.t('admin.action_logs.deleted_status')
+      end
+    end
+  end
 end