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
delete existing project_details widgets
ulferts0a895b4de950
diff --git a/db/migrate/20241025072902_remove_project_details_widget.rb b/db/migrate/20241025072902_remove_project_details_widget.rbnew file mode 100644index 00000000000..352218ac0b3--- /dev/null+++ b/db/migrate/20241025072902_remove_project_details_widget.rb@@ -0,0 +1,13 @@+class RemoveProjectDetailsWidget < ActiveRecord::Migration[7.1]+ def up+ # The joining of the overview grids is not strictly necessary+ # but it ensures that only widgets of overview grids are removed.+ execute <<~SQL.squish+ DELETE FROM grid_widgets+ USING grids+ WHERE grids.id = grid_widgets.grid_id+ AND grids.type = 'Grids::Overview'+ AND grid_widgets.identifier = 'project_details'+ SQL+ end+enddiff --git a/spec/migrations/remove_project_details_widget_spec.rb b/spec/migrations/remove_project_details_widget_spec.rbnew file mode 100644index 00000000000..26dc85fcda3--- /dev/null+++ b/spec/migrations/remove_project_details_widget_spec.rb@@ -0,0 +1,62 @@+# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2010-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.+# ++++require "spec_helper"+require Rails.root.join("db/migrate/20241025072902_remove_project_details_widget.rb")++RSpec.describe RemoveProjectDetailsWidget, type: :model do+ subject do+ ActiveRecord::Migration.suppress_messages do+ described_class+ .new+ .tap { _1.migrate(:up) }+ end+ end++ let!(:overview) do+ create(:overview) do |o|+ create(:grid_widget, grid: o, identifier: "widget_a", start_row: 1, end_row: 2, start_column: 1, end_column: 2)+ create(:grid_widget, grid: o, identifier: "widget_b", start_row: 1, end_row: 2, start_column: 2, end_column: 3)+ create(:grid_widget, grid: o, identifier: "project_details", start_row: 2, end_row: 3, start_column: 1, end_column: 2)+ create(:grid_widget, grid: o, identifier: "widget_c", start_row: 2, end_row: 3, start_column: 2, end_column: 3)+ create(:grid_widget, grid: o, identifier: "widget_d", start_row: 3, end_row: 4, start_column: 1, end_column: 2)+ create(:grid_widget, grid: o, identifier: "widget_1", start_row: 4, end_row: 4, start_column: 2, end_column: 3)+ end+ end++ it "removes only the project_details widget", :aggregate_failures do+ subject++ expect(Grids::Widget.where(identifier: "project_details")).not_to exist+ expect(Grids::Widget.where(identifier: "widget_a", start_row: 1, end_row: 2, start_column: 1, end_column: 2)).to exist+ expect(Grids::Widget.where(identifier: "widget_b", start_row: 1, end_row: 2, start_column: 2, end_column: 3)).to exist+ expect(Grids::Widget.where(identifier: "widget_c", start_row: 2, end_row: 3, start_column: 2, end_column: 3)).to exist+ expect(Grids::Widget.where(identifier: "widget_d", start_row: 3, end_row: 4, start_column: 1, end_column: 2)).to exist+ expect(Grids::Widget.where(identifier: "widget_1", start_row: 4, end_row: 4, start_column: 2, end_column: 3)).to exist+ end+end