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
Judge a ticket's meeting links against each meeting's own project
Guido Boykebff3f4fd4ab1
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.ymlindex 91aa238..2967672 100644--- a/.github/workflows/guards.yml+++ b/.github/workflows/guards.yml@@ -326,6 +326,7 @@ jobs:spec/requests/organisations/prompt_personas_spec.rbspec/requests/organisations/rich_text_editor_forms_spec.rbspec/requests/organisations/ticket_assistant_seams_spec.rb+ spec/requests/organisations/ticket_meeting_references_access_spec.rbspec/requests/organisations/ticket_writing_surface_spec.rbspec/requests/organisations/mobile_navigation_spec.rbspec/requests/organisations/tickets_destroy_spec.rbdiff --git a/app/models/meeting.rb b/app/models/meeting.rbindex 283389d..e032a0a 100644--- a/app/models/meeting.rb+++ b/app/models/meeting.rb@@ -201,6 +201,15 @@ class Meeting < ApplicationRecordMeetings::ParticipantFilter.call(all, [name])}+ # Meetings that link to `record` (a ticket), oldest link first. Says nothing+ # about who may read them: compose it onto MeetingPolicy::Scope, which judges+ # every meeting against its OWN project. A ticket moved to another project keeps+ # its links, so the ticket's project is the wrong question for its meetings.+ scope :linking_to, lambda { |record|+ joins(:outgoing_references).merge(Reference.pointing_to(record))+ .order(Reference.arel_table[:created_at])+ }+# Removes a leading YAML frontmatter block (FRONTMATTER_BLOCK) from `text`. Pure# function (mirrors MeetingParticipant.normalize_name) so display, the excerpt and# summary_source share ONE codepath — the raw value in the DB / edit textarea isdiff --git a/app/views/organisations/tickets/_meeting_references_section.html.erb b/app/views/organisations/tickets/_meeting_references_section.html.erbindex 1c10db5..8d6a133 100644--- a/app/views/organisations/tickets/_meeting_references_section.html.erb+++ b/app/views/organisations/tickets/_meeting_references_section.html.erb@@ -1,31 +1,30 @@-<%# locals: (ticket:, project:) %>+<%# locals: (ticket:) %><%# "Gespräche" backlinks on the ticket detail(Gespräche Slice 3): meetings that link TO this ticket. Sits between thesub-tasks section and the comment timeline, styled after _subtasks_section.- GATE (enforced by the caller): rendered ONLY when the user may read meetings in- this project — a user without :meetings read must not even learn that meeting- links exist (backlink leak = the critical path). This partial renders nothing- when there are no backlinks, so the section never appears empty.+ GATE (here, per meeting): a meeting shows only to people who may read meetings+ in the MEETING's project (MeetingPolicy::Scope), and its link names that project.+ A ticket moved to another project keeps its meeting links, so the ticket's+ project answers neither question. Somebody who may read none of the meetings+ does not learn that links exist: the section renders nothing without an entry,+ so it never appears empty.No tombstones on this side: a meeting owns its outgoing link (dependent:- :destroy), so a backlink's source meeting always exists. includes(:source)- avoids an N+1 across the linking meetings. %>-<% references = Reference.pointing_to(ticket)- .where(source_type: Meeting.polymorphic_name)- .includes(:source).order(:created_at).to_a %>-<% if references.any? %>+ :destroy), so a backlink's source meeting always exists. includes(:project)+ avoids an N+1 across the linking meetings' paths. %>+<% meetings = policy_scope(Meeting).linking_to(ticket).includes(:project).to_a %>+<% if meetings.any? %><section id="meeting-references-<%= ticket.id %>" class="meeting-references-section mb-6"><ul class="divide-y divide-cream-200 overflow-hidden rounded-lg bg-cream-50">- <% references.each do |ref| %>- <% meeting = ref.source %>+ <% meetings.each do |meeting| %><li class="flex items-center gap-3 px-3 py-2">- <i class="bi bi-chat-quote shrink-0 text-xs text-cream-500"></i>+ <i class="bi bi-chat-quote shrink-0 text-xs text-cream-500" aria-hidden="true"></i><%# _top: this section renders inside ticket_display_frame (the lane, onthe list and on the board), but the meetings page has no frame with that id —without the escape Turbo renders "Content missing" instead of navigating. %><%= link_to meeting.title,- organisation_project_meetings_path(@current_organisation, project, meeting_id: meeting.id),+ organisation_project_meetings_path(@current_organisation, meeting.project, meeting_id: meeting.id),class: 'flex-1 truncate text-sm text-cream-900 hover:underline',data: { turbo_frame: '_top' } %><span class="shrink-0 font-mono text-xs tabular-nums text-cream-500">diff --git a/app/views/organisations/tickets/_ticket_content_for_frame.html.erb b/app/views/organisations/tickets/_ticket_content_for_frame.html.erbindex 24aa4ef..6d496ae 100644--- a/app/views/organisations/tickets/_ticket_content_for_frame.html.erb+++ b/app/views/organisations/tickets/_ticket_content_for_frame.html.erb@@ -30,13 +30,10 @@<%= render 'organisations/tickets/relations_section', ticket: ticket %><%= turbo_frame_tag ticket_relation_modal_id(ticket) %>- <%# Meetings that link to this ticket (Gespräche Slice 3). GATE: only for users- who may read meetings in this project — without it the section (and even the- fact that meeting links exist) must stay hidden. Sits between sub-tasks and- the comment timeline. %>- <% if policy(@project).area_access?(:meetings, :read) %>- <%= render 'organisations/tickets/meeting_references_section', ticket: ticket, project: @project %>- <% end %>+ <%# Meetings that link to this ticket (Gespräche Slice 3). The section gates+ itself, per meeting against the meeting's own project: a moved ticket keeps+ links into its old project. Sits between sub-tasks and the comment timeline. %>+ <%= render 'organisations/tickets/meeting_references_section', ticket: ticket %><%# With reversed timeline order: buttons at the top, centered side by side %><% if current_user&.preference_store&.prefers_reverse_timeline? %>diff --git a/spec/requests/organisations/ticket_meeting_references_access_spec.rb b/spec/requests/organisations/ticket_meeting_references_access_spec.rbnew file mode 100644index 0000000..2fbdeee--- /dev/null+++ b/spec/requests/organisations/ticket_meeting_references_access_spec.rb@@ -0,0 +1,135 @@+# frozen_string_literal: true++require 'rails_helper'++# A ticket moved out of its meeting's project keeps the meeting link (nothing in the move+# touches Reference). The meeting then lives in project A and the ticket in project B. The+# ticket's "meetings" section must judge each meeting against the meeting's OWN project:+# read access to meetings in B says nothing about the meetings of A, and the link to a+# meeting of A has to name A.+RSpec.describe 'Ticket meeting references after a move', :ci_guard, type: :request do+ let(:organisation) { create(:organisation) }+ let(:creator) { create(:user) }+ let(:project_a) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation) } }+ let(:project_b) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation) } }++ let(:meeting) do+ ActsAsTenant.with_tenant(organisation) do+ create(:meeting, project: project_a, organisation: organisation, creator: creator,+ title: 'Planning-Meeting-QV')+ end+ end++ let(:ticket) do+ ActsAsTenant.with_tenant(organisation) do+ create(:ticket, project: project_a, organisation: organisation, creator: creator, title: 'Moved ticket')+ end+ end++ def grant(user, project, **access)+ ActsAsTenant.with_tenant(organisation) do+ create(:project_permission, { user: user, project: project }.merge(access))+ end+ end++ def member+ user = create(:user)+ ActsAsTenant.with_tenant(organisation) do+ role = create(:role, title: "Role #{SecureRandom.hex(4)}", organisation: organisation)+ create(:membership, user: user, organisation: organisation, role: role, active: true)+ end+ user+ end++ # Link in A, then move the ticket to B through the real mover.+ before do+ ActsAsTenant.with_tenant(organisation) do+ grant(creator, project_a, tickets_access: 'read_write', meetings_access: 'read_write')+ grant(creator, project_b, tickets_access: 'read_write', meetings_access: 'read_write')+ meeting.outgoing_references.create!(organisation: organisation, target: ticket,+ target_title_snapshot: ticket.display_title)+ Tickets::Mover.call(ticket: ticket, target_project: project_b, current_user: creator)+ end+ ticket.reload+ end++ def ticket_page+ get organisation_project_ticket_path(organisation, project_b, ticket)+ expect(response).to have_http_status(:ok)+ response.body+ end++ it 'moved the ticket and kept the link (precondition)' do+ expect(ticket.project_id).to eq(project_b.id)+ ActsAsTenant.with_tenant(organisation) do+ expect(Reference.pointing_to(ticket).where(source: meeting)).to exist+ end+ end++ context 'viewer reads meetings in B but has no access to A at all' do+ let(:viewer) do+ member.tap { |user| grant(user, project_b, tickets_access: 'read_only', meetings_access: 'read_only') }+ end++ it 'does not name the meeting of A' do+ sign_in viewer+ body = ticket_page++ expect(body).not_to include('Planning-Meeting-QV')+ expect(body).not_to include("meeting-references-#{ticket.id}")+ end+ end++ context 'viewer reads meetings in B and tickets, but not meetings, in A' do+ let(:viewer) do+ member.tap do |user|+ grant(user, project_b, tickets_access: 'read_only', meetings_access: 'read_only')+ grant(user, project_a, tickets_access: 'read_only')+ end+ end++ it 'does not name the meeting of A' do+ sign_in viewer+ body = ticket_page++ expect(body).not_to include('Planning-Meeting-QV')+ expect(body).not_to include("meeting-references-#{ticket.id}")+ end+ end++ context 'viewer reads meetings in A but not in B' do+ let(:viewer) do+ member.tap do |user|+ grant(user, project_b, tickets_access: 'read_only')+ grant(user, project_a, meetings_access: 'read_only')+ end+ end++ it 'names the meeting of A and links into A' do+ sign_in viewer+ body = ticket_page++ expect(body).to include('Planning-Meeting-QV')+ expect(body).to include(organisation_project_meetings_path(organisation, project_a, meeting_id: meeting.id))+ expect(body).not_to include(organisation_project_meetings_path(organisation, project_b, meeting_id: meeting.id))+ end+ end++ context 'viewer reads meetings in both projects' do+ let(:viewer) do+ member.tap do |user|+ grant(user, project_b, tickets_access: 'read_only', meetings_access: 'read_only')+ grant(user, project_a, meetings_access: 'read_only')+ end+ end++ it "links the meeting into its own project A, not into the ticket's project B" do+ sign_in viewer+ body = ticket_page++ expect(body).to include('Planning-Meeting-QV')+ expect(body).to include(organisation_project_meetings_path(organisation, project_a, meeting_id: meeting.id))+ expect(body).not_to include(organisation_project_meetings_path(organisation, project_b, meeting_id: meeting.id))+ end+ end+end