:remote,
:by_domain,
:silenced,
- :recent,
+ :alphabetic,
:suspended,
:username,
:display_name,
# frozen_string_literal: true
module Admin::FilterHelper
- ACCOUNT_FILTERS = %i(local remote by_domain silenced suspended recent username display_name email ip staff).freeze
+ ACCOUNT_FILTERS = %i(local remote by_domain silenced suspended alphabetic username display_name email ip staff).freeze
REPORT_FILTERS = %i(resolved account_id target_account_id).freeze
INVITE_FILTER = %i(available expired).freeze
CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze
end
def results
- scope = Account.alphabetic
+ scope = Account.recent
params.each do |key, value|
scope.merge!(scope_for(key, value)) if value.present?
Account.where(domain: value)
when 'silenced'
Account.silenced
- when 'recent'
- Account.recent
+ when 'alphabetic'
+ Account.reorder(nil).alphabetic
when 'suspended'
Account.suspended
when 'username'
.filter-subset
%strong= t('admin.accounts.order.title')
%ul
- %li= filter_link_to t('admin.accounts.order.alphabetic'), recent: nil
- %li= filter_link_to t('admin.accounts.order.most_recent'), recent: '1'
+ %li= filter_link_to t('admin.accounts.order.most_recent'), alphabetic: nil
+ %li= filter_link_to t('admin.accounts.order.alphabetic'), alphabetic: '1'
= form_tag admin_accounts_url, method: 'GET', class: 'simple_form' do
.fields-group
expect(h[:remote]).to eq '1'
expect(h[:by_domain]).to eq 'domain'
expect(h[:silenced]).to eq '1'
- expect(h[:recent]).to eq '1'
+ expect(h[:alphabetic]).to eq '1'
expect(h[:suspended]).to eq '1'
expect(h[:username]).to eq 'username'
expect(h[:display_name]).to eq 'display name'
remote: '1',
by_domain: 'domain',
silenced: '1',
- recent: '1',
+ alphabetic: '1',
suspended: '1',
username: 'username',
display_name: 'display name',
describe AccountFilter do
describe 'with empty params' do
- it 'defaults to alphabetic account list' do
+ it 'defaults to recent account list' do
filter = described_class.new({})
- expect(filter.results).to eq Account.alphabetic
+ expect(filter.results).to eq Account.recent
end
end
end
describe 'that call account methods' do
- %i(local remote silenced recent suspended).each do |option|
+ %i(local remote silenced alphabetic suspended).each do |option|
it "delegates the #{option} option" do
allow(Account).to receive(option).and_return(Account.none)
filter = described_class.new({ option => true })