Skip to content

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.

Pin the panel's decisions that mutations showed unguarded

Guido Boyke642884d5a7b0
diff --git a/spec/requests/organisations/ticket_meeting_panel_spec.rb b/spec/requests/organisations/ticket_meeting_panel_spec.rb
index b0e874b..36f4c12 100644
--- a/spec/requests/organisations/ticket_meeting_panel_spec.rb
+++ b/spec/requests/organisations/ticket_meeting_panel_spec.rb
@@ -75,6 +75,8 @@ RSpec.describe 'Ticket meeting panel', :ci_guard, type: :request do
'Transcript-Body-QX')
expect(frame_element.at_css('[data-controller~="ticket-meeting-panel"]')['data-ticket-meeting-panel-ticket-id-value'])
.to eq(ticket.id)
+ # A fragment for the frame, not a page around it.
+ expect(response.body).not_to match(/<html/i)
end
it 'is read only: no form, no edit, delete, analyses, suggestions or assistant entry point' do
@@ -234,6 +236,18 @@ RSpec.describe 'Ticket meeting panel', :ci_guard, type: :request do
expect(document.text).to include('Ticket-With-Meetings')
end
+ it 'lists the linked tickets oldest link first' do
+ ActsAsTenant.with_tenant(organisation) do
+ Reference.where(source: meeting, target: sibling).update_all(created_at: 2.hours.ago)
+ end
+ sign_in reader
+ panel
+
+ titles = Nokogiri::HTML(response.body).css('section li').map { |item| item.text.squish }
+ expect(titles.index { |text| text.include?('Sibling-QX') })
+ .to be < titles.index { |text| text.include?('Ticket-With-Meetings') }
+ end
+
it 'hides a linked ticket the reader may not read' do
sign_in reader
panel
@@ -260,6 +274,33 @@ RSpec.describe 'Ticket meeting panel', :ci_guard, type: :request do
expect(response).to have_http_status(:not_found)
expect(response.body).to include('turbo-frame id="ticket_meeting_panel"', unavailable_text)
expect(response.body).not_to include('Hidden-QX')
+ expect(response.body).not_to match(/<html/i)
+ end
+
+ # The ticket comes from the project of the address, not from anywhere the reader may look.
+ it 'is a 404 for the ticket under the address of another project' do
+ meeting
+ other_project = ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation) }
+ user = reader
+ grant(user, other_project, tickets_access: 'read_only', meetings_access: 'read_only')
+ sign_in user
+ panel(project_id: other_project.id)
+
+ expect_unavailable
+ end
+
+ # Two locks: the scope finds the meeting, and MeetingPolicy#show? is asked as well.
+ # They answer alike today; this keeps the second one from going as redundant.
+ it 'shows nothing when MeetingPolicy#show? refuses a meeting the scope found' do
+ meeting
+ allow(MeetingPolicy).to receive(:new).and_wrap_original do |original, *args|
+ original.call(*args).tap { |policy| allow(policy).to receive(:show?).and_return(false) }
+ end
+ sign_in reader
+ panel
+
+ expect(response).not_to have_http_status(:ok)
+ expect(response.body).not_to include('Hidden-QX')
end
it 'is a 404 for a meeting that does not link to the ticket' do
@@ -381,6 +422,15 @@ RSpec.describe 'Ticket meeting panel', :ci_guard, type: :request do
expect(response.body).to include('Before-Move-QX')
expect(response.body).to include(organisation_project_meetings_path(organisation, project, meeting_id: meeting.id))
end
+
+ it "sends a request outside the frame to the meeting's page in the meeting's project" do
+ user = member(meetings_access: 'read_only')
+ grant(user, project_b, tickets_access: 'read_only')
+ sign_in user
+ panel(project_id: project_b.id, headers: {})
+
+ expect(response).to redirect_to(organisation_project_meetings_path(organisation, project, meeting_id: meeting.id))
+ end
end
describe 'a request that is not for the panel frame' do
@@ -414,8 +464,10 @@ RSpec.describe 'Ticket meeting panel', :ci_guard, type: :request do
sign_in reader
panel(meeting_id: SecureRandom.uuid, headers: {})
- # The test environment's 404 page prints the spec source; the status is the answer.
+ # The test environment's 404 page prints the spec source, as text: an element is
+ # what tells the frame's answer from the application's.
expect(response).to have_http_status(:not_found)
+ expect(Nokogiri::HTML(response.body).at_css('turbo-frame#ticket_meeting_panel')).to be_nil
end
end
diff --git a/spec/requests/organisations/ticket_meeting_references_access_spec.rb b/spec/requests/organisations/ticket_meeting_references_access_spec.rb
index 1357de8..c252ff1 100644
--- a/spec/requests/organisations/ticket_meeting_references_access_spec.rb
+++ b/spec/requests/organisations/ticket_meeting_references_access_spec.rb
@@ -120,6 +120,15 @@ RSpec.describe 'Ticket meeting references after a move', :ci_guard, type: :reque
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
+
+ # The panel beside the ticket is addressed through the ticket, which now lives in B.
+ it "opens the panel under the ticket's project B" do
+ sign_in viewer
+ body = ticket_page
+
+ expect(body).to include(organisation_project_ticket_meeting_panel_path(organisation, project_b, ticket, meeting_id: meeting.id))
+ expect(body).not_to include(organisation_project_ticket_meeting_panel_path(organisation, project_a, ticket, meeting_id: meeting.id))
+ end
end
context 'viewer reads meetings in both projects' do
@@ -232,4 +241,33 @@ RSpec.describe 'Ticket meeting references after a move', :ci_guard, type: :reque
end
end
end
+
+ # A linked ticket that stayed in the meeting's project, for a reader of the meetings
+ # there who may not read its tickets: the title it has now (it is no news in a project
+ # the reader belongs to), without a link.
+ describe "the meeting's linked ticket that stayed in its project" do
+ let(:stayed) do
+ ActsAsTenant.with_tenant(organisation) do
+ create(:ticket, project: project_a, organisation: organisation, creator: creator, title: 'Stayed ticket')
+ end
+ end
+
+ before do
+ ActsAsTenant.with_tenant(organisation) do
+ meeting.outgoing_references.create!(organisation: organisation, target: stayed,
+ target_title_snapshot: stayed.display_title)
+ stayed.update!(title: 'Renamed-in-A-QV')
+ end
+ end
+
+ it 'shows its current title, without a link' do
+ viewer = member.tap { |user| grant(user, project_a, meetings_access: 'read_only') }
+ sign_in viewer
+ get organisation_project_meeting_path(organisation, project_a, meeting)
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('Renamed-in-A-QV')
+ expect(response.body).not_to include("ticket_id=#{stayed.id}")
+ end
+ end
end
diff --git a/spec/services/tickets/linked_meetings_spec.rb b/spec/services/tickets/linked_meetings_spec.rb
index 3cdb1bc..a662a14 100644
--- a/spec/services/tickets/linked_meetings_spec.rb
+++ b/spec/services/tickets/linked_meetings_spec.rb
@@ -37,6 +37,18 @@ RSpec.describe Tickets::LinkedMeetings do
expect(described_class.call(ticket: ticket, user: reader)).to be_empty
end
+ it 'names no meeting for a ticket without links, while meetings link to other tickets' do
+ other = ActsAsTenant.with_tenant(organisation) do
+ create(:ticket, project: project, organisation: organisation, creator: creator)
+ end
+ ActsAsTenant.with_tenant(organisation) do
+ create(:meeting, project: project, organisation: organisation, creator: creator)
+ .outgoing_references.create!(organisation: organisation, target: other, target_title_snapshot: other.display_title)
+ end
+
+ expect(described_class.call(ticket: ticket, user: reader)).to be_empty
+ end
+
it 'lists the linking meetings oldest link first, whatever their own dates' do
later = meeting_linked_at(1.hour.ago, 'Linked second')
earlier = meeting_linked_at(2.hours.ago, 'Linked first')