From 8ef546fe6b2453864c0f14c358ae8fff41c3aaa1 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 18 Mar 2025 04:16:42 -0400 Subject: [PATCH 1/7] Convert `oauth/tokens#revoke` spec controller->request (#34174) --- .../oauth/tokens_controller_spec.rb | 23 ------------------- spec/requests/oauth/token_spec.rb | 21 ++++++++++++++++- 2 files changed, 20 insertions(+), 24 deletions(-) delete mode 100644 spec/controllers/oauth/tokens_controller_spec.rb diff --git a/spec/controllers/oauth/tokens_controller_spec.rb b/spec/controllers/oauth/tokens_controller_spec.rb deleted file mode 100644 index a2eed797e0..0000000000 --- a/spec/controllers/oauth/tokens_controller_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe Oauth::TokensController do - describe 'POST #revoke' do - let!(:user) { Fabricate(:user) } - let!(:application) { Fabricate(:application, confidential: false) } - let!(:access_token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: application) } - let!(:web_push_subscription) { Fabricate(:web_push_subscription, user: user, access_token: access_token) } - - it 'revokes the token and removes subscriptions' do - post :revoke, params: { client_id: application.uid, token: access_token.token } - - expect(access_token.reload.revoked_at) - .to_not be_nil - expect(Web::PushSubscription.where(access_token: access_token).count) - .to eq(0) - expect { web_push_subscription.reload } - .to raise_error(ActiveRecord::RecordNotFound) - end - end -end diff --git a/spec/requests/oauth/token_spec.rb b/spec/requests/oauth/token_spec.rb index 18d232e5ab..74f301c577 100644 --- a/spec/requests/oauth/token_spec.rb +++ b/spec/requests/oauth/token_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Obtaining OAuth Tokens' do +RSpec.describe 'Managing OAuth Tokens' do describe 'POST /oauth/token' do subject do post '/oauth/token', params: params @@ -104,4 +104,23 @@ RSpec.describe 'Obtaining OAuth Tokens' do end end end + + describe 'POST /oauth/revoke' do + subject { post '/oauth/revoke', params: { client_id: application.uid, token: access_token.token } } + + let!(:user) { Fabricate(:user) } + let!(:application) { Fabricate(:application, confidential: false) } + let!(:access_token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: application) } + let!(:web_push_subscription) { Fabricate(:web_push_subscription, user: user, access_token: access_token) } + + it 'revokes the token and removes subscriptions' do + expect { subject } + .to change { access_token.reload.revoked_at }.from(nil).to(be_present) + + expect(Web::PushSubscription.where(access_token: access_token).count) + .to eq(0) + expect { web_push_subscription.reload } + .to raise_error(ActiveRecord::RecordNotFound) + end + end end From 795d465f8da06153c899d0b5e48457830c5a30ba Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 18 Mar 2025 04:18:36 -0400 Subject: [PATCH 2/7] Convert `disputes/strikes` spec controller->request/system (#34191) --- .../disputes/strikes_controller_spec.rb | 32 ------------------- spec/requests/disputes/strikes_spec.rb | 22 +++++++++++++ spec/system/disputes/strikes_spec.rb | 27 ++++++++++++++++ 3 files changed, 49 insertions(+), 32 deletions(-) delete mode 100644 spec/controllers/disputes/strikes_controller_spec.rb create mode 100644 spec/requests/disputes/strikes_spec.rb create mode 100644 spec/system/disputes/strikes_spec.rb diff --git a/spec/controllers/disputes/strikes_controller_spec.rb b/spec/controllers/disputes/strikes_controller_spec.rb deleted file mode 100644 index f6d28fc09a..0000000000 --- a/spec/controllers/disputes/strikes_controller_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe Disputes::StrikesController do - render_views - - before { sign_in current_user, scope: :user } - - describe '#show' do - let(:current_user) { Fabricate(:user) } - let(:strike) { Fabricate(:account_warning, target_account: current_user.account) } - - before do - get :show, params: { id: strike.id } - end - - context 'when meant for the user' do - it 'returns http success' do - expect(response).to have_http_status(:success) - end - end - - context 'when meant for a different user' do - let(:strike) { Fabricate(:account_warning) } - - it 'returns http forbidden' do - expect(response).to have_http_status(403) - end - end - end -end diff --git a/spec/requests/disputes/strikes_spec.rb b/spec/requests/disputes/strikes_spec.rb new file mode 100644 index 0000000000..48685893c2 --- /dev/null +++ b/spec/requests/disputes/strikes_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Disputes Strikes' do + before { sign_in current_user } + + describe 'GET /disputes/strikes/:id' do + let(:current_user) { Fabricate(:user) } + + context 'when meant for a different user' do + let(:strike) { Fabricate(:account_warning) } + + it 'returns http forbidden' do + get disputes_strike_path(strike) + + expect(response) + .to have_http_status(403) + end + end + end +end diff --git a/spec/system/disputes/strikes_spec.rb b/spec/system/disputes/strikes_spec.rb new file mode 100644 index 0000000000..d2b6b08c46 --- /dev/null +++ b/spec/system/disputes/strikes_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Disputes Strikes' do + before { sign_in(current_user) } + + describe 'viewing strike disputes' do + let(:current_user) { Fabricate(:user) } + let!(:strike) { Fabricate(:account_warning, target_account: current_user.account) } + + it 'shows a list of strikes and details for each' do + visit disputes_strikes_path + expect(page) + .to have_title(I18n.t('settings.strikes')) + + find('.strike-entry').click + expect(page) + .to have_title(strike_page_title) + .and have_content(strike.text) + end + + def strike_page_title + I18n.t('disputes.strikes.title', action: I18n.t(strike.action, scope: 'disputes.strikes.title_actions'), date: I18n.l(strike.created_at.to_date)) + end + end +end From 6bce43cdb844b7a298344631ee27a2a35bf88712 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 11:32:20 +0100 Subject: [PATCH 3/7] chore(deps): update dependency mime-types to v3.6.1 (#34196) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2afcdd4655..05536976ea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -418,7 +418,7 @@ GEM redis (>= 3.0.5) matrix (0.4.2) memory_profiler (1.1.0) - mime-types (3.6.0) + mime-types (3.6.1) logger mime-types-data (~> 3.2015) mime-types-data (3.2025.0304) From 9d5cbbbf0f74ab504dd3b84273338e1fb383aaf4 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 18 Mar 2025 11:32:35 +0100 Subject: [PATCH 4/7] Fix account notes not being displayed (#34166) --- .../features/account/components/account_note.jsx | 13 ++++++------- .../account/containers/account_note_container.js | 8 ++++---- .../account_timeline/components/account_header.tsx | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/javascript/mastodon/features/account/components/account_note.jsx b/app/javascript/mastodon/features/account/components/account_note.jsx index e736e7ad64..84fd6beeff 100644 --- a/app/javascript/mastodon/features/account/components/account_note.jsx +++ b/app/javascript/mastodon/features/account/components/account_note.jsx @@ -4,7 +4,6 @@ import { PureComponent } from 'react'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { is } from 'immutable'; -import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import Textarea from 'react-textarea-autosize'; @@ -49,7 +48,7 @@ class InlineAlert extends PureComponent { class AccountNote extends ImmutablePureComponent { static propTypes = { - account: ImmutablePropTypes.record.isRequired, + accountId: PropTypes.string.isRequired, value: PropTypes.string, onSave: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, @@ -66,7 +65,7 @@ class AccountNote extends ImmutablePureComponent { } UNSAFE_componentWillReceiveProps (nextProps) { - const accountWillChange = !is(this.props.account, nextProps.account); + const accountWillChange = !is(this.props.accountId, nextProps.accountId); const newState = {}; if (accountWillChange && this._isDirty()) { @@ -141,21 +140,21 @@ class AccountNote extends ImmutablePureComponent { } render () { - const { account, intl } = this.props; + const { accountId, intl } = this.props; const { value, saved } = this.state; - if (!account) { + if (!accountId) { return null; } return (
-