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.

fix(meetings): draw no dialog of a meeting moved right after a refused correction

Guido Boyked15446bce9f0
diff --git a/app/controllers/organisations/meeting_term_corrections_controller.rb b/app/controllers/organisations/meeting_term_corrections_controller.rb
index 507b4d0..043c2af 100644
--- a/app/controllers/organisations/meeting_term_corrections_controller.rb
+++ b/app/controllers/organisations/meeting_term_corrections_controller.rb
@@ -138,10 +138,17 @@ module Organisations
end
# The dialog again, in place of the opening that sent it, with what was
- # typed, counted against the transcript stored now.
+ # typed, counted against the transcript stored now. Read again after a
+ # refusal of the actor inside this project only: a move or a delete that
+ # committed right after it leaves nothing to draw here.
def refused(errors: [], notice: nil, reload: false)
- @meeting.reload if reload
- @dialog = build_dialog(heard: heard_param) if reload
+ if reload
+ @meeting = @project.meetings.find_by(id: @meeting.id)
+ @participants = nil
+ return render_not_found unless @meeting
+
+ @dialog = build_dialog(heard: heard_param)
+ end
@errors = errors
@notice = notice
@fields = correction_fields
diff --git a/spec/requests/organisations/meeting_term_corrections_spec.rb b/spec/requests/organisations/meeting_term_corrections_spec.rb
index d3ee917..020059d 100644
--- a/spec/requests/organisations/meeting_term_corrections_spec.rb
+++ b/spec/requests/organisations/meeting_term_corrections_spec.rb
@@ -284,6 +284,24 @@ RSpec.describe 'Organisations::MeetingTermCorrections', :ci_guard, type: :reques
expect(TermCorrection.count).to eq(0)
end
+ # The transcript changed under the correction (the actor's digest check),
+ # and the meeting moved into another project right after: the dialog is not
+ # drawn again from a meeting this request was never checked for.
+ it 'answers 404 when the meeting moved after a refusal that would count again' do
+ sign_in writer('manage_glossary')
+ elsewhere = create(:project, organisation: organisation)
+ allow_any_instance_of(Actors::CorrectMeetingTerm).to receive(:call) do
+ Meeting.where(id: meeting.id).update_all(project_id: elsewhere.id)
+ Actors::BaseActor::Result.new(success: false, errors: ['geändert'], code: :stale_transcript)
+ end
+
+ post_correction
+
+ expect(response).to have_http_status(:not_found)
+ expect(response.body).to include(%(<turbo-stream action="remove" target="meeting-term-correction-modal-#{meeting.id}-#{modal_token}">))
+ expect(response.body).not_to include('Lalabeis kann viel')
+ end
+
it 'shows the dialog again with the reason for a refused correction' do
sign_in writer('manage_glossary')
post_correction(correct: ' ')