mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-17 15:47:15 +01:00
Expand coverage of admin/trends/* areas (#33581)
This commit is contained in:
parent
4a2813158d
commit
a9a8b6b701
@ -5,20 +5,49 @@ require 'rails_helper'
|
|||||||
RSpec.describe 'Admin::Trends::Links::PreviewCardProviders' do
|
RSpec.describe 'Admin::Trends::Links::PreviewCardProviders' do
|
||||||
let(:current_user) { Fabricate(:admin_user) }
|
let(:current_user) { Fabricate(:admin_user) }
|
||||||
|
|
||||||
before do
|
before { sign_in current_user }
|
||||||
sign_in current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'Performing batch updates' do
|
describe 'Performing batch updates' do
|
||||||
before do
|
|
||||||
visit admin_trends_links_preview_card_providers_path
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'without selecting any records' do
|
context 'without selecting any records' do
|
||||||
it 'displays a notice about selection' do
|
it 'displays a notice about selection' do
|
||||||
|
visit admin_trends_links_preview_card_providers_path
|
||||||
|
|
||||||
click_on button_for_allow
|
click_on button_for_allow
|
||||||
|
|
||||||
expect(page).to have_content(selection_error_text)
|
expect(page)
|
||||||
|
.to have_content(selection_error_text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with providers that are not trendable' do
|
||||||
|
let!(:provider) { Fabricate :preview_card_provider, trendable: false }
|
||||||
|
|
||||||
|
it 'allows the providers' do
|
||||||
|
visit admin_trends_links_preview_card_providers_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_allow }
|
||||||
|
.to change { provider.reload.trendable? }.from(false).to(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with providers that are trendable' do
|
||||||
|
let!(:provider) { Fabricate :preview_card_provider, trendable: true }
|
||||||
|
|
||||||
|
it 'disallows the providers' do
|
||||||
|
visit admin_trends_links_preview_card_providers_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_disallow }
|
||||||
|
.to change { provider.reload.trendable? }.from(true).to(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_item
|
||||||
|
within '.batch-table__row' do
|
||||||
|
find('input[type=checkbox]').check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -26,6 +55,10 @@ RSpec.describe 'Admin::Trends::Links::PreviewCardProviders' do
|
|||||||
I18n.t('admin.trends.allow')
|
I18n.t('admin.trends.allow')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def button_for_disallow
|
||||||
|
I18n.t('admin.trends.disallow')
|
||||||
|
end
|
||||||
|
|
||||||
def selection_error_text
|
def selection_error_text
|
||||||
I18n.t('admin.trends.links.publishers.no_publisher_selected')
|
I18n.t('admin.trends.links.publishers.no_publisher_selected')
|
||||||
end
|
end
|
||||||
|
@ -5,20 +5,77 @@ require 'rails_helper'
|
|||||||
RSpec.describe 'Admin::Trends::Links' do
|
RSpec.describe 'Admin::Trends::Links' do
|
||||||
let(:current_user) { Fabricate(:admin_user) }
|
let(:current_user) { Fabricate(:admin_user) }
|
||||||
|
|
||||||
before do
|
before { sign_in current_user }
|
||||||
sign_in current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'Performing batch updates' do
|
describe 'Performing batch updates' do
|
||||||
before do
|
|
||||||
visit admin_trends_links_path
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'without selecting any records' do
|
context 'without selecting any records' do
|
||||||
it 'displays a notice about selection' do
|
it 'displays a notice about selection' do
|
||||||
|
visit admin_trends_links_path
|
||||||
|
|
||||||
click_on button_for_allow
|
click_on button_for_allow
|
||||||
|
|
||||||
expect(page).to have_content(selection_error_text)
|
expect(page)
|
||||||
|
.to have_content(selection_error_text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with links that are not trendable' do
|
||||||
|
let!(:preview_card_trend) { Fabricate :preview_card_trend, preview_card: Fabricate(:preview_card, trendable: false) }
|
||||||
|
|
||||||
|
it 'allows the links' do
|
||||||
|
visit admin_trends_links_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_allow }
|
||||||
|
.to change { preview_card_trend.preview_card.reload.trendable? }.from(false).to(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with links whose providers are not trendable' do
|
||||||
|
let(:preview_card_provider) { Fabricate :preview_card_provider, trendable: false }
|
||||||
|
let!(:preview_card_trend) { Fabricate :preview_card_trend, preview_card: Fabricate(:preview_card, url: "https://#{preview_card_provider.domain}/page") }
|
||||||
|
|
||||||
|
it 'allows the providers of the links' do
|
||||||
|
visit admin_trends_links_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_allow_providers }
|
||||||
|
.to change { preview_card_trend.preview_card.provider.reload.trendable? }.from(false).to(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with links that are trendable' do
|
||||||
|
let!(:preview_card_trend) { Fabricate :preview_card_trend, preview_card: Fabricate(:preview_card, trendable: true) }
|
||||||
|
|
||||||
|
it 'disallows the links' do
|
||||||
|
visit admin_trends_links_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_disallow }
|
||||||
|
.to change { preview_card_trend.preview_card.reload.trendable? }.from(true).to(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with links whose providers are trendable' do
|
||||||
|
let(:preview_card_provider) { Fabricate :preview_card_provider, trendable: true }
|
||||||
|
let!(:preview_card_trend) { Fabricate :preview_card_trend, preview_card: Fabricate(:preview_card, url: "https://#{preview_card_provider.domain}/page") }
|
||||||
|
|
||||||
|
it 'disallows the links' do
|
||||||
|
visit admin_trends_links_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_disallow_providers }
|
||||||
|
.to change { preview_card_trend.preview_card.provider.reload.trendable? }.from(true).to(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_item
|
||||||
|
within '.batch-table__row' do
|
||||||
|
find('input[type=checkbox]').check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -26,6 +83,18 @@ RSpec.describe 'Admin::Trends::Links' do
|
|||||||
I18n.t('admin.trends.links.allow')
|
I18n.t('admin.trends.links.allow')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def button_for_allow_providers
|
||||||
|
I18n.t('admin.trends.links.allow_provider')
|
||||||
|
end
|
||||||
|
|
||||||
|
def button_for_disallow
|
||||||
|
I18n.t('admin.trends.links.disallow')
|
||||||
|
end
|
||||||
|
|
||||||
|
def button_for_disallow_providers
|
||||||
|
I18n.t('admin.trends.links.disallow_provider')
|
||||||
|
end
|
||||||
|
|
||||||
def selection_error_text
|
def selection_error_text
|
||||||
I18n.t('admin.trends.links.no_link_selected')
|
I18n.t('admin.trends.links.no_link_selected')
|
||||||
end
|
end
|
||||||
|
@ -5,20 +5,75 @@ require 'rails_helper'
|
|||||||
RSpec.describe 'Admin::Trends::Statuses' do
|
RSpec.describe 'Admin::Trends::Statuses' do
|
||||||
let(:current_user) { Fabricate(:admin_user) }
|
let(:current_user) { Fabricate(:admin_user) }
|
||||||
|
|
||||||
before do
|
before { sign_in current_user }
|
||||||
sign_in current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'Performing batch updates' do
|
describe 'Performing batch updates' do
|
||||||
before do
|
|
||||||
visit admin_trends_statuses_path
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'without selecting any records' do
|
context 'without selecting any records' do
|
||||||
it 'displays a notice about selection' do
|
it 'displays a notice about selection' do
|
||||||
|
visit admin_trends_statuses_path
|
||||||
|
|
||||||
click_on button_for_allow
|
click_on button_for_allow
|
||||||
|
|
||||||
expect(page).to have_content(selection_error_text)
|
expect(page)
|
||||||
|
.to have_content(selection_error_text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with statuses that are not trendable' do
|
||||||
|
let!(:status_trend) { Fabricate :status_trend, status: Fabricate(:status, trendable: false) }
|
||||||
|
|
||||||
|
it 'allows the statuses' do
|
||||||
|
visit admin_trends_statuses_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_allow }
|
||||||
|
.to change { status_trend.status.reload.trendable? }.from(false).to(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with statuses whose accounts are not trendable' do
|
||||||
|
let!(:status_trend) { Fabricate :status_trend, status: Fabricate(:status, account: Fabricate(:account, trendable: false)) }
|
||||||
|
|
||||||
|
it 'allows the accounts of the statuses' do
|
||||||
|
visit admin_trends_statuses_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_allow_accounts }
|
||||||
|
.to change { status_trend.status.account.reload.trendable? }.from(false).to(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with statuses that are trendable' do
|
||||||
|
let!(:status_trend) { Fabricate :status_trend, status: Fabricate(:status, trendable: true) }
|
||||||
|
|
||||||
|
it 'disallows the statuses' do
|
||||||
|
visit admin_trends_statuses_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_disallow }
|
||||||
|
.to change { status_trend.status.reload.trendable? }.from(true).to(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with statuses whose accounts are trendable' do
|
||||||
|
let!(:status_trend) { Fabricate :status_trend, status: Fabricate(:status, account: Fabricate(:account, trendable: true)) }
|
||||||
|
|
||||||
|
it 'disallows the statuses' do
|
||||||
|
visit admin_trends_statuses_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_disallow_accounts }
|
||||||
|
.to change { status_trend.status.reload.trendable? }.from(true).to(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_item
|
||||||
|
within '.batch-table__row' do
|
||||||
|
find('input[type=checkbox]').check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -26,6 +81,18 @@ RSpec.describe 'Admin::Trends::Statuses' do
|
|||||||
I18n.t('admin.trends.statuses.allow')
|
I18n.t('admin.trends.statuses.allow')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def button_for_allow_accounts
|
||||||
|
I18n.t('admin.trends.statuses.allow_account')
|
||||||
|
end
|
||||||
|
|
||||||
|
def button_for_disallow
|
||||||
|
I18n.t('admin.trends.statuses.disallow')
|
||||||
|
end
|
||||||
|
|
||||||
|
def button_for_disallow_accounts
|
||||||
|
I18n.t('admin.trends.statuses.disallow_account')
|
||||||
|
end
|
||||||
|
|
||||||
def selection_error_text
|
def selection_error_text
|
||||||
I18n.t('admin.trends.statuses.no_status_selected')
|
I18n.t('admin.trends.statuses.no_status_selected')
|
||||||
end
|
end
|
||||||
|
@ -5,27 +5,59 @@ require 'rails_helper'
|
|||||||
RSpec.describe 'Admin::Trends::Tags' do
|
RSpec.describe 'Admin::Trends::Tags' do
|
||||||
let(:current_user) { Fabricate(:admin_user) }
|
let(:current_user) { Fabricate(:admin_user) }
|
||||||
|
|
||||||
before do
|
before { sign_in current_user }
|
||||||
sign_in current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'Performing batch updates' do
|
describe 'Performing batch updates' do
|
||||||
before do
|
|
||||||
visit admin_trends_tags_path
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'without selecting any records' do
|
context 'without selecting any records' do
|
||||||
it 'displays a notice about selection' do
|
it 'displays a notice about selection' do
|
||||||
|
visit admin_trends_tags_path
|
||||||
|
|
||||||
click_on button_for_allow
|
click_on button_for_allow
|
||||||
|
|
||||||
expect(page).to have_content(selection_error_text)
|
expect(page).to have_content(selection_error_text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with tags that are not trendable' do
|
||||||
|
let!(:tag_trend) { Fabricate :tag_trend, tag: Fabricate(:tag, trendable: false) }
|
||||||
|
|
||||||
|
it 'allows the tags' do
|
||||||
|
visit admin_trends_tags_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_allow }
|
||||||
|
.to change { tag_trend.tag.reload.trendable? }.from(false).to(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with tags that are trendable' do
|
||||||
|
let!(:tag_trend) { Fabricate :tag_trend, tag: Fabricate(:tag, trendable: true) }
|
||||||
|
|
||||||
|
it 'disallows the tags' do
|
||||||
|
visit admin_trends_tags_path
|
||||||
|
|
||||||
|
check_item
|
||||||
|
|
||||||
|
expect { click_on button_for_disallow }
|
||||||
|
.to change { tag_trend.tag.reload.trendable? }.from(true).to(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_item
|
||||||
|
within '.batch-table__row' do
|
||||||
|
find('input[type=checkbox]').check
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def button_for_allow
|
def button_for_allow
|
||||||
I18n.t('admin.trends.allow')
|
I18n.t('admin.trends.allow')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def button_for_disallow
|
||||||
|
I18n.t('admin.trends.disallow')
|
||||||
|
end
|
||||||
|
|
||||||
def selection_error_text
|
def selection_error_text
|
||||||
I18n.t('admin.trends.tags.no_tag_selected')
|
I18n.t('admin.trends.tags.no_tag_selected')
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user