Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master

This commit is contained in:
Jenkins 2018-05-17 11:17:21 +00:00
commit 2636a23092
3 changed files with 44 additions and 3 deletions

View file

@ -107,9 +107,7 @@ module SignatureVerification
def incompatible_signature?(signature_params) def incompatible_signature?(signature_params)
signature_params['keyId'].blank? || signature_params['keyId'].blank? ||
signature_params['signature'].blank? || signature_params['signature'].blank?
signature_params['algorithm'].blank? ||
signature_params['algorithm'] != 'rsa-sha256'
end end
def account_from_key_id(key_id) def account_from_key_id(key_id)

View file

@ -17,6 +17,7 @@ class Settings::ProfilesController < Settings::BaseController
ActivityPub::UpdateDistributionWorker.perform_async(@account.id) ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg') redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
else else
@account.build_fields
render :show render :show
end end
end end

View file

@ -1,4 +1,46 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Admin::AccountModerationNotesController, type: :controller do RSpec.describe Admin::AccountModerationNotesController, type: :controller do
render_views
let(:user) { Fabricate(:user, admin: true) }
let(:target_account) { Fabricate(:account) }
before do
sign_in user, scope: :user
end
describe 'POST #create' do
subject { post :create, params: params }
context 'when parameters are valid' do
let(:params) { { account_moderation_note: { target_account_id: target_account.id, content: 'test content' } } }
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)
end
end
context 'when parameters are invalid' do
let(:params) { { account_moderation_note: { target_account_id: target_account.id, content: '' } } }
it 'falls to create a note' do
expect { subject }.not_to change { AccountModerationNote.count }
expect(subject).to render_template 'admin/accounts/show'
end
end
end
describe 'DELETE #destroy' do
subject { delete :destroy, params: { id: note.id } }
let!(:note) { Fabricate(:account_moderation_note, account: account, target_account: target_account) }
let(:account) { Fabricate(:account) }
it 'destroys note' do
expect { subject }.to change { AccountModerationNote.count }.by(-1)
expect(subject).to redirect_to admin_account_path(target_account.id)
end
end
end end