From 220ca16ef02239a0b3294e8d51640619825f7718 Mon Sep 17 00:00:00 2001 From: Kabiru Mwenja Date: Mon, 2 Dec 2024 17:29:37 +0300 Subject: [PATCH] Revert "Add reminder note as an embedded notification detail" This reverts commit a13494ce642fc7994e82d0d8488cc6241ad1a8d8. --- config/locales/en.yml | 1 - .../notifications/notification_representer.rb | 2 +- .../property_factory/reminder.rb | 45 --------------- .../v3/values/property_generic_representer.rb | 33 ----------- .../v3/values/schemas/value_schema_factory.rb | 13 ++--- ...notification_representer_rendering_spec.rb | 55 ------------------- 6 files changed, 6 insertions(+), 143 deletions(-) delete mode 100644 lib/api/v3/notifications/property_factory/reminder.rb delete mode 100644 lib/api/v3/values/property_generic_representer.rb diff --git a/config/locales/en.yml b/config/locales/en.yml index 5ab4b6bae1b7..3d2a4e308d20 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1510,7 +1510,6 @@ en: login: "Username" mail: "Email" name: "Name" - note: "Note" password: "Password" priority: "Priority" project: "Project" diff --git a/lib/api/v3/notifications/notification_representer.rb b/lib/api/v3/notifications/notification_representer.rb index 6984fe235187..5b67c4dd9a3d 100644 --- a/lib/api/v3/notifications/notification_representer.rb +++ b/lib/api/v3/notifications/notification_representer.rb @@ -104,7 +104,7 @@ def _type "Notification" end - self.to_eager_load = %i[actor journal reminder] + self.to_eager_load = %i[actor journal] end end end diff --git a/lib/api/v3/notifications/property_factory/reminder.rb b/lib/api/v3/notifications/property_factory/reminder.rb deleted file mode 100644 index e8bd4e210c2f..000000000000 --- a/lib/api/v3/notifications/property_factory/reminder.rb +++ /dev/null @@ -1,45 +0,0 @@ -# --copyright -# OpenProject is an open source project management software. -# Copyright (C) the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See COPYRIGHT and LICENSE files for more details. -# ++ - -module API::V3::Notifications::PropertyFactory - module Reminder - extend ::API::V3::Utilities::PathHelper - - module_function - - def for(notification) - return [] unless notification.reminder - - [ - ::API::V3::Values::PropertyGenericRepresenter - .new(::API::V3::Values::PropertyModel.new(:note, notification.reminder.note), - self_link: api_v3_paths.notification_detail(notification.id, 0)) - ] - end - end -end diff --git a/lib/api/v3/values/property_generic_representer.rb b/lib/api/v3/values/property_generic_representer.rb deleted file mode 100644 index ed814ef2fa38..000000000000 --- a/lib/api/v3/values/property_generic_representer.rb +++ /dev/null @@ -1,33 +0,0 @@ -# --copyright -# OpenProject is an open source project management software. -# Copyright (C) the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See COPYRIGHT and LICENSE files for more details. -# ++ - -module API::V3::Values - class PropertyGenericRepresenter < PropertyRepresenter - property :value - end -end diff --git a/lib/api/v3/values/schemas/value_schema_factory.rb b/lib/api/v3/values/schemas/value_schema_factory.rb index 441bb6734729..de98a68e279e 100644 --- a/lib/api/v3/values/schemas/value_schema_factory.rb +++ b/lib/api/v3/values/schemas/value_schema_factory.rb @@ -29,7 +29,7 @@ module API::V3::Values::Schemas module ValueSchemaFactory extend ::API::V3::Utilities::PathHelper - SUPPORTED = %w(start_date due_date date note).freeze + SUPPORTED = %w(start_date due_date date).freeze module_function @@ -64,13 +64,10 @@ def i18n_for(property) I18n.t("attributes.#{property}") end - def type_for(property) - case property - when "start_date", "due_date", "date" - "Date" - when "note" - "String" - end + def type_for(_property) + # This is but a stub. Currently, only 'start_date' and 'due_date' + # need to be supported so this simple approach works. + "Date" end end end diff --git a/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb b/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb index bb3aef99788e..c0fb12c42cbd 100644 --- a/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb +++ b/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb @@ -267,60 +267,5 @@ .at_path("_embedded/details") end end - - shared_examples_for "embeds a Values::Property for reminder note" do - it "embeds a Values::Property" do - expect(generated) - .to be_json_eql("Values::Property".to_json) - .at_path("_embedded/details/0/_type") - end - - it "has a note value for the `property` property" do - expect(generated) - .to be_json_eql("note".to_json) - .at_path("_embedded/details/0/property") - end - - it "has a reminder`s note for the value" do - expect(generated) - .to be_json_eql(notification.reminder.note.to_json) - .at_path("_embedded/details/0/value") - end - end - - context "for a reminder when embedding" do - let(:reminder) { build_stubbed(:reminder) } - let(:reason) { :reminder } - let(:embed_links) { true } - - before do - allow(notification).to receive(:reminder).and_return(reminder) - end - - it_behaves_like "embeds a Values::Property for reminder note" - end - - context "for a reminder when not embedding" do - let(:reminder) { build_stubbed(:reminder) } - let(:reason) { :reminder } - let(:embed_links) { false } - - before do - allow(notification).to receive(:reminder).and_return(reminder) - end - - it_behaves_like "embeds a Values::Property for reminder note" - end - - context "for a reminder with no notification" do - let(:reminder) { nil } - let(:reason) { :reminder } - - it "has an empty details array" do - expect(generated) - .to have_json_size(0) - .at_path("_embedded/details") - end - end end end