Merge remote-tracking branch 'parent/main' into upstream-20231204
This commit is contained in:
commit
94c2396a34
179 changed files with 1036 additions and 775 deletions
|
@ -20,7 +20,7 @@ RSpec.describe Admin::AccountModerationNotesController do
|
|||
|
||||
it 'successfully creates a note' do
|
||||
expect { subject }.to change(AccountModerationNote, :count).by(1)
|
||||
expect(subject).to redirect_to admin_account_path(target_account.id)
|
||||
expect(response).to redirect_to admin_account_path(target_account.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,7 +29,7 @@ RSpec.describe Admin::AccountModerationNotesController do
|
|||
|
||||
it 'falls to create a note' do
|
||||
expect { subject }.to_not change(AccountModerationNote, :count)
|
||||
expect(subject).to render_template 'admin/accounts/show'
|
||||
expect(response).to render_template 'admin/accounts/show'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -42,7 +42,7 @@ RSpec.describe Admin::AccountModerationNotesController do
|
|||
|
||||
it 'destroys note' do
|
||||
expect { subject }.to change(AccountModerationNote, :count).by(-1)
|
||||
expect(subject).to redirect_to admin_account_path(target_account.id)
|
||||
expect(response).to redirect_to admin_account_path(target_account.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,24 +12,24 @@ describe Admin::CustomEmojisController do
|
|||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
subject { get :index }
|
||||
|
||||
before do
|
||||
Fabricate(:custom_emoji)
|
||||
end
|
||||
|
||||
it 'renders index page' do
|
||||
expect(subject).to have_http_status 200
|
||||
expect(subject).to render_template :index
|
||||
get :index
|
||||
|
||||
expect(response).to have_http_status 200
|
||||
expect(response).to render_template :index
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
subject { get :new }
|
||||
|
||||
it 'renders new page' do
|
||||
expect(subject).to have_http_status 200
|
||||
expect(subject).to render_template :new
|
||||
get :new
|
||||
|
||||
expect(response).to have_http_status 200
|
||||
expect(response).to render_template :new
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ describe Admin::ReportNotesController do
|
|||
it 'creates a report note and resolves report' do
|
||||
expect { subject }.to change(ReportNote, :count).by(1)
|
||||
expect(report.reload).to be_action_taken
|
||||
expect(subject).to redirect_to admin_reports_path
|
||||
expect(response).to redirect_to admin_reports_path
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,7 +37,7 @@ describe Admin::ReportNotesController do
|
|||
it 'creates a report note and does not resolve report' do
|
||||
expect { subject }.to change(ReportNote, :count).by(1)
|
||||
expect(report.reload).to_not be_action_taken
|
||||
expect(subject).to redirect_to admin_report_path(report)
|
||||
expect(response).to redirect_to admin_report_path(report)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -52,7 +52,7 @@ describe Admin::ReportNotesController do
|
|||
it 'creates a report note and unresolves report' do
|
||||
expect { subject }.to change(ReportNote, :count).by(1)
|
||||
expect(report.reload).to_not be_action_taken
|
||||
expect(subject).to redirect_to admin_report_path(report)
|
||||
expect(response).to redirect_to admin_report_path(report)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -62,7 +62,7 @@ describe Admin::ReportNotesController do
|
|||
it 'creates a report note and does not unresolve report' do
|
||||
expect { subject }.to change(ReportNote, :count).by(1)
|
||||
expect(report.reload).to be_action_taken
|
||||
expect(subject).to redirect_to admin_report_path(report)
|
||||
expect(response).to redirect_to admin_report_path(report)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -86,7 +86,7 @@ describe Admin::ReportNotesController do
|
|||
|
||||
it 'deletes note' do
|
||||
expect { subject }.to change(ReportNote, :count).by(-1)
|
||||
expect(subject).to redirect_to admin_report_path(report_note.report)
|
||||
expect(response).to redirect_to admin_report_path(report_note.report)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ describe Api::V1::Accounts::FamiliarFollowersController do
|
|||
account_ids = [account_a, account_b, account_b, account_a, account_a].map { |a| a.id.to_s }
|
||||
get :index, params: { id: account_ids }
|
||||
|
||||
expect(body_as_json.pluck(:id)).to eq [account_a.id.to_s, account_b.id.to_s]
|
||||
expect(body_as_json.pluck(:id)).to contain_exactly(account_a.id.to_s, account_b.id.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,6 +34,26 @@ RSpec.describe Api::V2::SearchController do
|
|||
expect(body_as_json[:accounts].pluck(:id)).to contain_exactly(bob.id.to_s, ana.id.to_s, tom.id.to_s)
|
||||
end
|
||||
|
||||
context 'with truthy `resolve`' do
|
||||
let(:params) { { q: 'test1', resolve: '1' } }
|
||||
|
||||
it 'returns http unauthorized' do
|
||||
get :index, params: params
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with `offset`' do
|
||||
let(:params) { { q: 'test1', offset: 1 } }
|
||||
|
||||
it 'returns http unauthorized' do
|
||||
get :index, params: params
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with following=true' do
|
||||
let(:params) { { q: 'test', type: 'accounts', following: 'true' } }
|
||||
|
||||
|
@ -48,6 +68,26 @@ RSpec.describe Api::V2::SearchController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when search raises syntax error' do
|
||||
before { allow(Search).to receive(:new).and_raise(Mastodon::SyntaxError) }
|
||||
|
||||
it 'returns http unprocessable_entity' do
|
||||
get :index, params: params
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when search raises not found error' do
|
||||
before { allow(Search).to receive(:new).and_raise(ActiveRecord::RecordNotFound) }
|
||||
|
||||
it 'returns http not_found' do
|
||||
get :index, params: params
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -59,6 +99,12 @@ RSpec.describe Api::V2::SearchController do
|
|||
get :index, params: search_params
|
||||
end
|
||||
|
||||
context 'without a `q` param' do
|
||||
it 'returns http bad_request' do
|
||||
expect(response).to have_http_status(400)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a `q` shorter than 5 characters' do
|
||||
let(:search_params) { { q: 'test' } }
|
||||
|
||||
|
@ -79,6 +125,7 @@ RSpec.describe Api::V2::SearchController do
|
|||
|
||||
it 'returns http unauthorized' do
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.body).to match('resolve remote resources')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -87,6 +134,7 @@ RSpec.describe Api::V2::SearchController do
|
|||
|
||||
it 'returns http unauthorized' do
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.body).to match('pagination is not supported')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe RateLimitHeaders do
|
||||
describe Api::RateLimitHeaders do
|
||||
controller(ApplicationController) do
|
||||
include RateLimitHeaders
|
||||
include Api::RateLimitHeaders
|
||||
|
||||
def show
|
||||
head 200
|
|
@ -85,7 +85,7 @@ RSpec.describe ChallengableConcern do
|
|||
before { get :foo }
|
||||
|
||||
it 'renders challenge' do
|
||||
expect(response).to render_template('auth/challenges/new')
|
||||
expect(response).to render_template('auth/challenges/new', layout: :auth)
|
||||
end
|
||||
|
||||
# See Auth::ChallengesControllerSpec
|
||||
|
@ -95,7 +95,7 @@ RSpec.describe ChallengableConcern do
|
|||
before { post :bar }
|
||||
|
||||
it 'renders challenge' do
|
||||
expect(response).to render_template('auth/challenges/new')
|
||||
expect(response).to render_template('auth/challenges/new', layout: :auth)
|
||||
end
|
||||
|
||||
it 'accepts correct password' do
|
||||
|
@ -106,7 +106,7 @@ RSpec.describe ChallengableConcern do
|
|||
|
||||
it 'rejects wrong password' do
|
||||
post :bar, params: { form_challenge: { current_password: 'dddfff888123' } }
|
||||
expect(response.body).to render_template('auth/challenges/new')
|
||||
expect(response.body).to render_template('auth/challenges/new', layout: :auth)
|
||||
expect(session[:challenge_passed_at]).to be_nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ExportControllerConcern do
|
||||
describe Settings::ExportControllerConcern do
|
||||
controller(ApplicationController) do
|
||||
include ExportControllerConcern
|
||||
include Settings::ExportControllerConcern
|
||||
|
||||
def index
|
||||
send_export_file
|
|
@ -20,37 +20,30 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
|||
[true, false].each do |with_otp_secret|
|
||||
let(:user) { Fabricate(:user, email: 'local-part@domain', otp_secret: with_otp_secret ? 'oldotpsecret' : nil) }
|
||||
|
||||
describe 'GET #new' do
|
||||
context 'when signed in and a new otp secret has been set in the session' do
|
||||
subject do
|
||||
sign_in user, scope: :user
|
||||
get :new, session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
context 'when signed in' do
|
||||
before { sign_in user, scope: :user }
|
||||
|
||||
describe 'GET #new' do
|
||||
context 'when a new otp secret has been set in the session' do
|
||||
subject do
|
||||
get :new, session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
end
|
||||
|
||||
include_examples 'renders :new'
|
||||
end
|
||||
|
||||
include_examples 'renders :new'
|
||||
end
|
||||
it 'redirects if a new otp_secret has not been set in the session' do
|
||||
get :new, session: { challenge_passed_at: Time.now.utc }
|
||||
|
||||
it 'redirects if not signed in' do
|
||||
get :new
|
||||
expect(response).to redirect_to('/auth/sign_in')
|
||||
end
|
||||
|
||||
it 'redirects if a new otp_secret has not been set in the session' do
|
||||
sign_in user, scope: :user
|
||||
get :new, session: { challenge_passed_at: Time.now.utc }
|
||||
expect(response).to redirect_to('/settings/otp_authentication')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'when signed in' do
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
expect(response).to redirect_to('/settings/otp_authentication')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
describe 'when form_two_factor_confirmation parameter is not provided' do
|
||||
it 'raises ActionController::ParameterMissing' do
|
||||
post :create, params: {}, session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
|
||||
expect(response).to have_http_status(400)
|
||||
end
|
||||
end
|
||||
|
@ -58,69 +51,78 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
|||
describe 'when creation succeeds' do
|
||||
let!(:otp_backup_codes) { user.generate_otp_backup_codes! }
|
||||
|
||||
it 'renders page with success' do
|
||||
before do
|
||||
prepare_user_otp_generation
|
||||
prepare_user_otp_consumption
|
||||
prepare_user_otp_consumption_response(true)
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
end
|
||||
|
||||
expect do
|
||||
post :create,
|
||||
params: { form_two_factor_confirmation: { otp_attempt: '123456' } },
|
||||
session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
end.to change { user.reload.otp_secret }.to 'thisisasecretforthespecofnewview'
|
||||
it 'renders page with success' do
|
||||
expect { post_create_with_options }
|
||||
.to change { user.reload.otp_secret }.to 'thisisasecretforthespecofnewview'
|
||||
|
||||
expect(assigns(:recovery_codes)).to eq otp_backup_codes
|
||||
expect(flash[:notice]).to eq 'Two-factor authentication successfully enabled'
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response).to render_template('settings/two_factor_authentication/recovery_codes/index')
|
||||
end
|
||||
|
||||
def prepare_user_otp_generation
|
||||
allow(user)
|
||||
.to receive(:generate_otp_backup_codes!)
|
||||
.and_return(otp_backup_codes)
|
||||
end
|
||||
|
||||
def prepare_user_otp_consumption
|
||||
options = { otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
allow(user)
|
||||
.to receive(:validate_and_consume_otp!)
|
||||
.with('123456', options)
|
||||
.and_return(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when creation fails' do
|
||||
subject do
|
||||
options = { otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
allow(user)
|
||||
.to receive(:validate_and_consume_otp!)
|
||||
.with('123456', options)
|
||||
.and_return(false)
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
|
||||
expect do
|
||||
post :create,
|
||||
params: { form_two_factor_confirmation: { otp_attempt: '123456' } },
|
||||
session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
end.to(not_change { user.reload.otp_secret })
|
||||
expect { post_create_with_options }
|
||||
.to(not_change { user.reload.otp_secret })
|
||||
end
|
||||
|
||||
it 'renders the new view' do
|
||||
before do
|
||||
prepare_user_otp_consumption_response(false)
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
end
|
||||
|
||||
it 'renders page with error message' do
|
||||
subject
|
||||
expect(response.body).to include 'The entered code was invalid! Are server time and device time correct?'
|
||||
end
|
||||
|
||||
include_examples 'renders :new'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not signed in' do
|
||||
it 'redirects if not signed in' do
|
||||
post :create, params: { form_two_factor_confirmation: { otp_attempt: '123456' } }
|
||||
expect(response).to redirect_to('/auth/sign_in')
|
||||
private
|
||||
|
||||
def post_create_with_options
|
||||
post :create,
|
||||
params: { form_two_factor_confirmation: { otp_attempt: '123456' } },
|
||||
session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
end
|
||||
|
||||
def prepare_user_otp_generation
|
||||
allow(user)
|
||||
.to receive(:generate_otp_backup_codes!)
|
||||
.and_return(otp_backup_codes)
|
||||
end
|
||||
|
||||
def prepare_user_otp_consumption_response(result)
|
||||
options = { otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
allow(user)
|
||||
.to receive(:validate_and_consume_otp!)
|
||||
.with('123456', options)
|
||||
.and_return(result)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not signed in' do
|
||||
it 'redirects on POST to create' do
|
||||
post :create, params: { form_two_factor_confirmation: { otp_attempt: '123456' } }
|
||||
|
||||
expect(response).to redirect_to('/auth/sign_in')
|
||||
end
|
||||
|
||||
it 'redirects on GET to new' do
|
||||
get :new
|
||||
|
||||
expect(response).to redirect_to('/auth/sign_in')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator('Admin::ActionLog') do
|
||||
Fabricator(:action_log, from: Admin::ActionLog) do
|
||||
account { Fabricate.build(:account) }
|
||||
action 'MyString'
|
||||
target nil
|
|
@ -59,10 +59,10 @@ describe ContentSecurityPolicy do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#media_host' do
|
||||
describe '#media_hosts' do
|
||||
context 'when there is no configured CDN' do
|
||||
it 'defaults to using the assets_host value' do
|
||||
expect(subject.media_host).to eq(subject.assets_host)
|
||||
expect(subject.media_hosts).to contain_exactly(subject.assets_host)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -74,7 +74,7 @@ describe ContentSecurityPolicy do
|
|||
end
|
||||
|
||||
it 'uses the s3 alias host value' do
|
||||
expect(subject.media_host).to eq 'https://asset-host.s3-alias.example'
|
||||
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.s3-alias.example')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -86,7 +86,7 @@ describe ContentSecurityPolicy do
|
|||
end
|
||||
|
||||
it 'uses the s3 alias host value and preserves the path' do
|
||||
expect(subject.media_host).to eq 'https://asset-host.s3-alias.example/pathname/'
|
||||
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.s3-alias.example/pathname/')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -98,7 +98,7 @@ describe ContentSecurityPolicy do
|
|||
end
|
||||
|
||||
it 'uses the s3 cloudfront host value' do
|
||||
expect(subject.media_host).to eq 'https://asset-host.s3-cloudfront.example'
|
||||
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.s3-cloudfront.example')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -110,7 +110,7 @@ describe ContentSecurityPolicy do
|
|||
end
|
||||
|
||||
it 'uses the azure alias host value' do
|
||||
expect(subject.media_host).to eq 'https://asset-host.azure-alias.example'
|
||||
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.azure-alias.example')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -122,7 +122,7 @@ describe ContentSecurityPolicy do
|
|||
end
|
||||
|
||||
it 'uses the s3 hostname host value' do
|
||||
expect(subject.media_host).to eq 'https://asset-host.s3.example'
|
||||
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.s3.example')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,8 @@ require 'mastodon/cli/accounts'
|
|||
describe Mastodon::CLI::Accounts do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
# `parallelize_with_progress` cannot run in transactions, so instead,
|
||||
# stub it with an alternative implementation that runs sequentially
|
||||
# and can run in transactions.
|
||||
|
@ -24,12 +26,6 @@ describe Mastodon::CLI::Accounts do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe '#create' do
|
||||
shared_examples 'a new user with given email address and username' do
|
||||
it 'creates a new user with the specified email address' do
|
||||
|
|
|
@ -6,11 +6,7 @@ require 'mastodon/cli/cache'
|
|||
describe Mastodon::CLI::Cache do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#clear' do
|
||||
before { allow(Rails.cache).to receive(:clear) }
|
||||
|
|
|
@ -6,11 +6,7 @@ require 'mastodon/cli/canonical_email_blocks'
|
|||
describe Mastodon::CLI::CanonicalEmailBlocks do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#find' do
|
||||
let(:arguments) { ['user@example.com'] }
|
||||
|
|
|
@ -4,9 +4,5 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/domains'
|
||||
|
||||
describe Mastodon::CLI::Domains do
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
end
|
||||
|
|
|
@ -4,9 +4,5 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/email_domain_blocks'
|
||||
|
||||
describe Mastodon::CLI::EmailDomainBlocks do
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
end
|
||||
|
|
|
@ -4,9 +4,5 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/emoji'
|
||||
|
||||
describe Mastodon::CLI::Emoji do
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
end
|
||||
|
|
|
@ -6,11 +6,7 @@ require 'mastodon/cli/feeds'
|
|||
describe Mastodon::CLI::Feeds do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#build' do
|
||||
before { Fabricate(:account) }
|
||||
|
|
|
@ -6,11 +6,7 @@ require 'mastodon/cli/ip_blocks'
|
|||
describe Mastodon::CLI::IpBlocks do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#add' do
|
||||
let(:ip_list) do
|
||||
|
|
|
@ -4,11 +4,7 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/main'
|
||||
|
||||
describe Mastodon::CLI::Main do
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe 'version' do
|
||||
it 'returns the Mastodon version' do
|
||||
|
|
|
@ -6,11 +6,7 @@ require 'mastodon/cli/maintenance'
|
|||
describe Mastodon::CLI::Maintenance do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#fix_duplicates' do
|
||||
context 'when the database version is too old' do
|
||||
|
|
|
@ -6,11 +6,7 @@ require 'mastodon/cli/media'
|
|||
describe Mastodon::CLI::Media do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#remove' do
|
||||
context 'with --prune-profiles and --remove-headers' do
|
||||
|
@ -78,4 +74,89 @@ describe Mastodon::CLI::Media do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#usage' do
|
||||
context 'without options' do
|
||||
let(:options) { {} }
|
||||
|
||||
it 'reports about storage size' do
|
||||
expect { cli.invoke(:usage, [], options) }.to output(
|
||||
a_string_including('0 Bytes')
|
||||
).to_stdout
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#refresh' do
|
||||
context 'without any options' do
|
||||
let(:options) { {} }
|
||||
|
||||
it 'warns about usage and exits' do
|
||||
expect { cli.invoke(:refresh, [], options) }.to output(
|
||||
a_string_including('Specify the source')
|
||||
).to_stdout.and raise_error(SystemExit)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with --status option' do
|
||||
before do
|
||||
media_attachment.update(file_file_name: nil)
|
||||
end
|
||||
|
||||
let(:media_attachment) { Fabricate(:media_attachment, status: status, remote_url: 'https://host.example/asset.jpg') }
|
||||
let(:options) { { status: status.id } }
|
||||
let(:status) { Fabricate(:status) }
|
||||
|
||||
it 'redownloads the attachment file' do
|
||||
expect { cli.invoke(:refresh, [], options) }.to output(
|
||||
a_string_including('Downloaded 1 media')
|
||||
).to_stdout
|
||||
end
|
||||
end
|
||||
|
||||
context 'with --account option' do
|
||||
context 'when the account does not exist' do
|
||||
let(:options) { { account: 'not-real-user@example.host' } }
|
||||
|
||||
it 'warns about usage and exits' do
|
||||
expect { cli.invoke(:refresh, [], options) }.to output(
|
||||
a_string_including('No such account')
|
||||
).to_stdout.and raise_error(SystemExit)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the account exists' do
|
||||
before do
|
||||
media_attachment.update(file_file_name: nil)
|
||||
end
|
||||
|
||||
let(:media_attachment) { Fabricate(:media_attachment, account: account) }
|
||||
let(:options) { { account: account.acct } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
it 'redownloads the attachment file' do
|
||||
expect { cli.invoke(:refresh, [], options) }.to output(
|
||||
a_string_including('Downloaded 1 media')
|
||||
).to_stdout
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with --domain option' do
|
||||
before do
|
||||
media_attachment.update(file_file_name: nil)
|
||||
end
|
||||
|
||||
let(:domain) { 'example.host' }
|
||||
let(:media_attachment) { Fabricate(:media_attachment, account: account) }
|
||||
let(:options) { { domain: domain } }
|
||||
let(:account) { Fabricate(:account, domain: domain) }
|
||||
|
||||
it 'redownloads the attachment file' do
|
||||
expect { cli.invoke(:refresh, [], options) }.to output(
|
||||
a_string_including('Downloaded 1 media')
|
||||
).to_stdout
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,11 +6,7 @@ require 'mastodon/cli/preview_cards'
|
|||
describe Mastodon::CLI::PreviewCards do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#remove' do
|
||||
context 'with relevant preview cards' do
|
||||
|
|
|
@ -4,9 +4,5 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/search'
|
||||
|
||||
describe Mastodon::CLI::Search do
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
end
|
||||
|
|
|
@ -4,11 +4,7 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/settings'
|
||||
|
||||
describe Mastodon::CLI::Settings do
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe 'subcommand "registrations"' do
|
||||
let(:cli) { Mastodon::CLI::Registrations.new }
|
||||
|
|
|
@ -6,11 +6,7 @@ require 'mastodon/cli/statuses'
|
|||
describe Mastodon::CLI::Statuses do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#remove', use_transactional_tests: false do
|
||||
context 'with small batch size' do
|
||||
|
|
|
@ -4,9 +4,5 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/upgrade'
|
||||
|
||||
describe Mastodon::CLI::Upgrade do
|
||||
describe '.exit_on_failure?' do
|
||||
it 'returns true' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
end
|
||||
it_behaves_like 'CLI Command'
|
||||
end
|
||||
|
|
|
@ -652,7 +652,7 @@ RSpec.describe Account do
|
|||
end
|
||||
|
||||
it 'limits via constant by default' do
|
||||
stub_const('AccountSearch::DEFAULT_LIMIT', 1)
|
||||
stub_const('Account::Search::DEFAULT_LIMIT', 1)
|
||||
2.times.each { Fabricate(:account, display_name: 'Display Name') }
|
||||
results = described_class.search_for('display')
|
||||
expect(results.size).to eq 1
|
||||
|
@ -823,7 +823,7 @@ RSpec.describe Account do
|
|||
end
|
||||
|
||||
it 'limits by 10 by default' do
|
||||
stub_const('AccountSearch::DEFAULT_LIMIT', 1)
|
||||
stub_const('Account::Search::DEFAULT_LIMIT', 1)
|
||||
2.times { Fabricate(:account, display_name: 'Display Name') }
|
||||
results = described_class.advanced_search_for('display', account)
|
||||
expect(results.size).to eq 1
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountCounters do
|
||||
describe Account::Counters do
|
||||
let!(:account) { Fabricate(:account) }
|
||||
|
||||
describe '#increment_count!' do
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountFinderConcern do
|
||||
describe Account::FinderConcern do
|
||||
describe 'local finders' do
|
||||
let!(:account) { Fabricate(:account, username: 'Alice') }
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountInteractions do
|
||||
describe Account::Interactions do
|
||||
let(:account) { Fabricate(:account, username: 'account') }
|
||||
let(:account_id) { account.id }
|
||||
let(:account_ids) { [account_id] }
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountStatusesSearch do
|
||||
describe Account::StatusesSearch do
|
||||
let(:account) { Fabricate(:account, indexable: indexable) }
|
||||
|
||||
before do
|
|
@ -31,7 +31,7 @@ RSpec.describe Remotable do
|
|||
end
|
||||
end
|
||||
|
||||
let(:attribute_name) { "#{hoge}_remote_url".to_sym }
|
||||
let(:attribute_name) { :"#{hoge}_remote_url" }
|
||||
let(:code) { 200 }
|
||||
let(:file) { 'filename="foo.txt"' }
|
||||
let(:foo) { foo_class.new }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe StatusThreadingConcern do
|
||||
describe Status::ThreadingConcern do
|
||||
describe '#ancestors' do
|
||||
let!(:alice) { Fabricate(:account, username: 'alice') }
|
||||
let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
|
@ -110,9 +110,9 @@ describe Report do
|
|||
let(:status) { Fabricate(:status) }
|
||||
|
||||
before do
|
||||
Fabricate('Admin::ActionLog', target_type: 'Report', account_id: target_account.id, target_id: report.id, created_at: 2.days.ago)
|
||||
Fabricate('Admin::ActionLog', target_type: 'Account', account_id: target_account.id, target_id: report.target_account_id, created_at: 2.days.ago)
|
||||
Fabricate('Admin::ActionLog', target_type: 'Status', account_id: target_account.id, target_id: status.id, created_at: 2.days.ago)
|
||||
Fabricate(:action_log, target_type: 'Report', account_id: target_account.id, target_id: report.id, created_at: 2.days.ago)
|
||||
Fabricate(:action_log, target_type: 'Account', account_id: target_account.id, target_id: report.target_account_id, created_at: 2.days.ago)
|
||||
Fabricate(:action_log, target_type: 'Status', account_id: target_account.id, target_id: status.id, created_at: 2.days.ago)
|
||||
end
|
||||
|
||||
it 'returns right logs' do
|
||||
|
|
|
@ -2,23 +2,22 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountsController do
|
||||
render_views
|
||||
|
||||
describe 'Accounts show response' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe 'unapproved account check' do
|
||||
context 'with an unapproved account' do
|
||||
before { account.user.update(approved: false) }
|
||||
|
||||
it 'returns http not found' do
|
||||
%w(html json rss).each do |format|
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_path(username: account.username), as: format
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'permanently suspended account check' do
|
||||
context 'with a permanently suspended account' do
|
||||
before do
|
||||
account.suspend!
|
||||
account.deletion_request.destroy
|
||||
|
@ -26,25 +25,26 @@ RSpec.describe AccountsController do
|
|||
|
||||
it 'returns http gone' do
|
||||
%w(html json rss).each do |format|
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_path(username: account.username), as: format
|
||||
|
||||
expect(response).to have_http_status(410)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'temporarily suspended account check' do
|
||||
context 'with a temporarily suspended account' do
|
||||
before { account.suspend! }
|
||||
|
||||
it 'returns appropriate http response code' do
|
||||
{ html: 403, json: 200, rss: 403 }.each do |format, code|
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_path(username: account.username), as: format
|
||||
|
||||
expect(response).to have_http_status(code)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
describe 'GET to short username paths' do
|
||||
context 'with existing statuses' do
|
||||
let!(:status) { Fabricate(:status, account: account) }
|
||||
let!(:status_reply) { Fabricate(:status, account: account, thread: Fabricate(:status)) }
|
||||
|
@ -66,17 +66,17 @@ RSpec.describe AccountsController do
|
|||
|
||||
shared_examples 'common HTML response' do
|
||||
it 'returns a standard HTML response', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and render_template(:show)
|
||||
|
||||
expect(response.headers['Link'].to_s).to include ActivityPub::TagManager.instance.uri_for(account)
|
||||
|
||||
expect(response).to render_template(:show)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a normal account in an HTML request' do
|
||||
before do
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_path(username: account.username), as: format
|
||||
end
|
||||
|
||||
it_behaves_like 'common HTML response'
|
||||
|
@ -84,8 +84,7 @@ RSpec.describe AccountsController do
|
|||
|
||||
context 'with replies' do
|
||||
before do
|
||||
allow(controller).to receive(:replies_requested?).and_return(true)
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_with_replies_path(username: account.username), as: format
|
||||
end
|
||||
|
||||
it_behaves_like 'common HTML response'
|
||||
|
@ -93,8 +92,7 @@ RSpec.describe AccountsController do
|
|||
|
||||
context 'with media' do
|
||||
before do
|
||||
allow(controller).to receive(:media_requested?).and_return(true)
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_media_path(username: account.username), as: format
|
||||
end
|
||||
|
||||
it_behaves_like 'common HTML response'
|
||||
|
@ -106,9 +104,8 @@ RSpec.describe AccountsController do
|
|||
let!(:status_tag) { Fabricate(:status, account: account) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:tag_requested?).and_return(true)
|
||||
status_tag.tags << tag
|
||||
get :show, params: { username: account.username, format: format, tag: tag.to_param }
|
||||
get short_account_tag_path(username: account.username, tag: tag), as: format
|
||||
end
|
||||
|
||||
it_behaves_like 'common HTML response'
|
||||
|
@ -117,21 +114,25 @@ RSpec.describe AccountsController do
|
|||
|
||||
context 'with JSON' do
|
||||
let(:authorized_fetch_mode) { false }
|
||||
let(:format) { 'json' }
|
||||
let(:headers) { { 'ACCEPT' => 'application/json' } }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:authorized_fetch_mode?).and_return(authorized_fetch_mode)
|
||||
around do |example|
|
||||
ClimateControl.modify AUTHORIZED_FETCH: authorized_fetch_mode.to_s do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a normal account in a JSON request' do
|
||||
before do
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_path(username: account.username), headers: headers
|
||||
end
|
||||
|
||||
it 'returns a JSON version of the account', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
expect(response.media_type).to eq 'application/activity+json'
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: eq('application/activity+json')
|
||||
)
|
||||
|
||||
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
||||
end
|
||||
|
@ -152,13 +153,15 @@ RSpec.describe AccountsController do
|
|||
|
||||
before do
|
||||
sign_in(user)
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_path(username: account.username), headers: headers.merge({ 'Cookie' => '123' })
|
||||
end
|
||||
|
||||
it 'returns a private JSON version of the account', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
expect(response.media_type).to eq 'application/activity+json'
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: eq('application/activity+json')
|
||||
)
|
||||
|
||||
expect(response.headers['Cache-Control']).to include 'private'
|
||||
|
||||
|
@ -170,14 +173,15 @@ RSpec.describe AccountsController do
|
|||
let(:remote_account) { Fabricate(:account, domain: 'example.com') }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:signed_request_actor).and_return(remote_account)
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_path(username: account.username), headers: headers, sign_with: remote_account
|
||||
end
|
||||
|
||||
it 'returns a JSON version of the account', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
expect(response.media_type).to eq 'application/activity+json'
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: eq('application/activity+json')
|
||||
)
|
||||
|
||||
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
||||
end
|
||||
|
@ -188,12 +192,13 @@ RSpec.describe AccountsController do
|
|||
let(:authorized_fetch_mode) { true }
|
||||
|
||||
it 'returns a private signature JSON version of the account', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
expect(response.media_type).to eq 'application/activity+json'
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: eq('application/activity+json')
|
||||
)
|
||||
|
||||
expect(response.headers['Cache-Control']).to include 'private'
|
||||
|
||||
expect(response.headers['Vary']).to include 'Signature'
|
||||
|
||||
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
||||
|
@ -207,60 +212,58 @@ RSpec.describe AccountsController do
|
|||
|
||||
context 'with a normal account in an RSS request' do
|
||||
before do
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_path(username: account.username, format: format)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
it 'responds with correct statuses', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body).to include_status_tag(status_media)
|
||||
expect(response.body).to include_status_tag(status_self_reply)
|
||||
expect(response.body).to include_status_tag(status)
|
||||
expect(response.body).to_not include_status_tag(status_direct)
|
||||
expect(response.body).to_not include_status_tag(status_private)
|
||||
expect(response.body).to_not include_status_tag(status_reblog.reblog)
|
||||
expect(response.body).to_not include_status_tag(status_reply)
|
||||
expect(response.body).to include(status_tag_for(status_media))
|
||||
expect(response.body).to include(status_tag_for(status_self_reply))
|
||||
expect(response.body).to include(status_tag_for(status))
|
||||
expect(response.body).to_not include(status_tag_for(status_direct))
|
||||
expect(response.body).to_not include(status_tag_for(status_private))
|
||||
expect(response.body).to_not include(status_tag_for(status_reblog.reblog))
|
||||
expect(response.body).to_not include(status_tag_for(status_reply))
|
||||
end
|
||||
end
|
||||
|
||||
context 'with replies' do
|
||||
before do
|
||||
allow(controller).to receive(:replies_requested?).and_return(true)
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_with_replies_path(username: account.username, format: format)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
it 'responds with correct statuses with replies', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body).to include_status_tag(status_media)
|
||||
expect(response.body).to include_status_tag(status_reply)
|
||||
expect(response.body).to include_status_tag(status_self_reply)
|
||||
expect(response.body).to include_status_tag(status)
|
||||
expect(response.body).to_not include_status_tag(status_direct)
|
||||
expect(response.body).to_not include_status_tag(status_private)
|
||||
expect(response.body).to_not include_status_tag(status_reblog.reblog)
|
||||
expect(response.body).to include(status_tag_for(status_media))
|
||||
expect(response.body).to include(status_tag_for(status_reply))
|
||||
expect(response.body).to include(status_tag_for(status_self_reply))
|
||||
expect(response.body).to include(status_tag_for(status))
|
||||
expect(response.body).to_not include(status_tag_for(status_direct))
|
||||
expect(response.body).to_not include(status_tag_for(status_private))
|
||||
expect(response.body).to_not include(status_tag_for(status_reblog.reblog))
|
||||
end
|
||||
end
|
||||
|
||||
context 'with media' do
|
||||
before do
|
||||
allow(controller).to receive(:media_requested?).and_return(true)
|
||||
get :show, params: { username: account.username, format: format }
|
||||
get short_account_media_path(username: account.username, format: format)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
it 'responds with correct statuses with media', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body).to include_status_tag(status_media)
|
||||
expect(response.body).to_not include_status_tag(status_direct)
|
||||
expect(response.body).to_not include_status_tag(status_private)
|
||||
expect(response.body).to_not include_status_tag(status_reblog.reblog)
|
||||
expect(response.body).to_not include_status_tag(status_reply)
|
||||
expect(response.body).to_not include_status_tag(status_self_reply)
|
||||
expect(response.body).to_not include_status_tag(status)
|
||||
expect(response.body).to include(status_tag_for(status_media))
|
||||
expect(response.body).to_not include(status_tag_for(status_direct))
|
||||
expect(response.body).to_not include(status_tag_for(status_private))
|
||||
expect(response.body).to_not include(status_tag_for(status_reblog.reblog))
|
||||
expect(response.body).to_not include(status_tag_for(status_reply))
|
||||
expect(response.body).to_not include(status_tag_for(status_self_reply))
|
||||
expect(response.body).to_not include(status_tag_for(status))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -270,30 +273,29 @@ RSpec.describe AccountsController do
|
|||
let!(:status_tag) { Fabricate(:status, account: account) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:tag_requested?).and_return(true)
|
||||
status_tag.tags << tag
|
||||
get :show, params: { username: account.username, format: format, tag: tag.to_param }
|
||||
get short_account_tag_path(username: account.username, tag: tag, format: format)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
it 'responds with correct statuses with a tag', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body).to include_status_tag(status_tag)
|
||||
expect(response.body).to_not include_status_tag(status_direct)
|
||||
expect(response.body).to_not include_status_tag(status_media)
|
||||
expect(response.body).to_not include_status_tag(status_private)
|
||||
expect(response.body).to_not include_status_tag(status_reblog.reblog)
|
||||
expect(response.body).to_not include_status_tag(status_reply)
|
||||
expect(response.body).to_not include_status_tag(status_self_reply)
|
||||
expect(response.body).to_not include_status_tag(status)
|
||||
expect(response.body).to include(status_tag_for(status_tag))
|
||||
expect(response.body).to_not include(status_tag_for(status_direct))
|
||||
expect(response.body).to_not include(status_tag_for(status_media))
|
||||
expect(response.body).to_not include(status_tag_for(status_private))
|
||||
expect(response.body).to_not include(status_tag_for(status_reblog.reblog))
|
||||
expect(response.body).to_not include(status_tag_for(status_reply))
|
||||
expect(response.body).to_not include(status_tag_for(status_self_reply))
|
||||
expect(response.body).to_not include(status_tag_for(status))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def include_status_tag(status)
|
||||
include ActivityPub::TagManager.instance.url_for(status)
|
||||
def status_tag_for(status)
|
||||
ActivityPub::TagManager.instance.url_for(status)
|
||||
end
|
||||
end
|
|
@ -12,15 +12,15 @@ describe 'Content-Security-Policy' do
|
|||
"default-src 'none'",
|
||||
"frame-ancestors 'none'",
|
||||
"font-src 'self' https://cb6e6126.ngrok.io",
|
||||
"img-src 'self' https: data: blob: https://cb6e6126.ngrok.io",
|
||||
"img-src 'self' data: blob: https://cb6e6126.ngrok.io",
|
||||
"style-src 'self' https://cb6e6126.ngrok.io 'nonce-ZbA+JmE7+bK8F5qvADZHuQ=='",
|
||||
"media-src 'self' https: data: https://cb6e6126.ngrok.io",
|
||||
"media-src 'self' data: https://cb6e6126.ngrok.io",
|
||||
"frame-src 'self' https:",
|
||||
"manifest-src 'self' https://cb6e6126.ngrok.io",
|
||||
"form-action 'self'",
|
||||
"child-src 'self' blob: https://cb6e6126.ngrok.io",
|
||||
"worker-src 'self' blob: https://cb6e6126.ngrok.io",
|
||||
"connect-src 'self' data: blob: https://cb6e6126.ngrok.io https://cb6e6126.ngrok.io ws://localhost:4000",
|
||||
"connect-src 'self' data: blob: https://cb6e6126.ngrok.io ws://localhost:4000",
|
||||
"script-src 'self' https://cb6e6126.ngrok.io 'wasm-unsafe-eval'"
|
||||
)
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountSearch do
|
||||
describe Account::Search do
|
||||
describe 'a non-discoverable account becoming discoverable' do
|
||||
let(:account) { Account.find_by(username: 'search_test_account_1') }
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountStatusesSearch do
|
||||
describe Account::StatusesSearch do
|
||||
describe 'a non-indexable account becoming indexable' do
|
||||
let(:account) { Account.find_by(username: 'search_test_account_1') }
|
||||
|
|
@ -10,6 +10,12 @@ describe REST::InstanceSerializer do
|
|||
it 'returns recent usage data' do
|
||||
expect(serialization['usage']).to eq({ 'users' => { 'active_month' => 0 } })
|
||||
end
|
||||
|
||||
it 'returns the VAPID public key' do
|
||||
expect(serialization['configuration']['vapid']).to eq({
|
||||
'public_key' => Rails.configuration.x.vapid_public_key,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
describe 'fedibird_capabilities' do
|
||||
|
|
|
@ -389,7 +389,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
|
||||
it 'updates the existing media attachment in-place' do
|
||||
media_attachment = status.media_attachments.reload.first
|
||||
media_attachment = status.media_attachments.ordered.reload.first
|
||||
|
||||
expect(media_attachment).to_not be_nil
|
||||
expect(media_attachment.remote_url).to eq 'https://example.com/foo.png'
|
||||
|
|
11
spec/support/examples/cli.rb
Normal file
11
spec/support/examples/cli.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
shared_examples 'CLI Command' do
|
||||
it 'configures Thor to exit on failure' do
|
||||
expect(described_class.exit_on_failure?).to be true
|
||||
end
|
||||
|
||||
it 'descends from the CLI base class' do
|
||||
expect(described_class.new).to be_a(Mastodon::CLI::Base)
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module SignedRequestHelpers
|
||||
def get(path, headers: nil, sign_with: nil, **args)
|
||||
return super path, headers: headers, **args if sign_with.nil?
|
||||
return super(path, headers: headers, **args) if sign_with.nil?
|
||||
|
||||
headers ||= {}
|
||||
headers['Date'] = Time.now.utc.httpdate
|
||||
|
@ -16,6 +16,6 @@ module SignedRequestHelpers
|
|||
|
||||
headers['Signature'] = "keyId=\"#{key_id}\",algorithm=\"rsa-sha256\",headers=\"#{signed_headers.keys.join(' ').downcase}\",signature=\"#{signature}\""
|
||||
|
||||
super path, headers: headers, **args
|
||||
super(path, headers: headers, **args)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue