Merge remote-tracking branch 'parent/main' into upstream-20231206
This commit is contained in:
commit
0199608b87
61 changed files with 781 additions and 162 deletions
|
@ -161,12 +161,13 @@ RSpec.describe Admin::AccountsController do
|
|||
it 'logs action' do
|
||||
expect(subject).to have_http_status 302
|
||||
|
||||
log_item = Admin::ActionLog.last
|
||||
|
||||
expect(log_item).to_not be_nil
|
||||
expect(log_item.action).to eq :approve
|
||||
expect(log_item.account_id).to eq current_user.account_id
|
||||
expect(log_item.target_id).to eq account.user.id
|
||||
expect(latest_admin_action_log)
|
||||
.to be_present
|
||||
.and have_attributes(
|
||||
action: eq(:approve),
|
||||
account_id: eq(current_user.account_id),
|
||||
target_id: eq(account.user.id)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -201,12 +202,13 @@ RSpec.describe Admin::AccountsController do
|
|||
it 'logs action' do
|
||||
expect(subject).to have_http_status 302
|
||||
|
||||
log_item = Admin::ActionLog.last
|
||||
|
||||
expect(log_item).to_not be_nil
|
||||
expect(log_item.action).to eq :reject
|
||||
expect(log_item.account_id).to eq current_user.account_id
|
||||
expect(log_item.target_id).to eq account.user.id
|
||||
expect(latest_admin_action_log)
|
||||
.to be_present
|
||||
.and have_attributes(
|
||||
action: eq(:reject),
|
||||
account_id: eq(current_user.account_id),
|
||||
target_id: eq(account.user.id)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -427,4 +429,10 @@ RSpec.describe Admin::AccountsController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def latest_admin_action_log
|
||||
Admin::ActionLog.last
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,11 +9,9 @@ describe Admin::ActionLogsController do
|
|||
let!(:account) { Fabricate(:account) }
|
||||
|
||||
before do
|
||||
_orphaned_logs = %w(
|
||||
Account User UserRole Report DomainBlock DomainAllow
|
||||
EmailDomainBlock UnavailableDomain Status AccountWarning
|
||||
Announcement IpBlock Instance CustomEmoji CanonicalEmailBlock Appeal
|
||||
).map { |type| Admin::ActionLog.new(account: account, action: 'destroy', target_type: type, target_id: 1312).save! }
|
||||
orphaned_log_types.map do |type|
|
||||
Fabricate(:action_log, account: account, action: 'destroy', target_type: type, target_id: 1312)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
|
@ -24,4 +22,27 @@ describe Admin::ActionLogsController do
|
|||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def orphaned_log_types
|
||||
%w(
|
||||
Account
|
||||
AccountWarning
|
||||
Announcement
|
||||
Appeal
|
||||
CanonicalEmailBlock
|
||||
CustomEmoji
|
||||
DomainAllow
|
||||
DomainBlock
|
||||
EmailDomainBlock
|
||||
Instance
|
||||
IpBlock
|
||||
Report
|
||||
Status
|
||||
UnavailableDomain
|
||||
User
|
||||
UserRole
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -192,16 +192,11 @@ RSpec.describe Admin::DomainBlocksController do
|
|||
let(:original_severity) { 'suspend' }
|
||||
let(:new_severity) { 'silence' }
|
||||
|
||||
it 'changes the block severity' do
|
||||
expect { subject }.to change { domain_block.reload.severity }.from('suspend').to('silence')
|
||||
end
|
||||
|
||||
it 'undoes individual suspensions' do
|
||||
expect { subject }.to change { remote_account.reload.suspended? }.from(true).to(false)
|
||||
end
|
||||
|
||||
it 'performs individual silences' do
|
||||
expect { subject }.to change { remote_account.reload.silenced? }.from(false).to(true)
|
||||
it 'changes the block severity, suspensions, and silences' do
|
||||
expect { subject }
|
||||
.to change_severity('suspend', 'silence')
|
||||
.and change_suspended(true, false)
|
||||
.and change_silenced(false, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -209,17 +204,26 @@ RSpec.describe Admin::DomainBlocksController do
|
|||
let(:original_severity) { 'silence' }
|
||||
let(:new_severity) { 'suspend' }
|
||||
|
||||
it 'changes the block severity' do
|
||||
expect { subject }.to change { domain_block.reload.severity }.from('silence').to('suspend')
|
||||
it 'changes the block severity, silences, and suspensions' do
|
||||
expect { subject }
|
||||
.to change_severity('silence', 'suspend')
|
||||
.and change_silenced(true, false)
|
||||
.and change_suspended(false, true)
|
||||
end
|
||||
end
|
||||
|
||||
it 'undoes individual silences' do
|
||||
expect { subject }.to change { remote_account.reload.silenced? }.from(true).to(false)
|
||||
end
|
||||
private
|
||||
|
||||
it 'performs individual suspends' do
|
||||
expect { subject }.to change { remote_account.reload.suspended? }.from(false).to(true)
|
||||
end
|
||||
def change_severity(from, to)
|
||||
change { domain_block.reload.severity }.from(from).to(to)
|
||||
end
|
||||
|
||||
def change_silenced(from, to)
|
||||
change { remote_account.reload.silenced? }.from(from).to(to)
|
||||
end
|
||||
|
||||
def change_suspended(from, to)
|
||||
change { remote_account.reload.suspended? }.from(from).to(to)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ RSpec.describe Admin::ExportDomainAllowsController do
|
|||
|
||||
get :export, params: { format: :csv }
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body).to eq(File.read(File.join(file_fixture_path, 'domain_allows.csv')))
|
||||
expect(response.body).to eq(domain_allows_csv_file)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -40,7 +40,7 @@ RSpec.describe Admin::ExportDomainAllowsController do
|
|||
# Domains should now be added
|
||||
get :export, params: { format: :csv }
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body).to eq(File.read(File.join(file_fixture_path, 'domain_allows.csv')))
|
||||
expect(response.body).to eq(domain_allows_csv_file)
|
||||
end
|
||||
|
||||
it 'displays error on no file selected' do
|
||||
|
@ -49,4 +49,10 @@ RSpec.describe Admin::ExportDomainAllowsController do
|
|||
expect(flash[:error]).to eq(I18n.t('admin.export_domain_allows.no_file'))
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def domain_allows_csv_file
|
||||
File.read(File.join(file_fixture_path, 'domain_allows.csv'))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,13 @@ RSpec.describe Admin::ExportDomainBlocksController do
|
|||
|
||||
get :export, params: { format: :csv }
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body).to eq(File.read(File.join(file_fixture_path, 'domain_blocks.csv')))
|
||||
expect(response.body).to eq(domain_blocks_csv_file)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def domain_blocks_csv_file
|
||||
File.read(File.join(file_fixture_path, 'domain_blocks.csv'))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue