mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-22 14:15:22 +00:00
Add domain_block_policies
helper method
This commit is contained in:
parent
a1ac2a73ff
commit
5fb8c95b3a
12
app/helpers/admin/domain_blocks_helper.rb
Normal file
12
app/helpers/admin/domain_blocks_helper.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Admin::DomainBlocksHelper
|
||||||
|
CONNECTOR = ' · '
|
||||||
|
|
||||||
|
def domain_block_policies(domain_block)
|
||||||
|
domain_block
|
||||||
|
.policies
|
||||||
|
.map { |policy| t("admin.instances.content_policies.policies.#{policy}") }
|
||||||
|
.join(CONNECTOR)
|
||||||
|
end
|
||||||
|
end
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
%br/
|
%br/
|
||||||
|
|
||||||
= f.object.policies.map { |policy| t(policy, scope: 'admin.instances.content_policies.policies') }.join(' · ')
|
= domain_block_policies(f.object)
|
||||||
- if f.object.public_comment.present?
|
- if f.object.public_comment.present?
|
||||||
·
|
·
|
||||||
= f.object.public_comment
|
= f.object.public_comment
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
%small
|
%small
|
||||||
- if instance.domain_block
|
- if instance.domain_block
|
||||||
= instance.domain_block.policies.map { |policy| t(policy, scope: 'admin.instances.content_policies.policies') }.join(' · ')
|
= domain_block_policies(instance.domain_block)
|
||||||
- if instance.domain_block.public_comment.present?
|
- if instance.domain_block.public_comment.present?
|
||||||
%span.comment.public-comment #{t('admin.domain_blocks.public_comment')}: #{instance.domain_block.public_comment}
|
%span.comment.public-comment #{t('admin.domain_blocks.public_comment')}: #{instance.domain_block.public_comment}
|
||||||
- if instance.domain_block.private_comment.present?
|
- if instance.domain_block.private_comment.present?
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
%td= @instance.domain_block.public_comment
|
%td= @instance.domain_block.public_comment
|
||||||
%tr
|
%tr
|
||||||
%th= t('admin.instances.content_policies.policy')
|
%th= t('admin.instances.content_policies.policy')
|
||||||
%td= @instance.domain_block.policies.map { |policy| t(policy, scope: 'admin.instances.content_policies.policies') }.join(' · ')
|
%td= domain_block_policies(@instance.domain_block)
|
||||||
|
|
||||||
= link_to t('admin.domain_blocks.edit'), edit_admin_domain_block_path(@instance.domain_block), class: 'button'
|
= link_to t('admin.domain_blocks.edit'), edit_admin_domain_block_path(@instance.domain_block), class: 'button'
|
||||||
= link_to t('admin.domain_blocks.undo'), admin_domain_block_path(@instance.domain_block), class: 'button', data: { confirm: t('admin.accounts.are_you_sure'), method: :delete }
|
= link_to t('admin.domain_blocks.undo'), admin_domain_block_path(@instance.domain_block), class: 'button', data: { confirm: t('admin.accounts.are_you_sure'), method: :delete }
|
||||||
|
|
21
spec/helpers/admin/domain_blocks_helper_spec.rb
Normal file
21
spec/helpers/admin/domain_blocks_helper_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Admin::DomainBlocksHelper do
|
||||||
|
describe '#domain_block_policies' do
|
||||||
|
subject { helper.domain_block_policies(domain_block) }
|
||||||
|
|
||||||
|
context 'with a suspend domain block' do
|
||||||
|
let(:domain_block) { Fabricate.build :domain_block, severity: :suspend }
|
||||||
|
|
||||||
|
it { is_expected.to eq('Suspend') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a multi policy domain block' do
|
||||||
|
let(:domain_block) { Fabricate.build :domain_block, severity: :silence, reject_media: true, reject_reports: true }
|
||||||
|
|
||||||
|
it { is_expected.to eq('Limit · Reject media · Reject reports') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue