Skip to content

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

fix notifiable settings for document_added

ulferts9d76f80f7887
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index 8841a7d38cf..4b5a609a992 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -188,7 +188,7 @@ module SettingsHelper
# Renders a notification field for an OpenProject::Notifiable option
def notification_field(notifiable, options = {})
- content_tag(:label, class: 'form--label-with-check-box' + (notifiable.parent.present? ? ' parent' : '')) do
+ content_tag(:label, class: 'form--label-with-check-box') do
styled_check_box_tag('settings[notified_events][]',
notifiable.name,
Setting.notified_events.include?(notifiable.name),
diff --git a/lib/open_project/notifiable.rb b/lib/open_project/notifiable.rb
index e78a9254d42..3d40e3a2b29 100644
--- a/lib/open_project/notifiable.rb
+++ b/lib/open_project/notifiable.rb
@@ -40,7 +40,7 @@ module OpenProject
%w(membership_updated)
].freeze
- Notifiable = Struct.new(:name, :parent) do
+ Notifiable = Struct.new(:name) do
def to_s
name
end
diff --git a/modules/documents/lib/open_project/documents/engine.rb b/modules/documents/lib/open_project/documents/engine.rb
index 82dbe2cc47a..b901540d2e4 100644
--- a/modules/documents/lib/open_project/documents/engine.rb
+++ b/modules/documents/lib/open_project/documents/engine.rb
@@ -50,14 +50,13 @@ module OpenProject::Documents
}, require: :loggedin
end
- OpenProject::Notifiable.all << OpenProject::Notifiable.new('document_added')
-
Redmine::Search.register :documents
end
activity_provider :documents, class_name: 'Activities::DocumentActivityProvider', default: false
patches %i[CustomFieldsHelper Project]
+ patch_with_namespace :OpenProject, :Notifiable
add_api_path :documents do
"#{root}/documents"
diff --git a/modules/documents/lib/open_project/documents/patches/notifiable_patch.rb b/modules/documents/lib/open_project/documents/patches/notifiable_patch.rb
new file mode 100644
index 00000000000..2c32d81e5e2
--- /dev/null
+++ b/modules/documents/lib/open_project/documents/patches/notifiable_patch.rb
@@ -0,0 +1,41 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2021 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 docs/COPYRIGHT.rdoc for more details.
+#++
+
+module OpenProject::Documents::Patches::NotifiablePatch
+ def self.included(base)
+ class << base
+ prepend ClassMethods
+ end
+ end
+
+ module ClassMethods
+ def all
+ super + [::OpenProject::Notifiable.new('document_added')]
+ end
+ end
+end
diff --git a/modules/documents/spec/lib/open_project/notifiable_spec.rb b/modules/documents/spec/lib/open_project/notifiable_spec.rb
new file mode 100644
index 00000000000..5b3e9b70dfa
--- /dev/null
+++ b/modules/documents/spec/lib/open_project/notifiable_spec.rb
@@ -0,0 +1,39 @@
+#-- encoding: UTF-8
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2021 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 docs/COPYRIGHT.rdoc for more details.
+#++
+require 'spec_helper'
+
+describe OpenProject::Notifiable do
+ describe '#all' do
+ it 'includes document_added' do
+ expect(described_class.all.map(&:name))
+ .to include('document_added')
+ end
+ end
+end
diff --git a/spec/lib/open_project/notifiable_spec.rb b/spec/lib/open_project/notifiable_spec.rb
index f76aa6aa616..e0e56dbee76 100644
--- a/spec/lib/open_project/notifiable_spec.rb
+++ b/spec/lib/open_project/notifiable_spec.rb
@@ -32,11 +32,11 @@ require 'spec_helper'
describe OpenProject::Notifiable do
describe '#all' do
it 'matches expected list' do
- expected = %w(news_added news_comment_added file_added message_posted wiki_content_added
- wiki_content_updated membership_added membership_updated)
-
- expect(described_class.all.map(&:name))
- .to match_array(expected)
+ %w(news_added news_comment_added file_added message_posted wiki_content_added
+ wiki_content_updated membership_added membership_updated).each do |expected|
+ expect(described_class.all.map(&:name))
+ .to include(expected)
+ end
end
end
end