From a2db8d94398659b132bbb3c295fcaf54f87d7339 Mon Sep 17 00:00:00 2001 From: Andrei Prigorshnev Date: Fri, 12 Apr 2024 15:08:07 +0400 Subject: [PATCH] DEV: Drop FoundUserWithStatusSerializer (#25884) See dedf1a5e --- .../found_user_with_status_serializer.rb | 21 --------- .../found_user_with_status_serializer_spec.rb | 46 ------------------- 2 files changed, 67 deletions(-) delete mode 100644 app/serializers/found_user_with_status_serializer.rb delete mode 100644 spec/serializers/found_user_with_status_serializer_spec.rb diff --git a/app/serializers/found_user_with_status_serializer.rb b/app/serializers/found_user_with_status_serializer.rb deleted file mode 100644 index 31c8ccad085..00000000000 --- a/app/serializers/found_user_with_status_serializer.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class FoundUserWithStatusSerializer < FoundUserSerializer - include UserStatusMixin - - def initialize(object, options = {}) - super - options[:include_status] = true - deprecated - end - - private - - def deprecated - message = - "FoundUserWithStatusSerializer is deprecated. " \ - "Use FoundUserSerializer with the include_status option instead." - - Discourse.deprecate(message, since: "3.3.0.beta1", drop_from: "3.3.0.beta2") - end -end diff --git a/spec/serializers/found_user_with_status_serializer_spec.rb b/spec/serializers/found_user_with_status_serializer_spec.rb deleted file mode 100644 index 4bb69352544..00000000000 --- a/spec/serializers/found_user_with_status_serializer_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe FoundUserWithStatusSerializer do - fab!(:user_status) - fab!(:user) { Fabricate(:user, user_status: user_status) } - let(:serializer) { described_class.new(user, root: false) } - - describe "#status" do - it "adds user status when enabled" do - SiteSetting.enable_user_status = true - - json = serializer.as_json - - expect(json[:status]).to_not be_nil do |status| - expect(status.description).to eq(user_status.description) - expect(status.emoji).to eq(user_status.emoji) - end - end - - it "doesn't add user status when disabled" do - SiteSetting.enable_user_status = false - json = serializer.as_json - expect(json.keys).not_to include :status - end - - it "doesn't add expired user status" do - SiteSetting.enable_user_status = true - - user.user_status.ends_at = 1.minutes.ago - serializer = described_class.new(user, scope: Guardian.new(user), root: false) - json = serializer.as_json - - expect(json.keys).not_to include :status - end - - it "doesn't return status if user doesn't have it" do - SiteSetting.enable_user_status = true - - user.clear_status! - user.reload - json = serializer.as_json - - expect(json.keys).not_to include :status - end - end -end