Change admin accounts default sort to most recent (#8813)

master
Eugen Rochko 6 years ago committed by GitHub
parent 7fe137d2f7
commit e645ae9561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/controllers/admin/accounts_controller.rb
  2. 2
      app/helpers/admin/filter_helper.rb
  3. 6
      app/models/account_filter.rb
  4. 4
      app/views/admin/accounts/index.html.haml
  5. 4
      spec/controllers/admin/accounts_controller_spec.rb
  6. 6
      spec/models/account_filter_spec.rb

@ -95,7 +95,7 @@ module Admin
:remote,
:by_domain,
:silenced,
:recent,
:alphabetic,
:suspended,
:username,
:display_name,

@ -1,7 +1,7 @@
# 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

@ -8,7 +8,7 @@ class AccountFilter
end
def results
scope = Account.alphabetic
scope = Account.recent
params.each do |key, value|
scope.merge!(scope_for(key, value)) if value.present?
@ -29,8 +29,8 @@ class AccountFilter
Account.where(domain: value)
when 'silenced'
Account.silenced
when 'recent'
Account.recent
when 'alphabetic'
Account.reorder(nil).alphabetic
when 'suspended'
Account.suspended
when 'username'

@ -38,8 +38,8 @@
.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

@ -25,7 +25,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
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'
@ -40,7 +40,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
remote: '1',
by_domain: 'domain',
silenced: '1',
recent: '1',
alphabetic: '1',
suspended: '1',
username: 'username',
display_name: 'display name',

@ -2,10 +2,10 @@ require 'rails_helper'
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
@ -60,7 +60,7 @@ describe AccountFilter do
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 })

Loading…
Cancel
Save