-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Feature/69562 add seeder migration that enables documents module by default for new projects #21561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
akabiru
merged 4 commits into
release/17.0
from
feature/69562-seeder-migration-enable-documents-module-per-default-for-new-projects
Jan 9, 2026
+248
−24
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6fb34a1
Enable (default) real time text collaboration based on hocuspocus url…
akabiru 20c18d4
Enable documents module by default when real-time collaboration is en…
akabiru fbf0727
Add safety check for Setting.exists? in migration
akabiru 6708d21
Improve tests to be more accurate/idiomatic
akabiru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
db/migrate/20260106151226_add_documents_to_default_projects_modules.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| #-- 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. | ||
| #++ | ||
|
|
||
| class AddDocumentsToDefaultProjectsModules < ActiveRecord::Migration[8.0] | ||
| def up | ||
| return unless Setting.exists?(:real_time_text_collaboration_enabled) | ||
| return unless Setting.real_time_text_collaboration_enabled? | ||
akabiru marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Only update if setting exists in DB (avoid updating on new installations - seeder handles that) | ||
| setting = Setting.find_by(name: "default_projects_modules") | ||
| return unless setting | ||
|
|
||
| current_modules = setting.value || [] | ||
| return if current_modules.include?("documents") | ||
|
|
||
| Setting.default_projects_modules = current_modules + ["documents"] | ||
cbliard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end | ||
|
|
||
| def down | ||
| # No-op | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
spec/migrations/add_documents_to_default_projects_modules_spec.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| #-- 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" | ||
| require Rails.root.join("db/migrate/20260106151226_add_documents_to_default_projects_modules") | ||
|
|
||
| RSpec.describe AddDocumentsToDefaultProjectsModules, type: :model do | ||
| let(:base_modules) { %w[calendar board_view work_package_tracking gantt news costs wiki] } | ||
|
|
||
| before do | ||
| # Ensure a clean state | ||
| Setting.find_by(name: "default_projects_modules")&.destroy | ||
| Setting.clear_cache | ||
| end | ||
|
|
||
| context "when real_time_text_collaboration is enabled", | ||
| with_settings: { real_time_text_collaboration_enabled: true } do | ||
| context "when default_projects_modules setting exists in DB" do | ||
| before do | ||
| Setting.default_projects_modules = base_modules | ||
| end | ||
|
|
||
| it "adds documents to the default modules" do | ||
| ActiveRecord::Migration.suppress_messages { described_class.migrate(:up) } | ||
|
|
||
| Setting.clear_cache | ||
| expect(Setting.default_projects_modules).to include("documents") | ||
| end | ||
|
|
||
| it "preserves existing modules" do | ||
| ActiveRecord::Migration.suppress_messages { described_class.migrate(:up) } | ||
|
|
||
| Setting.clear_cache | ||
| expect(Setting.default_projects_modules).to include(*base_modules) | ||
| end | ||
|
|
||
| context "when documents is already in the default modules" do | ||
| before do | ||
| Setting.default_projects_modules = base_modules + ["documents"] | ||
| end | ||
|
|
||
| it "does not duplicate documents" do | ||
| ActiveRecord::Migration.suppress_messages { described_class.migrate(:up) } | ||
|
|
||
| Setting.clear_cache | ||
| expect(Setting.default_projects_modules.count("documents")).to eq(1) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| context "when default_projects_modules setting does not exist in DB" do | ||
| it "does not create the setting (seeder handles new installations)" do | ||
| expect(Setting.find_by(name: "default_projects_modules")).to be_nil | ||
|
|
||
| ActiveRecord::Migration.suppress_messages { described_class.migrate(:up) } | ||
|
|
||
| # Setting should still not exist - seeder will handle it | ||
| expect(Setting.find_by(name: "default_projects_modules")).to be_nil | ||
| end | ||
| end | ||
| end | ||
|
|
||
| context "when real_time_text_collaboration is disabled", | ||
| with_settings: { real_time_text_collaboration_enabled: false } do | ||
| before do | ||
| Setting.default_projects_modules = base_modules | ||
| end | ||
|
|
||
| it "does not modify the default modules" do | ||
| ActiveRecord::Migration.suppress_messages { described_class.migrate(:up) } | ||
|
|
||
| Setting.clear_cache | ||
| expect(Setting.default_projects_modules).not_to include("documents") | ||
| expect(Setting.default_projects_modules).to match_array(base_modules) | ||
| end | ||
| end | ||
|
|
||
| context "when real_time_text_collaboration_enabled setting does not exist" do | ||
| before do | ||
| Setting.default_projects_modules = base_modules | ||
| allow(Setting).to receive(:exists?).and_call_original | ||
| allow(Setting).to receive(:exists?).with(:real_time_text_collaboration_enabled).and_return(false) | ||
| end | ||
|
|
||
| it "does not modify the default modules" do | ||
| ActiveRecord::Migration.suppress_messages { described_class.migrate(:up) } | ||
|
|
||
| Setting.clear_cache | ||
| expect(Setting.default_projects_modules).not_to include("documents") | ||
| expect(Setting.default_projects_modules).to match_array(base_modules) | ||
| end | ||
| end | ||
| end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.