OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#59433] Define database model for reminders
Kabiru Mwenjab466fba10c15
diff --git a/app/models/remindable.rb b/app/models/remindable.rbnew file mode 100644index 00000000000..d55e65bf912--- /dev/null+++ b/app/models/remindable.rb@@ -0,0 +1,35 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 Remindable+ extend ActiveSupport::Concern++ included do+ has_many :reminders, as: :remindable, dependent: :destroy+ end+enddiff --git a/app/models/reminder.rb b/app/models/reminder.rbnew file mode 100644index 00000000000..13365419f1b--- /dev/null+++ b/app/models/reminder.rb@@ -0,0 +1,32 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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.+#++++class Reminder < ApplicationRecord+ belongs_to :remindable, polymorphic: true+ belongs_to :creator, class_name: "User"+enddiff --git a/app/models/work_package.rb b/app/models/work_package.rbindex e02d14aa81d..27010679916 100644--- a/app/models/work_package.rb+++ b/app/models/work_package.rb@@ -41,6 +41,7 @@ class WorkPackage < ApplicationRecordinclude WorkPackages::Relationsinclude ::Scopes::Scopedinclude HasMembers+ include Remindableinclude OpenProject::Journal::AttachmentHelperdiff --git a/db/migrate/20241119131205_create_reminders.rb b/db/migrate/20241119131205_create_reminders.rbnew file mode 100644index 00000000000..0bac66cccf0--- /dev/null+++ b/db/migrate/20241119131205_create_reminders.rb@@ -0,0 +1,12 @@+class CreateReminders < ActiveRecord::Migration[7.1]+ def change+ create_table :reminders do |t|+ t.references :remindable, polymorphic: true, null: false+ t.references :creator, null: false, foreign_key: { to_table: :users }+ t.datetime :remind_at, null: false+ t.text :notes++ t.timestamps+ end+ end+enddiff --git a/spec/models/concerns/remindable_spec.rb b/spec/models/concerns/remindable_spec.rbnew file mode 100644index 00000000000..c86420aa8f7--- /dev/null+++ b/spec/models/concerns/remindable_spec.rb@@ -0,0 +1,37 @@+#-- 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.+#++++require "spec_helper"++RSpec.describe Remindable do+ let(:remindable) { build_stubbed(:work_package) }++ describe "Associations" do+ it { expect(remindable).to have_many(:reminders) }+ end+enddiff --git a/spec/models/reminder_spec.rb b/spec/models/reminder_spec.rbnew file mode 100644index 00000000000..6e22d9a83dd--- /dev/null+++ b/spec/models/reminder_spec.rb@@ -0,0 +1,36 @@+#-- 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.+#++++require "spec_helper"++RSpec.describe Reminder do+ describe "Associations" do+ it { is_expected.to belong_to(:remindable) }+ it { is_expected.to belong_to(:creator).class_name("User") }+ end+end