mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-07 02:11:04 +00:00
Add action_logs
association to account
This commit is contained in:
parent
e7c30cd072
commit
9b359d8daf
|
@ -4,10 +4,8 @@ module AccountableConcern
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
def log_action(action, target)
|
||||
Admin::ActionLog.create(
|
||||
account: current_account,
|
||||
action: action,
|
||||
target: target
|
||||
)
|
||||
current_account
|
||||
.action_logs
|
||||
.create(action:, target:)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -143,7 +143,7 @@ class Account < ApplicationRecord
|
|||
scope :matches_username, ->(value) { where('lower((username)::text) LIKE lower(?)', "#{value}%") }
|
||||
scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) }
|
||||
scope :without_unapproved, -> { left_outer_joins(:user).merge(User.approved.confirmed).or(remote) }
|
||||
scope :auditable, -> { where(id: Admin::ActionLog.select(:account_id).distinct) }
|
||||
scope :auditable, -> { where.associated(:action_logs).distinct }
|
||||
scope :searchable, -> { without_unapproved.without_suspended.where(moved_to_account_id: nil) }
|
||||
scope :discoverable, -> { searchable.without_silenced.where(discoverable: true).joins(:account_stat) }
|
||||
scope :by_recent_status, -> { includes(:account_stat).merge(AccountStat.by_recent_status).references(:account_stat) }
|
||||
|
|
|
@ -11,6 +11,7 @@ module Account::Associations
|
|||
has_many :account_moderation_notes
|
||||
has_many :account_pins
|
||||
has_many :account_warnings
|
||||
has_many :action_logs, class_name: 'Admin::ActionLog'
|
||||
has_many :aliases, class_name: 'AccountAlias'
|
||||
has_many :bookmarks
|
||||
has_many :conversations, class_name: 'AccountConversation'
|
||||
|
|
|
@ -6,6 +6,10 @@ RSpec.describe Account do
|
|||
it_behaves_like 'Account::Search'
|
||||
it_behaves_like 'Reviewable'
|
||||
|
||||
describe 'Associations' do
|
||||
it { is_expected.to have_many(:action_logs).class_name('Admin::ActionLog') }
|
||||
end
|
||||
|
||||
context 'with an account record' do
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user