Merge remote-tracking branch 'parent/main' into upstream-20250210

This commit is contained in:
KMY 2025-02-17 08:57:56 +09:00
commit 935bea989d
69 changed files with 1646 additions and 1363 deletions

View file

@ -59,16 +59,15 @@ RSpec.describe Admin::AccountsController do
let(:account) { Fabricate(:account) }
it 'includes moderation notes' do
note1 = Fabricate(:account_moderation_note, target_account: account)
note2 = Fabricate(:account_moderation_note, target_account: account)
note1 = Fabricate(:account_moderation_note, target_account: account, content: 'Note 1 remarks')
note2 = Fabricate(:account_moderation_note, target_account: account, content: 'Note 2 remarks')
get :show, params: { id: account.id }
expect(response).to have_http_status(200)
moderation_notes = assigns(:moderation_notes).to_a
expect(moderation_notes.size).to be 2
expect(moderation_notes).to eq [note1, note2]
expect(response.body)
.to include(note1.content)
.and include(note2.content)
end
end

View file

@ -3,40 +3,54 @@
require 'rails_helper'
RSpec.describe Admin::BaseController do
render_views
controller do
def success
authorize :dashboard, :index?
render 'admin/reports/show'
render html: '<p>success</p>', layout: true
end
end
it 'requires administrator or moderator' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user))
get :success
before { routes.draw { get 'success' => 'admin/base#success' } }
expect(response).to have_http_status(403)
context 'when signed in as regular user' do
before { sign_in Fabricate(:user) }
it 'responds with unauthorized' do
get :success
expect(response).to have_http_status(403)
end
end
it 'returns private cache control headers' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:moderator_user))
get :success
context 'when signed in as moderator' do
before { sign_in Fabricate(:moderator_user) }
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns success with private headers and admin layout' do
get :success
expect(response)
.to have_http_status(200)
expect(response.headers['Cache-Control'])
.to include('private, no-store')
expect(response.parsed_body)
.to have_css('body.admin')
end
end
it 'renders admin layout as a moderator' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:moderator_user))
get :success
expect(response).to render_template layout: 'admin'
end
context 'when signed in as admin' do
before { sign_in Fabricate(:admin_user) }
it 'renders admin layout as an admin' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:admin_user))
get :success
expect(response).to render_template layout: 'admin'
it 'returns success with private headers and admin layout' do
get :success
expect(response)
.to have_http_status(200)
expect(response.headers['Cache-Control'])
.to include('private, no-store')
expect(response.parsed_body)
.to have_css('body.admin')
end
end
end

View file

@ -49,23 +49,11 @@ RSpec.describe Admin::InstancesController do
expect(response).to have_http_status(200)
instance = assigns(:instance)
expect(instance).to_not be_new_record
expect(response.body)
.to include(I18n.t('admin.instances.totals_time_period_hint_html'))
.and include(I18n.t('accounts.nothing_here'))
expect(Admin::ActionLogFilter).to have_received(:new).with(target_domain: account_popular_main.domain)
action_logs = assigns(:action_logs).to_a
expect(action_logs.size).to eq 0
end
context 'with an unknown domain' do
it 'returns http success' do
get :show, params: { id: 'unknown.example' }
expect(response).to have_http_status(200)
instance = assigns(:instance)
expect(instance).to be_new_record
end
end
end