From a7673d361d6af5613119470a90c95a15b51a575d Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 17 Dec 2024 03:54:07 -0500 Subject: [PATCH] Fix `application_id` erroneous inclusion in `ScheduledStatusSerializer` (#33159) --- app/serializers/rest/scheduled_status_serializer.rb | 2 +- .../rest/scheduled_status_serializer_spec.rb | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/serializers/rest/scheduled_status_serializer.rb b/app/serializers/rest/scheduled_status_serializer.rb index 5d6311b872..8aa0d89386 100644 --- a/app/serializers/rest/scheduled_status_serializer.rb +++ b/app/serializers/rest/scheduled_status_serializer.rb @@ -10,6 +10,6 @@ class REST::ScheduledStatusSerializer < ActiveModel::Serializer end def params - object.params.without(:application_id) + object.params.without('application_id') end end diff --git a/spec/serializers/rest/scheduled_status_serializer_spec.rb b/spec/serializers/rest/scheduled_status_serializer_spec.rb index 7d0d7c96bb..2fe689766f 100644 --- a/spec/serializers/rest/scheduled_status_serializer_spec.rb +++ b/spec/serializers/rest/scheduled_status_serializer_spec.rb @@ -11,11 +11,18 @@ RSpec.describe REST::ScheduledStatusSerializer do end let(:account) { Fabricate(:account) } - let(:scheduled_status) { Fabricate.build(:scheduled_status, scheduled_at: 4.minutes.from_now, account: account) } + let(:scheduled_status) { Fabricate.build(:scheduled_status, scheduled_at: 4.minutes.from_now, account: account, params: { application_id: 123 }) } - context 'with scheduled_at' do + describe 'serialization' do it 'is serialized as RFC 3339 datetime' do - expect { DateTime.rfc3339(subject['scheduled_at']) }.to_not raise_error + expect { DateTime.rfc3339(subject['scheduled_at']) } + .to_not raise_error + end + + it 'returns expected values and removes application_id from params' do + expect(subject.deep_symbolize_keys) + .to include(scheduled_at: be_a(String)) + .and include(params: not_include(:application_id)) end end end