mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-16 20:03:24 +00:00
Rename admin/accounts_helper to admin/filter_helper (#1816)
- Add some spec coverage for both methods - Add explicit constant call-outs for where the params are from
This commit is contained in:
parent
08059ddda9
commit
09540192c9
|
@ -1,9 +1,10 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Admin::AccountsHelper
|
module Admin::FilterHelper
|
||||||
def filter_params(more_params)
|
ACCOUNT_FILTERS = %i[local remote by_domain silenced suspended recent].freeze
|
||||||
params.permit(:local, :remote, :by_domain, :silenced, :suspended, :recent, :resolved).merge(more_params)
|
REPORT_FILTERS = %i[resolved].freeze
|
||||||
end
|
|
||||||
|
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS
|
||||||
|
|
||||||
def filter_link_to(text, more_params)
|
def filter_link_to(text, more_params)
|
||||||
new_url = filtered_url_for(more_params)
|
new_url = filtered_url_for(more_params)
|
||||||
|
@ -16,6 +17,10 @@ module Admin::AccountsHelper
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def filter_params(more_params)
|
||||||
|
params.permit(FILTERS).merge(more_params)
|
||||||
|
end
|
||||||
|
|
||||||
def filter_link_class(new_url)
|
def filter_link_class(new_url)
|
||||||
filtered_url_for(params) == new_url ? 'selected' : ''
|
filtered_url_for(params) == new_url ? 'selected' : ''
|
||||||
end
|
end
|
|
@ -1,5 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Admin::AccountsHelper, type: :helper do
|
|
||||||
|
|
||||||
end
|
|
20
spec/helpers/admin/filter_helper_spec.rb
Normal file
20
spec/helpers/admin/filter_helper_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe Admin::FilterHelper do
|
||||||
|
it 'Uses filter_link_to to create filter links' do
|
||||||
|
params = ActionController::Parameters.new(
|
||||||
|
{ test: 'test' }
|
||||||
|
)
|
||||||
|
allow(helper).to receive(:params).and_return(params)
|
||||||
|
allow(helper).to receive(:url_for).and_return('/test')
|
||||||
|
result = helper.filter_link_to('text', { resolved: true })
|
||||||
|
|
||||||
|
expect(result).to match(/text/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Uses table_link_to to create icon links' do
|
||||||
|
result = helper.table_link_to 'icon', 'text', 'path'
|
||||||
|
|
||||||
|
expect(result).to match(/text/)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue