mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 16:59:41 +00:00
Merge commit '77098c6f1c25958960df98a1510b28352a39704f' into glitch-soc/merge-upstream
Conflicts: - `README.md`: Upstream has updated its README, we have a completely different one. Kept ours. - `app/views/auth/sessions/two_factor.html.haml`: Upstream refactored stuff and the conflict is because of glitch-soc's theming system. Ported upstream changes while accounting for the different theming system.
This commit is contained in:
81
spec/features/admin/accounts_spec.rb
Normal file
81
spec/features/admin/accounts_spec.rb
Normal file
@@ -0,0 +1,81 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Accounts' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
let(:unapproved_user_account) { Fabricate(:account) }
|
||||
let(:approved_user_account) { Fabricate(:account) }
|
||||
|
||||
before do
|
||||
unapproved_user_account.user.update(approved: false)
|
||||
approved_user_account.user.update(approved: true)
|
||||
|
||||
visit admin_accounts_path
|
||||
end
|
||||
|
||||
context 'without selecting any accounts' do
|
||||
it 'displays a notice about account selection' do
|
||||
click_on button_for_suspend
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with action of `suspend`' do
|
||||
it 'suspends the account' do
|
||||
batch_checkbox_for(approved_user_account).check
|
||||
|
||||
click_on button_for_suspend
|
||||
|
||||
expect(approved_user_account.reload).to be_suspended
|
||||
end
|
||||
end
|
||||
|
||||
context 'with action of `approve`' do
|
||||
it 'approves the account user' do
|
||||
batch_checkbox_for(unapproved_user_account).check
|
||||
|
||||
click_on button_for_approve
|
||||
|
||||
expect(unapproved_user_account.reload.user).to be_approved
|
||||
end
|
||||
end
|
||||
|
||||
context 'with action of `reject`' do
|
||||
it 'rejects and removes the account' do
|
||||
batch_checkbox_for(unapproved_user_account).check
|
||||
|
||||
click_on button_for_reject
|
||||
|
||||
expect { unapproved_user_account.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_suspend
|
||||
I18n.t('admin.accounts.perform_full_suspension')
|
||||
end
|
||||
|
||||
def button_for_approve
|
||||
I18n.t('admin.accounts.approve')
|
||||
end
|
||||
|
||||
def button_for_reject
|
||||
I18n.t('admin.accounts.reject')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.accounts.no_account_selected')
|
||||
end
|
||||
|
||||
def batch_checkbox_for(account)
|
||||
find("#form_account_batch_account_ids_#{account.id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
33
spec/features/admin/custom_emojis_spec.rb
Normal file
33
spec/features/admin/custom_emojis_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::CustomEmojis' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_custom_emojis_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_enable
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_enable
|
||||
I18n.t('admin.custom_emojis.enable')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.custom_emojis.no_emoji_selected')
|
||||
end
|
||||
end
|
||||
end
|
||||
33
spec/features/admin/email_domain_blocks_spec.rb
Normal file
33
spec/features/admin/email_domain_blocks_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::EmailDomainBlocks' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_email_domain_blocks_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_delete
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_delete
|
||||
I18n.t('admin.email_domain_blocks.delete')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.email_domain_blocks.no_email_domain_block_selected')
|
||||
end
|
||||
end
|
||||
end
|
||||
33
spec/features/admin/ip_blocks_spec.rb
Normal file
33
spec/features/admin/ip_blocks_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::IpBlocks' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_ip_blocks_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_delete
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_delete
|
||||
I18n.t('admin.ip_blocks.delete')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.ip_blocks.no_ip_block_selected')
|
||||
end
|
||||
end
|
||||
end
|
||||
34
spec/features/admin/statuses_spec.rb
Normal file
34
spec/features/admin/statuses_spec.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Statuses' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
_status = Fabricate(:status, account: current_user.account)
|
||||
visit admin_account_statuses_path(account_id: current_user.account_id)
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_report
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_report
|
||||
I18n.t('admin.statuses.batch.report')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.statuses.no_status_selected')
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Trends::Links::PreviewCardProviders' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_trends_links_preview_card_providers_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_allow
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_allow
|
||||
I18n.t('admin.trends.allow')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.trends.links.publishers.no_publisher_selected')
|
||||
end
|
||||
end
|
||||
end
|
||||
33
spec/features/admin/trends/links_spec.rb
Normal file
33
spec/features/admin/trends/links_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Trends::Links' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_trends_links_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_allow
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_allow
|
||||
I18n.t('admin.trends.links.allow')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.trends.links.no_link_selected')
|
||||
end
|
||||
end
|
||||
end
|
||||
33
spec/features/admin/trends/statuses_spec.rb
Normal file
33
spec/features/admin/trends/statuses_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Trends::Statuses' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_trends_statuses_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_allow
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_allow
|
||||
I18n.t('admin.trends.statuses.allow')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.trends.statuses.no_status_selected')
|
||||
end
|
||||
end
|
||||
end
|
||||
33
spec/features/admin/trends/tags_spec.rb
Normal file
33
spec/features/admin/trends/tags_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Trends::Tags' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_trends_tags_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_allow
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_allow
|
||||
I18n.t('admin.trends.allow')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.trends.tags.no_tag_selected')
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -532,6 +532,44 @@ RSpec.describe FeedManager do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#unmerge_tag_from_home' do
|
||||
let(:receiver) { Fabricate(:account) }
|
||||
let(:tag) { Fabricate(:tag) }
|
||||
|
||||
it 'leaves a tagged status' do
|
||||
status = Fabricate(:status)
|
||||
status.tags << tag
|
||||
described_class.instance.push_to_home(receiver, status)
|
||||
|
||||
described_class.instance.unmerge_tag_from_home(tag, receiver)
|
||||
|
||||
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to_not include(status.id.to_s)
|
||||
end
|
||||
|
||||
it 'remains a tagged status written by receiver\'s followee' do
|
||||
followee = Fabricate(:account)
|
||||
receiver.follow!(followee)
|
||||
|
||||
status = Fabricate(:status, account: followee)
|
||||
status.tags << tag
|
||||
described_class.instance.push_to_home(receiver, status)
|
||||
|
||||
described_class.instance.unmerge_tag_from_home(tag, receiver)
|
||||
|
||||
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to include(status.id.to_s)
|
||||
end
|
||||
|
||||
it 'remains a tagged status written by receiver' do
|
||||
status = Fabricate(:status, account: receiver)
|
||||
status.tags << tag
|
||||
described_class.instance.push_to_home(receiver, status)
|
||||
|
||||
described_class.instance.unmerge_tag_from_home(tag, receiver)
|
||||
|
||||
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to include(status.id.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#clear_from_home' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:followed_account) { Fabricate(:account) }
|
||||
|
||||
Reference in New Issue
Block a user