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

This commit is contained in:
KMY 2023-11-09 12:33:50 +09:00
commit fc1b280d59
65 changed files with 18502 additions and 13905 deletions

View file

@ -26,7 +26,6 @@ describe Api::V1::StreamingController do
context 'with streaming api on different host' do
before do
Rails.configuration.x.streaming_api_base_url = "wss://streaming-#{Rails.configuration.x.web_domain}"
@streaming_host = URI.parse(Rails.configuration.x.streaming_api_base_url).host
end
describe 'GET #index' do
@ -38,7 +37,13 @@ describe Api::V1::StreamingController do
[:scheme, :path, :query, :fragment].each do |part|
expect(redirect_to_uri.send(part)).to eq(request_uri.send(part)), "redirect target #{part}"
end
expect(redirect_to_uri.host).to eq(@streaming_host), 'redirect target host'
expect(redirect_to_uri.host).to eq(streaming_host), 'redirect target host'
end
private
def streaming_host
URI.parse(Rails.configuration.x.streaming_api_base_url).host
end
end
end

View file

@ -7,7 +7,7 @@ describe Auth::ConfirmationsController do
describe 'GET #new' do
it 'returns http success' do
@request.env['devise.mapping'] = Devise.mappings[:user]
request.env['devise.mapping'] = Devise.mappings[:user]
get :new
expect(response).to have_http_status(200)
end
@ -19,7 +19,7 @@ describe Auth::ConfirmationsController do
before do
allow(BootstrapTimelineWorker).to receive(:perform_async)
@request.env['devise.mapping'] = Devise.mappings[:user]
request.env['devise.mapping'] = Devise.mappings[:user]
get :show, params: { confirmation_token: 'foobar' }
end
@ -37,7 +37,7 @@ describe Auth::ConfirmationsController do
before do
allow(BootstrapTimelineWorker).to receive(:perform_async)
@request.env['devise.mapping'] = Devise.mappings[:user]
request.env['devise.mapping'] = Devise.mappings[:user]
get :show, params: { confirmation_token: 'foobar' }
end
@ -51,7 +51,7 @@ describe Auth::ConfirmationsController do
before do
allow(BootstrapTimelineWorker).to receive(:perform_async)
@request.env['devise.mapping'] = Devise.mappings[:user]
request.env['devise.mapping'] = Devise.mappings[:user]
sign_in(user, scope: :user)
get :show, params: { confirmation_token: 'foobar' }
end
@ -66,7 +66,7 @@ describe Auth::ConfirmationsController do
before do
allow(BootstrapTimelineWorker).to receive(:perform_async)
@request.env['devise.mapping'] = Devise.mappings[:user]
request.env['devise.mapping'] = Devise.mappings[:user]
user.approved = false
user.save!
sign_in(user, scope: :user)
@ -83,7 +83,7 @@ describe Auth::ConfirmationsController do
before do
allow(BootstrapTimelineWorker).to receive(:perform_async)
@request.env['devise.mapping'] = Devise.mappings[:user]
request.env['devise.mapping'] = Devise.mappings[:user]
get :show, params: { confirmation_token: 'foobar' }
end

View file

@ -7,7 +7,7 @@ describe Auth::PasswordsController do
describe 'GET #new' do
it 'returns http success' do
@request.env['devise.mapping'] = Devise.mappings[:user]
request.env['devise.mapping'] = Devise.mappings[:user]
get :new
expect(response).to have_http_status(200)
end
@ -18,12 +18,14 @@ describe Auth::PasswordsController do
before do
request.env['devise.mapping'] = Devise.mappings[:user]
@token = user.send_reset_password_instructions
end
context 'with valid reset_password_token' do
it 'returns http success' do
get :edit, params: { reset_password_token: @token }
token = user.send_reset_password_instructions
get :edit, params: { reset_password_token: token }
expect(response).to have_http_status(200)
end
end
@ -38,9 +40,9 @@ describe Auth::PasswordsController do
describe 'POST #update' do
let(:user) { Fabricate(:user) }
let(:password) { 'reset0password' }
before do
@password = 'reset0password'
request.env['devise.mapping'] = Devise.mappings[:user]
end
@ -50,9 +52,9 @@ describe Auth::PasswordsController do
let!(:web_push_subscription) { Fabricate(:web_push_subscription, access_token: access_token) }
before do
@token = user.send_reset_password_instructions
token = user.send_reset_password_instructions
post :update, params: { user: { password: @password, password_confirmation: @password, reset_password_token: @token } }
post :update, params: { user: { password: password, password_confirmation: password, reset_password_token: token } }
end
it 'redirect to sign in' do
@ -63,7 +65,7 @@ describe Auth::PasswordsController do
this_user = User.find(user.id)
expect(this_user).to_not be_nil
expect(this_user.valid_password?(@password)).to be true
expect(this_user.valid_password?(password)).to be true
end
it 'deactivates all sessions' do
@ -81,7 +83,7 @@ describe Auth::PasswordsController do
context 'with invalid reset_password_token' do
before do
post :update, params: { user: { password: @password, password_confirmation: @password, reset_password_token: 'some_invalid_value' } }
post :update, params: { user: { password: password, password_confirmation: password, reset_password_token: 'some_invalid_value' } }
end
it 'renders reset password' do

View file

@ -378,7 +378,7 @@ RSpec.describe Auth::SessionsController do
context 'when using a valid webauthn credential' do
before do
@controller.session[:webauthn_challenge] = challenge
controller.session[:webauthn_challenge] = challenge
post :create, params: { user: { credential: fake_credential } }, session: { attempt_user_id: user.id, attempt_user_updated_at: user.updated_at.to_s }
end

View file

@ -11,7 +11,7 @@ describe ExportControllerConcern do
end
def export_data
@export.account.username
'body data value'
end
end
@ -24,7 +24,7 @@ describe ExportControllerConcern do
expect(response).to have_http_status(200)
expect(response.media_type).to eq 'text/csv'
expect(response.headers['Content-Disposition']).to start_with 'attachment; filename="anonymous.csv"'
expect(response.body).to eq user.account.username
expect(response.body).to eq 'body data value'
end
it 'returns unauthorized when not signed in' do

View file

@ -10,7 +10,7 @@ RSpec.describe HomeController do
context 'when not signed in' do
it 'returns http success' do
@request.path = '/'
request.path = '/'
expect(subject).to have_http_status(:success)
end
end

View file

@ -194,7 +194,7 @@ RSpec.describe Settings::ImportsController do
let!(:rows) do
[
{ 'acct' => 'foo@bar' },
{ 'acct' => 'user@bar', 'show_reblogs' => false, 'notify' => true, 'languages' => ['fr', 'de'] },
{ 'acct' => 'user@bar', 'show_reblogs' => false, 'notify' => true, 'languages' => %w(fr de) },
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
end

View file

@ -130,7 +130,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
it 'stores the challenge on the session' do
get :options
expect(@controller.session[:webauthn_challenge]).to be_present
expect(controller.session[:webauthn_challenge]).to be_present
end
it 'does not change webauthn_id' do
@ -155,7 +155,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
it 'stores the challenge on the session' do
get :options
expect(@controller.session[:webauthn_challenge]).to be_present
expect(controller.session[:webauthn_challenge]).to be_present
end
it 'sets user webauthn_id' do
@ -218,7 +218,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
context 'when creation succeeds' do
it 'returns http success' do
@controller.session[:webauthn_challenge] = challenge
controller.session[:webauthn_challenge] = challenge
post :create, params: { credential: new_webauthn_credential, nickname: nickname }
@ -226,7 +226,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
end
it 'adds a new credential to user credentials' do
@controller.session[:webauthn_challenge] = challenge
controller.session[:webauthn_challenge] = challenge
expect do
post :create, params: { credential: new_webauthn_credential, nickname: nickname }
@ -234,7 +234,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
end
it 'does not change webauthn_id' do
@controller.session[:webauthn_challenge] = challenge
controller.session[:webauthn_challenge] = challenge
expect do
post :create, params: { credential: new_webauthn_credential, nickname: nickname }
@ -244,7 +244,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
context 'when the nickname is already used' do
it 'fails' do
@controller.session[:webauthn_challenge] = challenge
controller.session[:webauthn_challenge] = challenge
post :create, params: { credential: new_webauthn_credential, nickname: 'USB Key' }
@ -264,7 +264,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
end
it 'fails' do
@controller.session[:webauthn_challenge] = challenge
controller.session[:webauthn_challenge] = challenge
post :create, params: { credential: new_webauthn_credential, nickname: nickname }
@ -277,7 +277,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
context 'when user have not enabled webauthn' do
context 'when creation succeeds' do
it 'creates a webauthn credential' do
@controller.session[:webauthn_challenge] = challenge
controller.session[:webauthn_challenge] = challenge
expect do
post :create, params: { credential: new_webauthn_credential, nickname: nickname }

View file

@ -5,9 +5,10 @@ require 'rails_helper'
RSpec.describe StatusesCleanupController do
render_views
let!(:user) { Fabricate(:user) }
before do
@user = Fabricate(:user)
sign_in @user, scope: :user
sign_in user, scope: :user
end
describe 'GET #show' do
@ -30,9 +31,9 @@ RSpec.describe StatusesCleanupController do
end
it 'updates the account status cleanup policy' do
expect(@user.account.statuses_cleanup_policy.enabled).to be true
expect(@user.account.statuses_cleanup_policy.keep_direct).to be false
expect(@user.account.statuses_cleanup_policy.keep_polls).to be true
expect(user.account.statuses_cleanup_policy.enabled).to be true
expect(user.account.statuses_cleanup_policy.keep_direct).to be false
expect(user.account.statuses_cleanup_policy.keep_polls).to be true
end
it 'redirects' do