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

This commit is contained in:
KMY 2024-05-17 08:53:59 +09:00
commit 094ff9d2ee
153 changed files with 1412 additions and 631 deletions

View file

@ -24,10 +24,19 @@ RSpec.describe Admin::AccountModerationNotesController do
end
end
context 'when parameters are invalid' do
context 'when the content is too short' do
let(:params) { { account_moderation_note: { target_account_id: target_account.id, content: '' } } }
it 'falls to create a note' do
it 'fails to create a note' do
expect { subject }.to_not change(AccountModerationNote, :count)
expect(response).to render_template 'admin/accounts/show'
end
end
context 'when the content is too long' do
let(:params) { { account_moderation_note: { target_account_id: target_account.id, content: 'test' * AccountModerationNote::CONTENT_SIZE_LIMIT } } }
it 'fails to create a note' do
expect { subject }.to_not change(AccountModerationNote, :count)
expect(response).to render_template 'admin/accounts/show'
end

View file

@ -22,7 +22,7 @@ describe Admin::ReportNotesController do
let(:account_id) { nil }
context 'when create_and_resolve flag is on' do
let(:params) { { report_note: { content: 'test content', report_id: report.id }, create_and_resolve: nil } }
let(:params) { { report_note: { report_id: report.id, content: 'test content' }, create_and_resolve: nil } }
it 'creates a report note and resolves report' do
expect { subject }.to change(ReportNote, :count).by(1)
@ -32,7 +32,7 @@ describe Admin::ReportNotesController do
end
context 'when create_and_resolve flag is false' do
let(:params) { { report_note: { content: 'test content', report_id: report.id } } }
let(:params) { { report_note: { report_id: report.id, content: 'test content' } } }
it 'creates a report note and does not resolve report' do
expect { subject }.to change(ReportNote, :count).by(1)
@ -47,7 +47,7 @@ describe Admin::ReportNotesController do
let(:account_id) { user.account.id }
context 'when create_and_unresolve flag is on' do
let(:params) { { report_note: { content: 'test content', report_id: report.id }, create_and_unresolve: nil } }
let(:params) { { report_note: { report_id: report.id, content: 'test content' }, create_and_unresolve: nil } }
it 'creates a report note and unresolves report' do
expect { subject }.to change(ReportNote, :count).by(1)
@ -57,7 +57,7 @@ describe Admin::ReportNotesController do
end
context 'when create_and_unresolve flag is false' do
let(:params) { { report_note: { content: 'test content', report_id: report.id } } }
let(:params) { { report_note: { report_id: report.id, content: 'test content' } } }
it 'creates a report note and does not unresolve report' do
expect { subject }.to change(ReportNote, :count).by(1)
@ -68,12 +68,24 @@ describe Admin::ReportNotesController do
end
end
context 'when parameter is invalid' do
let(:params) { { report_note: { content: '', report_id: report.id } } }
context 'when content is too short' do
let(:params) { { report_note: { report_id: report.id, content: '' } } }
let(:action_taken) { nil }
let(:account_id) { nil }
it 'renders admin/reports/show' do
expect { subject }.to_not change(ReportNote, :count)
expect(subject).to render_template 'admin/reports/show'
end
end
context 'when content is too long' do
let(:params) { { report_note: { report_id: report.id, content: 'test' * ReportNote::CONTENT_SIZE_LIMIT } } }
let(:action_taken) { nil }
let(:account_id) { nil }
it 'renders admin/reports/show' do
expect { subject }.to_not change(ReportNote, :count)
expect(subject).to render_template 'admin/reports/show'
end
end

View file

@ -2,20 +2,20 @@
require 'rails_helper'
RSpec.describe CacheConcern do
RSpec.describe PreloadingConcern do
controller(ApplicationController) do
include CacheConcern
include PreloadingConcern
def empty_array
render plain: cache_collection([], Status).size
render plain: preload_collection([], Status).size
end
def empty_relation
render plain: cache_collection(Status.none, Status).size
render plain: preload_collection(Status.none, Status).size
end
def account_statuses_favourites
render plain: cache_collection(Status.where(account_id: params[:id]), Status).map(&:favourites_count)
render plain: preload_collection(Status.where(account_id: params[:id]), Status).map(&:favourites_count)
end
end
@ -27,7 +27,7 @@ RSpec.describe CacheConcern do
end
end
describe '#cache_collection' do
describe '#preload_collection' do
context 'when given an empty array' do
it 'returns an empty array' do
get :empty_array