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
remove acts_as_customizable from enumerable
ulfertseae67495629c
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rbindex e433e6e31e7..3aff71dff4f 100644--- a/app/helpers/custom_fields_helper.rb+++ b/app/helpers/custom_fields_helper.rb@@ -66,18 +66,6 @@ module CustomFieldsHelperpartial: 'custom_fields/tab',path: custom_fields_path(tab: :GroupCustomField),label: :label_group_plural- },- {- name: 'TimeEntryActivityCustomField',- partial: 'custom_fields/tab',- path: custom_fields_path(tab: :TimeEntryActivityCustomField),- label: TimeEntryActivity::OptionName- },- {- name: 'IssuePriorityCustomField',- partial: 'custom_fields/tab',- path: custom_fields_path(tab: :IssuePriorityCustomField),- label: IssuePriority::OptionName}]enddiff --git a/app/models/enumeration.rb b/app/models/enumeration.rbindex c0732290f77..258e111e157 100644--- a/app/models/enumeration.rb+++ b/app/models/enumeration.rb@@ -34,7 +34,6 @@ class Enumeration < ApplicationRecordbelongs_to :projectacts_as_list scope: 'type = \'#{type}\''- acts_as_customizableacts_as_tree order: 'position ASC'before_destroy :check_integritydiff --git a/app/views/enumerations/_form.html.erb b/app/views/enumerations/_form.html.erbindex 75858ad1bd9..6e0feb76129 100644--- a/app/views/enumerations/_form.html.erb+++ b/app/views/enumerations/_form.html.erb@@ -48,8 +48,4 @@ See COPYRIGHT and LICENSE files for more details.label: @enumeration.color_label} %><% end %>-- <% @enumeration.custom_field_values.each do |value| %>- <div class="form--field"><%= custom_field_tag_with_label :enumeration, value %></div>- <% end %></section>diff --git a/db/migrate/20211102161932_remove_custom_field_types.rb b/db/migrate/20211102161932_remove_custom_field_types.rbnew file mode 100644index 00000000000..499e5f626e6--- /dev/null+++ b/db/migrate/20211102161932_remove_custom_field_types.rb@@ -0,0 +1,35 @@+class RemoveCustomFieldTypes < ActiveRecord::Migration[6.1]+ def up+ delete_custom_field('TimeEntryActivityCustomField')+ delete_custom_field('DocumentCategoryCustomField')+ delete_custom_field('IssuePriorityCustomField')++ delete_custom_values+ end++ def delete_custom_field(type)+ execute <<~SQL.squish+ DELETE FROM+ custom_fields+ WHERE+ type = '#{type}'+ SQL+ end++ def delete_custom_values+ execute <<~SQL.squish+ DELETE FROM+ custom_values values_delete+ USING+ custom_values values_select+ LEFT OUTER JOIN+ custom_fields+ ON+ custom_fields.id = values_select.custom_field_id+ WHERE+ values_delete.id = values_select.id+ AND+ custom_fields.id IS NULL+ SQL+ end+enddiff --git a/modules/costs/app/models/time_entry_activity_custom_field.rb b/modules/costs/app/models/time_entry_activity_custom_field.rbdeleted file mode 100644index df9ab482087..00000000000--- a/modules/costs/app/models/time_entry_activity_custom_field.rb+++ /dev/null@@ -1,35 +0,0 @@-#-- 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 COPYRIGHT and LICENSE files for more details.-#++--class TimeEntryActivityCustomField < CustomField- def type_name- :enumeration_activities- end-enddiff --git a/app/models/issue_priority_custom_field.rb b/modules/costs/spec/models/time_entry_activity_spec.rbsimilarity index 64%rename from app/models/issue_priority_custom_field.rbrename to modules/costs/spec/models/time_entry_activity_spec.rbindex a67e7292063..49be71957d7 100644--- a/app/models/issue_priority_custom_field.rb+++ b/modules/costs/spec/models/time_entry_activity_spec.rb@@ -28,8 +28,30 @@# See COPYRIGHT and LICENSE files for more details.#++-class IssuePriorityCustomField < CustomField- def type_name- :enumeration_work_package_priorities+require 'spec_helper'++describe TimeEntryActivity, type: :model do+ let(:new_activity) { described_class.new }+ let(:saved_activity) { described_class.create name: 'Design' }++ it 'is an enumeration' do+ expect(new_activity)+ .to be_a(Enumeration)+ end++ describe '#objects_count' do+ it 'represents the count of time entries of that activity' do+ expect { FactoryBot.create(:time_entry, activity: saved_activity) }+ .to change(saved_activity, :objects_count)+ .from(0)+ .to(1)+ end+ end++ describe '#option_name' do+ it 'is enumeration_activities' do+ expect(new_activity.option_name)+ .to eq :enumeration_activities+ endendenddiff --git a/modules/documents/app/models/document_category_custom_field.rb b/modules/documents/app/models/document_category_custom_field.rbdeleted file mode 100644index 4a381ceedbc..00000000000--- a/modules/documents/app/models/document_category_custom_field.rb+++ /dev/null@@ -1,35 +0,0 @@-#-- 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 COPYRIGHT and LICENSE files for more details.-#++--class DocumentCategoryCustomField < CustomField- def type_name- :enumeration_doc_categories- end-enddiff --git a/modules/documents/lib/open_project/documents/engine.rb b/modules/documents/lib/open_project/documents/engine.rbindex 7b44248c018..7e0fde687ed 100644--- a/modules/documents/lib/open_project/documents/engine.rb+++ b/modules/documents/lib/open_project/documents/engine.rb@@ -54,7 +54,7 @@ module OpenProject::Documentsactivity_provider :documents, class_name: 'Activities::DocumentActivityProvider', default: false- patches %i[CustomFieldsHelper Project]+ patches %i[Project]add_api_path :documents do"#{root}/documents"@@ -78,7 +78,6 @@ module OpenProject::Documentsconfig.to_prepare dorequire_dependency 'document'require_dependency 'document_category'- require_dependency 'document_category_custom_field'require_dependency 'open_project/documents/patches/textile_converter_patch'enddiff --git a/modules/documents/lib/open_project/documents/patches/custom_fields_helper_patch.rb b/modules/documents/lib/open_project/documents/patches/custom_fields_helper_patch.rbdeleted file mode 100644index ff65da43f8f..00000000000--- a/modules/documents/lib/open_project/documents/patches/custom_fields_helper_patch.rb+++ /dev/null@@ -1,50 +0,0 @@-#-- 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 COPYRIGHT and LICENSE files for more details.-#++--module OpenProject::Documents::Patches- module CustomFieldsHelperPatch- def self.included(base)- base.prepend InstanceMethods- end-- module InstanceMethods- def custom_fields_tabs- super << {- name: 'DocumentCategoryCustomField',- partial: 'custom_fields/tab',- path: custom_fields_path(tab: :DocumentCategoryCustomField),- label: DocumentCategory::OptionName- }- end- end- end-end--unless CustomFieldsHelper.included_modules.include?(OpenProject::Documents::Patches::CustomFieldsHelperPatch)- CustomFieldsHelper.include OpenProject::Documents::Patches::CustomFieldsHelperPatch-enddiff --git a/spec_legacy/fixtures/custom_fields.yml b/spec_legacy/fixtures/custom_fields.ymlindex a38842e8069..7be6fe87be2 100644--- a/spec_legacy/fixtures/custom_fields.yml+++ b/spec_legacy/fixtures/custom_fields.yml@@ -97,18 +97,6 @@ custom_fields_006:is_required: falsefield_format: floateditable: true-custom_fields_007:- name: "Billable"- min_length: 0- regexp: ""- is_for_all: false- is_filter: true- type: TimeEntryActivityCustomField- max_length: 0- id: 7- is_required: false- field_format: bool- editable: truecustom_fields_008:name: "Custom date"min_length: 0diff --git a/spec_legacy/unit/enumeration_spec.rb b/spec_legacy/unit/enumeration_spec.rbindex d89ac54975b..f38eeef3488 100644--- a/spec_legacy/unit/enumeration_spec.rb+++ b/spec_legacy/unit/enumeration_spec.rb@@ -86,10 +86,6 @@ describe Enumeration, type: :model doassert_equal @issues.size, new_priority.objects_countend- it 'should be customizable' do- assert Enumeration.included_modules.include?(Redmine::Acts::Customizable::InstanceMethods)- end-it 'should belong to a project' doassociation = Enumeration.reflect_on_association(:project)assert association, 'No Project association found'diff --git a/spec_legacy/unit/time_entry_activity_spec.rb b/spec_legacy/unit/time_entry_activity_spec.rbdeleted file mode 100644index df0f7bc5aa3..00000000000--- a/spec_legacy/unit/time_entry_activity_spec.rb+++ /dev/null@@ -1,98 +0,0 @@-#-- 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 COPYRIGHT and LICENSE files for more details.-#++-require_relative '../legacy_spec_helper'--describe TimeEntryActivity, type: :model do- include MiniTest::Assertions # refute-- fixtures :all-- it 'should be an enumeration' do- assert TimeEntryActivity.ancestors.include?(Enumeration)- end-- it 'should objects count' do- assert_equal 3, TimeEntryActivity.find_by(name: 'Design').objects_count- assert_equal 1, TimeEntryActivity.find_by(name: 'Development').objects_count- end-- it 'should option name' do- assert_equal :enumeration_activities, TimeEntryActivity.new.option_name- end-- it 'should create with custom field' do- field = TimeEntryActivityCustomField.find_by(name: 'Billable')- e = TimeEntryActivity.new(name: 'Custom Data')- e.custom_field_values = { field.id => '1' }- assert e.save-- e.reload- assert_equal 't', e.custom_value_for(field).value- end-- it 'should create without required custom field should fail' do- field = TimeEntryActivityCustomField.find_by(name: 'Billable')- field.update_attribute(:is_required, true)-- e = TimeEntryActivity.new(name: 'Custom Data')- assert !e.save- assert_includes e.errors["custom_field_#{field.id}"],- I18n.translate('activerecord.errors.messages.blank')- end-- it 'should create with required custom field should succeed' do- field = TimeEntryActivityCustomField.find_by(name: 'Billable')- field.update_attribute(:is_required, true)-- e = TimeEntryActivity.new(name: 'Custom Data')- e.custom_field_values = { field.id => '1' }- assert e.save- end-- it 'should update issue with required custom field change' do- field = TimeEntryActivityCustomField.find_by(name: 'Billable')- field.update_attribute(:is_required, true)-- e = TimeEntryActivity.find(10)- assert e.available_custom_fields.include?(field)- # No change to custom field, record can be saved- assert e.save- # Blanking custom field, save should fail- e.custom_field_values = { field.id => '' }- assert !e.save- refute_empty e.errors["custom_field_#{field.id}"]-- # Update custom field to valid value, save should succeed- e.custom_field_values = { field.id => '0' }- assert e.save- e.reload- assert_equal 'f', e.custom_value_for(field).value- end-end