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
fix: review round 1 of #111, sharpen what the meeting tests hold
Guido Boyke623c3b451653
diff --git a/CLAUDE.md b/CLAUDE.mdindex 50c2f97..37ce335 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -806,7 +806,7 @@ feature by feature):body comes from `Api::V1::ErrorBody` through `BaseController#render_error`; guard`spec/architecture/api_v1_error_body_guard_spec.rb`. Answers outside the controllers carryno `code`: the Rack::Attack 429 (plain text), a 500 from the exceptions app, a 400 for a- query string Rack cannot decode (`?x=%`; raised in middleware before any controller), and a+ query string Rack cannot decode (`?x=%`; raised in middleware before any controller), a query or path parameter of raw bytes that are no valid UTF-8 (`?q=%FF`, an HTML 400 before authentication, the same whatever exists), and a400 for a body parameter of raw bytes that are no valid UTF-8, form or JSON (Rails raises`ActionController::BadRequest` when it first reads the parameters, in its params wrapper orits request log, before any callback or `rescue_from` of `BaseController` runs; a JSON escape@@ -912,7 +912,7 @@ API 1.10.0, capabilities `meetings.list`, `meetings.show`; no MCP tool) read a pand one meeting. Fields are `Meetings::Serializer`'s two allowlists: a row has no text of themeeting, the whole answer adds `participants` (names only), `generated_summary` (Markdown),`notes`, `transcript` (uncut, a leading metadata block left off as on the web), `updated_at`,-`path`. No analyses, ticket suggestions or linked tickets: each has a visibility rule of its own.+`path`. `creator.name` is null when the account is gone, the id stays. No analyses, ticket suggestions or linked tickets: each has a visibility rule of its own.The list runs `Meetings::ListQuery`, the web list's order (`occurred_at`, then the entry time,then `id`, all newest first) and `Meeting.search_by_content`, on `policy_scope(project.meetings)`and nowhere else, because the search matches inside transcripts. Paging and `q` by the strictdiff --git a/spec/contracts/mcp_contract_recorder.rb b/spec/contracts/mcp_contract_recorder.rbindex b3f3ba4..378467e 100644--- a/spec/contracts/mcp_contract_recorder.rb+++ b/spec/contracts/mcp_contract_recorder.rb@@ -112,6 +112,7 @@ module McpContractwrite_token: 81, read_token: 82, deactivated_token: 83, limited_token: 84, dora_token: 85,doris_person: 91, ben_person: 92,kickoff_meeting: 101, review_meeting: 102, hidden_meeting: 103, internal_meeting: 104, foreign_meeting: 105,+ gone_meeting: 106, gone_user: 107,missing: 999}.transform_values { |n| format('00000000-0000-4000-8000-%012d', n) }.freeze@@ -690,6 +691,14 @@ module McpContractcreate(:meeting, id: id(:internal_meeting), project: @internal, organisation: @organisation, creator: @anna,title: 'Interne Runde', occurred_at: START - 4.days)end+ in_org do+ # The creator's account is gone: the id stays, `name` is null.+ gone = create(:user, id: id(:gone_user), email: '[email protected]', first_name: 'Gerd', last_name: 'Gegangen')+ create(:membership, user: gone, organisation: @organisation, role: Role.find(id(:role)), active: true)+ create(:meeting, id: id(:gone_meeting), project: @internal, organisation: @organisation, creator: gone,+ title: 'Altes Gespräch', occurred_at: START - 6.days)+ gone.soft_delete!+ endActsAsTenant.with_tenant(@other_organisation) docreate(:meeting, id: id(:foreign_meeting), project: @foreign_project, organisation: @other_organisation, creator: @ben,title: 'Fremdes Gespräch', occurred_at: START - 5.days)@@ -706,6 +715,8 @@ module McpContract'ok' => rest_get(:read, path),'ok_search' => rest_get(:read, "#{path}?q=M%C3%A4rz"),'ok_page' => rest_get(:read, "#{path}?page=2&per_page=1"),+ # The last row's creator has no account any more.+ 'ok_creator_gone' => rest_get(:read, "/api/v1/projects/#{id(:internal)}/meetings"),'empty' => rest_get(:read, "#{path}?q=Gibt%20es%20nicht"),# The reader opens the project but reads no meetings there.'empty_no_area' => rest_get(:read, "/api/v1/projects/#{id(:handbook)}/meetings"),@@ -724,6 +735,7 @@ module McpContract'ok' => rest_get(:read, path.call(:kickoff_meeting)),# No duration, no notes, no transcript, no summary, nobody named.'ok_bare' => rest_get(:read, path.call(:review_meeting)),+ 'ok_creator_gone' => rest_get(:read, path.call(:gone_meeting)),'not_found' => rest_get(:read, path.call(:missing)),'not_found_malformed' => rest_get(:read, '/api/v1/meetings/not-a-uuid'),# All of these answer exactly like the missing one.diff --git a/spec/fixtures/mcp_contract.json b/spec/fixtures/mcp_contract.jsonindex ccfa83d..d5b1805 100644--- a/spec/fixtures/mcp_contract.json+++ b/spec/fixtures/mcp_contract.json@@ -1,9 +1,9 @@{"header": {"regenerate": "RAILS_ENV=test bin/rails mcp:contract",- "core_commit": "49391c5b10ddbdfbbb3141520b8c6faece429b5f",+ "core_commit": "e084716a38a4f204d844af7dc7ebf40a94411781","core_dirty": true,- "contract_sha256": "5c6489e822b85cfec1fb37099088ac4ae3b4b524c1b3185d275a421ccde75ef3"+ "contract_sha256": "f662e324577e9c86ae8fb19d8c53f804051917a7315514cfa66cab103a1e32e4"},"contract": {"mcp": {@@ -7510,6 +7510,46 @@}}},+ "ok_creator_gone": {+ "token": "read",+ "request": {+ "path": "/api/v1/projects/00000000-0000-4000-8000-000000000032/meetings"+ },+ "response": {+ "status": 200,+ "body": {+ "data": [+ {+ "id": "00000000-0000-4000-8000-000000000104",+ "project_id": "00000000-0000-4000-8000-000000000032",+ "title": "Interne Runde",+ "occurred_at": "2026-01-01T09:00:00Z",+ "duration_minutes": null,+ "creator": {+ "id": "00000000-0000-4000-8000-000000000011",+ "name": "Anna Albers"+ }+ },+ {+ "id": "00000000-0000-4000-8000-000000000106",+ "project_id": "00000000-0000-4000-8000-000000000032",+ "title": "Altes Gespräch",+ "occurred_at": "2025-12-30T09:00:00Z",+ "duration_minutes": null,+ "creator": {+ "id": "00000000-0000-4000-8000-000000000107",+ "name": null+ }+ }+ ],+ "meta": {+ "page": 1,+ "per_page": 10,+ "total": 2+ }+ }+ }+ },"empty": {"token": "read","request": {@@ -7676,6 +7716,34 @@}}},+ "ok_creator_gone": {+ "token": "read",+ "request": {+ "path": "/api/v1/meetings/00000000-0000-4000-8000-000000000106"+ },+ "response": {+ "status": 200,+ "body": {+ "data": {+ "id": "00000000-0000-4000-8000-000000000106",+ "project_id": "00000000-0000-4000-8000-000000000032",+ "title": "Altes Gespräch",+ "occurred_at": "2025-12-30T09:00:00Z",+ "duration_minutes": null,+ "creator": {+ "id": "00000000-0000-4000-8000-000000000107",+ "name": null+ },+ "participants": [],+ "generated_summary": "",+ "notes": null,+ "transcript": null,+ "updated_at": "2026-01-05T09:36:00Z",+ "path": "/org/00000000-0000-4000-8000-000000000001/projects/00000000-0000-4000-8000-000000000032/meetings/00000000-0000-4000-8000-000000000106"+ }+ }+ }+ },"not_found": {"token": "read","request": {diff --git a/spec/requests/api/v1/meetings_read_spec.rb b/spec/requests/api/v1/meetings_read_spec.rbindex ea98d4b..7e73ee8 100644--- a/spec/requests/api/v1/meetings_read_spec.rb+++ b/spec/requests/api/v1/meetings_read_spec.rb@@ -93,6 +93,17 @@ RSpec.describe 'REST meetings', :ci_guard, type: :request doexpect(response.parsed_body['data'].last['duration_minutes']).to eq(45)end+ it 'answers a creator whose account is gone with the id and no name' do+ gone = member(meetings: 'read_write')+ found = meeting(creator: gone)+ quietly { gone.soft_delete! }++ expect(list).to have_http_status(:ok)+ expect(response.parsed_body['data'].first['creator']).to eq('id' => gone.id, 'name' => nil)+ expect(show(found.id)).to have_http_status(:ok)+ expect(response.parsed_body.dig('data', 'creator')).to eq('id' => gone.id, 'name' => nil)+ end+it 'keeps the order over pages when date and entry time are equal, down to the id' doat = 2.days.ago.change(usec: 0)made = %w[1 3 2 5 4].map do |digit|@@ -146,6 +157,14 @@ RSpec.describe 'REST meetings', :ci_guard, type: :request doexpect(response.parsed_body.dig('meta', 'total')).to eq(0)end+ it 'trims the search term' do+ found = meeting(title: 'Budget review')+ meeting(title: 'Something else')++ list('?q=%20budget%20')+ expect(ids).to eq([found.id])+ end+it 'matches a percent sign as text' domeeting(title: 'Plain')@@ -215,6 +234,23 @@ RSpec.describe 'REST meetings', :ci_guard, type: :request doexpect(response.body).to eq(not_found_body)end+ # The reader may read both projects: only the project in the path, and the token, keep+ # the rows of the other one out, in the list, in the search and in the count.+ it 'never lists a meeting of another project the owner may read, beyond the token or not' do+ sibling = new_project+ quietly { create(:project_permission, user: reader, project: sibling, meetings_access: 'read_only') }+ meeting(in_project: sibling, transcript: 'the secret word')+ pat = token_for(reader, project_scopes: { organisation => [project] })++ list('?q=secret', pat: pat)+ expect(ids).to eq([held.id])+ expect(response.parsed_body.dig('meta', 'total')).to eq(1)++ list('?q=secret')+ expect(ids).to eq([held.id])+ expect(response.parsed_body.dig('meta', 'total')).to eq(1)+ end+it 'answers an empty list to a reader of the project without the meetings area' dotickets_only = member(meetings: 'no_access', tickets: 'read_only')@@ -261,6 +297,17 @@ RSpec.describe 'REST meetings', :ci_guard, type: :request doexpect(queries.grep(/FROM "users" WHERE "users"\."id" IN/).size).to be <= 2end+ it 'reads no rows for a page beyond the end' do+ meeting+ pat = token_for(reader)+ queries = []+ counter = ->(*, payload) { queries << payload[:sql] }++ ActiveSupport::Notifications.subscribed(counter, 'sql.active_record') { list('?page=2', pat: pat) }++ expect(queries.grep(/FROM "meetings"/).grep_v(/COUNT/i)).to be_empty+ end+it 'scales: more rows do not mean more queries' dopat = token_for(reader)count = lambda do@@ -289,10 +336,11 @@ RSpec.describe 'REST meetings', :ci_guard, type: :request doit 'answers the row, the participants by name, the texts whole, updated_at and the path' doquietly do+ # Row order: not the order of creation here, not the alphabet.create(:meeting_participant, meeting: held, organisation: organisation, display_name: 'Anna Albers',- created_at: 2.minutes.ago)+ created_at: 1.minute.ago)create(:meeting_participant, meeting: held, organisation: organisation, display_name: 'Ben Berger',- user: creator, created_at: 1.minute.ago)+ user: creator, created_at: 2.minutes.ago)endexpect(show(held.id)).to have_http_status(:ok)@@ -300,7 +348,7 @@ RSpec.describe 'REST meetings', :ci_guard, type: :request do'id' => held.id, 'project_id' => project.id, 'title' => 'Kickoff','occurred_at' => held.occurred_at.iso8601, 'duration_minutes' => 30,'creator' => { 'id' => creator.id, 'name' => 'Clara Creator' },- 'participants' => [{ 'display_name' => 'Anna Albers' }, { 'display_name' => 'Ben Berger' }],+ 'participants' => [{ 'display_name' => 'Ben Berger' }, { 'display_name' => 'Anna Albers' }],'generated_summary' => '**Head:** done', 'notes' => 'Some notes', 'transcript' => 'Anna: hello','updated_at' => held.reload.updated_at.iso8601,'path' => "/org/#{organisation.id}/projects/#{project.id}/meetings/#{held.id}"@@ -430,12 +478,46 @@ RSpec.describe 'REST meetings', :ci_guard, type: :request doexpect(show(held.id, user: account_admin)).to have_http_status(:ok)end- it 'follows a meeting that moved: the reach of its project now, not of the old one' do- target = new_project- quietly { held.update!(project: target) }+ # The reader may read both projects, so the token alone stands between them.+ describe 'a meeting that moved' do+ let(:target) { new_project }+ let(:pat) { token_for(reader, project_scopes: { organisation => [project] }) }++ before { quietly { create(:project_permission, user: reader, project: target, meetings_access: 'read_only') } }++ it 'answers by the reach of its project now, not of the old one' do+ quietly { held.update!(project: target) }++ expect(show(held.id, pat: pat)).to have_http_status(:not_found)+ expect(response.body).to eq(not_found_body)+ end++ it 'is gone from the project whose reach was checked when it moves during the read' do+ held+ pat+ allow_any_instance_of(PersonalAccessToken).to receive(:accessible_project?).and_wrap_original do |original, *args|+ original.call(*args).tap { held.update_columns(project_id: target.id) }+ end++ expect(show(held.id, pat: pat)).to have_http_status(:not_found)+ expect(response.body).to eq(not_found_body)+ end+ end++ it 'reads a meeting of a second organisation with a token that reaches every organisation' do+ second = create(:organisation)+ place = new_project(second)+ ActsAsTenant.with_tenant(second) do+ Prosopite.pause do+ create(:membership, user: reader, organisation: second, role: create(:role, organisation: second), active: true)+ create(:project_permission, user: reader, project: place, meetings_access: 'read_only')+ end+ end+ found = meeting(in_project: place)+ quietly { create(:meeting, project: project, organisation: organisation, creator: creator) }- expect(show(held.id, pat: token_for(reader, project_scopes: { organisation => [project] })))- .to have_http_status(:not_found)+ expect(show(found.id, pat: token_for(reader, all_organisations: true, organisations: []))).to have_http_status(:ok)+ expect(response.parsed_body.dig('data', 'id')).to eq(found.id)endendend