From dfb6907e08350ca487e2978a85013f4525526bdf Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 17 May 2018 04:03:28 +0200 Subject: [PATCH 1/3] HTTP signatures spec no longer requires algorithms field (#7525) Fix #7520 --- app/controllers/concerns/signature_verification.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index f289228d3c..41aa1c8a64 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -107,9 +107,7 @@ module SignatureVerification def incompatible_signature?(signature_params) signature_params['keyId'].blank? || - signature_params['signature'].blank? || - signature_params['algorithm'].blank? || - signature_params['algorithm'] != 'rsa-sha256' + signature_params['signature'].blank? end def account_from_key_id(key_id) From b48a166c82480d5d27139cb07077a42b45149563 Mon Sep 17 00:00:00 2001 From: Shuhei Kitagawa Date: Thu, 17 May 2018 11:26:51 +0900 Subject: [PATCH 2/3] Add tests for account_moderation_notes_controller (#7524) --- ...ccount_moderation_notes_controller_spec.rb | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/spec/controllers/admin/account_moderation_notes_controller_spec.rb b/spec/controllers/admin/account_moderation_notes_controller_spec.rb index ca4e55c4d4..410ce6543d 100644 --- a/spec/controllers/admin/account_moderation_notes_controller_spec.rb +++ b/spec/controllers/admin/account_moderation_notes_controller_spec.rb @@ -1,4 +1,46 @@ require 'rails_helper' 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 From 7293b9fc6190acd6d2a481c158c718a7a8299c73 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 17 May 2018 13:00:56 +0200 Subject: [PATCH 3/3] Ensure unfilled fields are shown when errors are shown (#7523) Fix #7486 --- app/controllers/settings/profiles_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index 1b01fc75f0..fe265c81d2 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -20,6 +20,7 @@ class Settings::ProfilesController < ApplicationController ActivityPub::UpdateDistributionWorker.perform_async(@account.id) redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg') else + @account.build_fields render :show end end