Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
Destroy view configurations without a project with their organisation
Guido Boykebc3ba01c27ce
diff --git a/app/models/organisation.rb b/app/models/organisation.rbindex ff289e8..19c84f0 100644--- a/app/models/organisation.rb+++ b/app/models/organisation.rb@@ -103,6 +103,9 @@ class Organisation < ApplicationRecordhas_many :projects, dependent: :destroyhas_many :tickets, through: :projectshas_many :smart_folders, dependent: :destroy+ # Project#view_configurations takes the rows of a project; this one takes the+ # rows without a project (the base view of "Alle Meetings"). The FK is NO ACTION.+ has_many :view_configurations, dependent: :destroyhas_many :ai_usages, dependent: :destroyhas_many :codebase_import_files, dependent: :destroyhas_many :tags, dependent: :destroydiff --git a/spec/models/view_configuration_without_project_spec.rb b/spec/models/view_configuration_without_project_spec.rbindex 685b86e..71930d0 100644--- a/spec/models/view_configuration_without_project_spec.rb+++ b/spec/models/view_configuration_without_project_spec.rb@@ -145,6 +145,26 @@ RSpec.describe ViewConfiguration, 'without a project' doendend+ # Organisation deletion is Rails-driven and the organisation FK is NO ACTION.+ # Project#view_configurations only reaches rows with a project; without+ # Organisation#view_configurations the overview row would block the delete+ # with InvalidForeignKey.+ describe 'when the organisation is destroyed' do+ it 'removes the row without a project and keeps the row of another organisation' do+ overview_row = build_overview_config.tap(&:save!)+ other_row = ActsAsTenant.with_tenant(other_organisation) do+ build_overview_config(in_organisation: other_organisation).tap(&:save!)+ end++ organisation.destroy!++ ActsAsTenant.without_tenant do+ expect(described_class.exists?(overview_row.id)).to be(false)+ expect(described_class.exists?(other_row.id)).to be(true)+ end+ end+ end+describe '.for_list' doit 'picks the row of the project when there is one, the organisation row otherwise' dowith_project = described_class.for_list(user: user, organisation: organisation, project: project, view_type: 'meetings')