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
Pin that a meeting edit keeps the participant's person link
Guido Boykefc536348c13e
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.ymlindex 4b2e7d9..cff7597 100644--- a/.github/workflows/guards.yml+++ b/.github/workflows/guards.yml@@ -603,6 +603,8 @@ jobs:spec/requests/organisations/meetings_overview_views_spec.rbspec/requests/organisations/meeting_move_spec.rbspec/services/actors/move_meeting_spec.rb+ spec/services/actors/save_meeting_spec.rb+ spec/services/actors/claim_meeting_participants_spec.rbspec/requests/organisations/meetings_overview_columns_spec.rbspec/requests/organisations/meetings_overview_lane_spec.rbspec/requests/organisations/meetings_overview_lane_access_spec.rbdiff --git a/app/services/actors/save_meeting.rb b/app/services/actors/save_meeting.rbindex 7e7669c..0fbb9da 100644--- a/app/services/actors/save_meeting.rb+++ b/app/services/actors/save_meeting.rb@@ -146,6 +146,12 @@ module Actorsraise ActorError, @meeting.errors.full_messages if @meeting.errors.any?end+ # Rows are matched by normalized_name and updated in place, never rebuilt.+ # That is what keeps person_id (the link to the people directory): the form+ # does not know it, and it never comes from the payload. A row survives every+ # save that keeps its name, in any spelling, with its link. A new name is a+ # new row without a link: the form has no rename, a chip removed and another+ # added is another participant, and the link dialog sets the link again.def reconcile_participants(desired)keep = desired.map { |d| d[:normalized_name] }# Remove participants no longer present (empty desired -> clears them all).diff --git a/spec/services/actors/claim_meeting_participants_spec.rb b/spec/services/actors/claim_meeting_participants_spec.rbindex 20ba61c..777bfda 100644--- a/spec/services/actors/claim_meeting_participants_spec.rb+++ b/spec/services/actors/claim_meeting_participants_spec.rb@@ -66,6 +66,19 @@ RSpec.describe Actors::ClaimMeetingParticipants doexpect(row.display_name).to eq('karl krause')end+ # The claim writes user_id only. A row linked to the people directory keeps+ # its person_id (meeting_participants.person_id, set by the link dialog).+ it 'leaves person_id untouched' do+ target = member+ person = create(:person, organisation: organisation, name: 'Karl Krause')+ row = external_row(writable_project, 'Karl Krause')+ row.update_column(:person_id, person.id)++ described_class.new(user: target, normalized_name: 'Karl Krause', current_user: actor).call++ expect(MeetingParticipant.where(id: row.id).pluck(:user_id, :person_id)).to eq([[target.id, person.id]])+ end+it 'matches across umlaut spellings (member "Jörg Groß" ~ external "Joerg Gross")' dotarget = member(first: 'Jörg', last: 'Groß')row = external_row(writable_project, 'Joerg Gross')diff --git a/spec/services/actors/save_meeting_spec.rb b/spec/services/actors/save_meeting_spec.rbindex ad330e8..2a6ed87 100644--- a/spec/services/actors/save_meeting_spec.rb+++ b/spec/services/actors/save_meeting_spec.rb@@ -213,6 +213,105 @@ RSpec.describe Actors::SaveMeeting doresult = described_class.call(project: project, params: params, current_user: user)expect(result.success).to be(false)end++ # meeting_participants.person_id links a row to the people directory. The form+ # never sends it: the edit keeps a row by its normalized name, so the link+ # survives every save that keeps the name, and a new name is a new row without+ # a link (accepted; the link dialog sets it again). Rebuilding the rows on save,+ # or taking person_id from the payload, would drop every link on every save.+ describe 'person link (person_id)' do+ let(:person) { create(:person, organisation: organisation, name: 'Karl Krause') }++ # The meeting is created through the actor; the link is set directly, as the+ # link dialog (a separate writer) will.+ def meeting_with(*names)+ described_class.call(+ project: project, params: valid_params.merge(participants: names.map { |n| { display_name: n } }),+ current_user: user+ ).resource+ end++ def linked_row(meeting, name)+ row = meeting.meeting_participants.find_by!(normalized_name: MeetingParticipant.normalize_name(name))+ row.update_column(:person_id, person.id)+ row+ end++ def save(meeting, params)+ result = described_class.call(project: project, id: meeting.id, params: params, current_user: user)+ expect(result.success).to be(true)+ result+ end++ it 'keeps person_id and the row when the name stays and the rest of the meeting changes' do+ meeting = meeting_with('Karl Krause', 'Anna Ananas')+ row = linked_row(meeting, 'Karl Krause')++ save(meeting, valid_params.merge(title: 'Retro',+ participants: [{ display_name: 'Karl Krause' }, { display_name: 'Bert Bauer' }]))++ expect(meeting.reload.title).to eq('Retro')+ expect(participants_of(meeting)).to eq(['bert bauer', 'karl krause'])+ expect(MeetingParticipant.where(id: row.id).pluck(:person_id)).to eq([person.id])+ end++ it 'keeps person_id and takes the new spelling when the normalized name is the same' do+ meeting = meeting_with('Karl Krause')+ row = linked_row(meeting, 'Karl Krause')++ save(meeting, valid_params.merge(participants: [{ display_name: ' KARL krause ' }]))++ rows = meeting.reload.meeting_participants.pluck(:id, :display_name, :person_id)+ expect(rows).to eq([[row.id, 'KARL krause', person.id]])+ end++ it 'keeps person_id when only the user_id of the participant changes' do+ member = org_member+ meeting = meeting_with('Karl Krause')+ row = linked_row(meeting, 'Karl Krause')++ save(meeting, valid_params.merge(participants: [{ display_name: 'Karl Krause', user_id: member.id }]))+ expect(MeetingParticipant.where(id: row.id).pluck(:user_id, :person_id)).to eq([[member.id, person.id]])++ save(meeting, valid_params.merge(participants: [{ display_name: 'Karl Krause', user_id: '' }]))+ expect(MeetingParticipant.where(id: row.id).pluck(:user_id, :person_id)).to eq([[nil, person.id]])+ end++ it 'keeps person_id when no :participants key is sent' do+ meeting = meeting_with('Karl Krause')+ row = linked_row(meeting, 'Karl Krause')++ save(meeting, { title: 'Renamed', occurred_at: Time.current })++ expect(MeetingParticipant.where(id: row.id).pluck(:person_id)).to eq([person.id])+ end++ it 'never takes person_id from the payload' do+ other = create(:person, organisation: organisation, name: 'Erika Muster')+ meeting = meeting_with('Karl Krause', 'Anna Ananas')+ row = linked_row(meeting, 'Karl Krause')++ save(meeting, valid_params.merge(participants: [{ display_name: 'Karl Krause', person_id: other.id },+ { display_name: 'Anna Ananas', person_id: other.id }]))++ expect(meeting.reload.meeting_participants.pluck(:id, :person_id))+ .to contain_exactly([row.id, person.id], [anything, nil])+ end++ # The accepted rule (no rename in the form): a chip removed and a new one+ # added is another participant. The old row goes, its link with it.+ it 'drops the row and its link when the name is replaced by a new one' do+ meeting = meeting_with('Karl Krause')+ row = linked_row(meeting, 'Karl Krause')++ save(meeting, valid_params.merge(participants: [{ display_name: 'Karl Kraus' }]))++ rows = meeting.reload.meeting_participants.pluck(:id, :normalized_name, :person_id)+ expect(rows.size).to eq(1)+ expect(rows.first).to match([satisfy { |id| id != row.id }, 'karl kraus', nil])+ expect(Person.exists?(person.id)).to be(true)+ end+ endend# Search & chat embedding wiring (Gespräche Slice 6): enqueue gating mirrors