Favoring constant over magic string (#15852)
This commit is contained in:
parent
2bf13cab00
commit
0b8c09851c
3 changed files with 5 additions and 3 deletions
|
|
@ -5,7 +5,7 @@ module Admin
|
|||
def index
|
||||
@q = AuditLog
|
||||
.includes(:user)
|
||||
.where(category: "moderator.audit.log")
|
||||
.where(category: AuditLog::MODERATOR_AUDIT_LOG_CATEGORY)
|
||||
.order(created_at: :desc)
|
||||
.ransack(params[:q])
|
||||
@moderator_actions = @q.result.page(params[:page] || 1).per(25)
|
||||
|
|
|
|||
|
|
@ -2,4 +2,6 @@ class AuditLog < ApplicationRecord
|
|||
belongs_to :user, optional: true
|
||||
|
||||
validates :data, presence: true
|
||||
|
||||
MODERATOR_AUDIT_LOG_CATEGORY = "moderator.audit.log".freeze
|
||||
end
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ RSpec.describe "/admin/moderation/moderator_reactions", type: :request do
|
|||
it "renders the page with a user's audit log" do
|
||||
audit_log = create(
|
||||
:audit_log,
|
||||
category: "moderator.audit.log",
|
||||
category: AuditLog::MODERATOR_AUDIT_LOG_CATEGORY,
|
||||
user: admin,
|
||||
roles: admin.roles.pluck(:name),
|
||||
)
|
||||
|
|
@ -57,7 +57,7 @@ RSpec.describe "/admin/moderation/moderator_reactions", type: :request do
|
|||
it "renders the page with an audit log not belonging to a specific user" do
|
||||
audit_log = create(
|
||||
:audit_log,
|
||||
category: "moderator.audit.log",
|
||||
category: AuditLog::MODERATOR_AUDIT_LOG_CATEGORY,
|
||||
user: nil,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue