Merge remote-tracking branch 'parent/main' into upstream-20250328
This commit is contained in:
commit
12ed20b6d5
257 changed files with 3505 additions and 2010 deletions
|
@ -1,35 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::AccountActionsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
it 'returns http success' do
|
||||
get :new, params: { account_id: account.id }
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
it 'records the account action' do
|
||||
expect do
|
||||
post :create, params: { account_id: account.id, admin_account_action: { type: 'silence' } }
|
||||
end.to change { account.strikes.count }.by(1)
|
||||
|
||||
expect(response).to redirect_to(admin_account_path(account.id))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,48 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::ActionLogsController do
|
||||
render_views
|
||||
|
||||
# Action logs typically cause issues when their targets are not in the database
|
||||
let!(:account) { Fabricate(:account) }
|
||||
|
||||
before do
|
||||
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
|
||||
it 'returns 200' do
|
||||
sign_in Fabricate(:admin_user)
|
||||
get :index, params: { page: 1 }
|
||||
|
||||
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
|
|
@ -1,48 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::ChangeEmailsController do
|
||||
render_views
|
||||
|
||||
let(:admin) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in admin
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
user = Fabricate(:user)
|
||||
|
||||
get :show, params: { account_id: user.account.id }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #update' do
|
||||
before do
|
||||
allow(UserMailer).to receive(:confirmation_instructions)
|
||||
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
user = Fabricate(:user)
|
||||
|
||||
previous_email = user.email
|
||||
|
||||
post :update, params: { account_id: user.account.id, user: { unconfirmed_email: 'test@example.com' } }
|
||||
|
||||
user.reload
|
||||
|
||||
expect(user.email).to eq previous_email
|
||||
expect(user.unconfirmed_email).to eq 'test@example.com'
|
||||
expect(user.confirmation_token).to_not be_nil
|
||||
|
||||
expect(UserMailer).to have_received(:confirmation_instructions).with(user, user.confirmation_token, { to: 'test@example.com' })
|
||||
|
||||
expect(response).to redirect_to(admin_account_path(user.account.id))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,35 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::DashboardController do
|
||||
render_views
|
||||
|
||||
describe 'GET #index' do
|
||||
let(:user) { Fabricate(:owner_user) }
|
||||
|
||||
before do
|
||||
stub_system_checks
|
||||
Fabricate :software_update
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
it 'returns http success and body with system check messages' do
|
||||
get :index
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
body: include(I18n.t('admin.system_checks.software_version_patch_check.message_html'))
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def stub_system_checks
|
||||
stub_const 'Admin::SystemCheck::ACTIVE_CHECKS', [
|
||||
Admin::SystemCheck::SoftwareVersionCheck,
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,54 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require 'webauthn/fake_client'
|
||||
|
||||
RSpec.describe Admin::Users::TwoFactorAuthenticationsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
sign_in Fabricate(:admin_user), scope: :user
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
context 'when user has OTP enabled' do
|
||||
before do
|
||||
user.update(otp_required_for_login: true)
|
||||
end
|
||||
|
||||
it 'redirects to admin account page' do
|
||||
delete :destroy, params: { user_id: user.id }
|
||||
|
||||
user.reload
|
||||
expect(user.otp_enabled?).to be false
|
||||
expect(response).to redirect_to(admin_account_path(user.account_id))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user has OTP and WebAuthn enabled' do
|
||||
let(:fake_client) { WebAuthn::FakeClient.new('http://test.host') }
|
||||
|
||||
before do
|
||||
user.update(otp_required_for_login: true, webauthn_id: WebAuthn.generate_user_id)
|
||||
|
||||
public_key_credential = WebAuthn::Credential.from_create(fake_client.create)
|
||||
Fabricate(:webauthn_credential,
|
||||
user_id: user.id,
|
||||
external_id: public_key_credential.id,
|
||||
public_key: public_key_credential.public_key,
|
||||
nickname: 'Security Key')
|
||||
end
|
||||
|
||||
it 'redirects to admin account page' do
|
||||
delete :destroy, params: { user_id: user.id }
|
||||
|
||||
user.reload
|
||||
expect(user.otp_enabled?).to be false
|
||||
expect(user.webauthn_enabled?).to be false
|
||||
expect(response).to redirect_to(admin_account_path(user.account_id))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue