mirror of https://github.com/mastodon/mastodon
Extract helper method for repeated form fill in admin/domain_blocks feature spec (#29128)
This commit is contained in:
parent
52986f35b8
commit
5271131658
|
@ -12,9 +12,7 @@ describe 'blocking domains through the moderation interface' do
|
||||||
it 'adds a new domain block' do
|
it 'adds a new domain block' do
|
||||||
visit new_admin_domain_block_path
|
visit new_admin_domain_block_path
|
||||||
|
|
||||||
fill_in 'domain_block_domain', with: 'example.com'
|
submit_domain_block('example.com', 'silence')
|
||||||
select I18n.t('admin.domain_blocks.new.severity.silence'), from: 'domain_block_severity'
|
|
||||||
click_on I18n.t('admin.domain_blocks.new.create')
|
|
||||||
|
|
||||||
expect(DomainBlock.exists?(domain: 'example.com', severity: 'silence')).to be true
|
expect(DomainBlock.exists?(domain: 'example.com', severity: 'silence')).to be true
|
||||||
expect(DomainBlockWorker).to have_received(:perform_async)
|
expect(DomainBlockWorker).to have_received(:perform_async)
|
||||||
|
@ -25,9 +23,7 @@ describe 'blocking domains through the moderation interface' do
|
||||||
it 'presents a confirmation screen before suspending the domain' do
|
it 'presents a confirmation screen before suspending the domain' do
|
||||||
visit new_admin_domain_block_path
|
visit new_admin_domain_block_path
|
||||||
|
|
||||||
fill_in 'domain_block_domain', with: 'example.com'
|
submit_domain_block('example.com', 'suspend')
|
||||||
select I18n.t('admin.domain_blocks.new.severity.suspend'), from: 'domain_block_severity'
|
|
||||||
click_on I18n.t('admin.domain_blocks.new.create')
|
|
||||||
|
|
||||||
# It doesn't immediately block but presents a confirmation screen
|
# It doesn't immediately block but presents a confirmation screen
|
||||||
expect(page).to have_title(I18n.t('admin.domain_blocks.confirm_suspension.title', domain: 'example.com'))
|
expect(page).to have_title(I18n.t('admin.domain_blocks.confirm_suspension.title', domain: 'example.com'))
|
||||||
|
@ -47,9 +43,7 @@ describe 'blocking domains through the moderation interface' do
|
||||||
|
|
||||||
visit new_admin_domain_block_path
|
visit new_admin_domain_block_path
|
||||||
|
|
||||||
fill_in 'domain_block_domain', with: 'example.com'
|
submit_domain_block('example.com', 'suspend')
|
||||||
select I18n.t('admin.domain_blocks.new.severity.suspend'), from: 'domain_block_severity'
|
|
||||||
click_on I18n.t('admin.domain_blocks.new.create')
|
|
||||||
|
|
||||||
# It doesn't immediately block but presents a confirmation screen
|
# It doesn't immediately block but presents a confirmation screen
|
||||||
expect(page).to have_title(I18n.t('admin.domain_blocks.confirm_suspension.title', domain: 'example.com'))
|
expect(page).to have_title(I18n.t('admin.domain_blocks.confirm_suspension.title', domain: 'example.com'))
|
||||||
|
@ -69,9 +63,7 @@ describe 'blocking domains through the moderation interface' do
|
||||||
|
|
||||||
visit new_admin_domain_block_path
|
visit new_admin_domain_block_path
|
||||||
|
|
||||||
fill_in 'domain_block_domain', with: 'subdomain.example.com'
|
submit_domain_block('subdomain.example.com', 'suspend')
|
||||||
select I18n.t('admin.domain_blocks.new.severity.suspend'), from: 'domain_block_severity'
|
|
||||||
click_on I18n.t('admin.domain_blocks.new.create')
|
|
||||||
|
|
||||||
# It doesn't immediately block but presents a confirmation screen
|
# It doesn't immediately block but presents a confirmation screen
|
||||||
expect(page).to have_title(I18n.t('admin.domain_blocks.confirm_suspension.title', domain: 'subdomain.example.com'))
|
expect(page).to have_title(I18n.t('admin.domain_blocks.confirm_suspension.title', domain: 'subdomain.example.com'))
|
||||||
|
@ -84,8 +76,11 @@ describe 'blocking domains through the moderation interface' do
|
||||||
expect(DomainBlockWorker).to have_received(:perform_async)
|
expect(DomainBlockWorker).to have_received(:perform_async)
|
||||||
|
|
||||||
# And leaves the previous block alone
|
# And leaves the previous block alone
|
||||||
expect(domain_block.reload.severity).to eq 'silence'
|
expect(domain_block.reload)
|
||||||
expect(domain_block.reload.domain).to eq 'example.com'
|
.to have_attributes(
|
||||||
|
severity: eq('silence'),
|
||||||
|
domain: eq('example.com')
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -109,4 +104,12 @@ describe 'blocking domains through the moderation interface' do
|
||||||
expect(domain_block.reload.severity).to eq 'suspend'
|
expect(domain_block.reload.severity).to eq 'suspend'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def submit_domain_block(domain, severity)
|
||||||
|
fill_in 'domain_block_domain', with: domain
|
||||||
|
select I18n.t("admin.domain_blocks.new.severity.#{severity}"), from: 'domain_block_severity'
|
||||||
|
click_on I18n.t('admin.domain_blocks.new.create')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue