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 what the ticket changes endpoint does with odd bodies
Guido Boykea18a39c8536c
diff --git a/spec/requests/api/v1/ticket_changes_side_effects_spec.rb b/spec/requests/api/v1/ticket_changes_side_effects_spec.rbindex 3a195d8..2cab523 100644--- a/spec/requests/api/v1/ticket_changes_side_effects_spec.rb+++ b/spec/requests/api/v1/ticket_changes_side_effects_spec.rb@@ -110,6 +110,12 @@ RSpec.describe 'REST ticket changes: side effects equal the MCP write', :ci_guarProsopite.pause { ActsAsTenant.without_tenant { tickets.map { |ticket| yield ticket.reload } } }end+ it 'runs both surfaces through the one rule' do+ expect(Tickets::Change).to receive(:parse).twice.and_call_original++ compare({ status: 'wip' })+ end+it 'changes the status with the same trail, once' dorest, mcp, rest_ticket, mcp_ticket = compare({ status: 'wip' })diff --git a/spec/requests/api/v1/ticket_changes_spec.rb b/spec/requests/api/v1/ticket_changes_spec.rbindex 2c57d30..ec0074d 100644--- a/spec/requests/api/v1/ticket_changes_spec.rb+++ b/spec/requests/api/v1/ticket_changes_spec.rb@@ -303,6 +303,12 @@ RSpec.describe 'API V1 ticket changes', :ci_guard, type: :request doendend+ # Rails drops a JSON null from a list before the rule sees it: it names nobody.+ it 'reads a list of nulls as naming nobody' do+ send_change({ add_assignee_ids: [nil] })+ expect_invalid_input('Name at least one user in add_assignee_ids or remove_assignee_ids.')+ end+it 'refuses a person the project does not offer loudly, and takes nobody off' doassign(colleague)before = written@@ -481,6 +487,26 @@ RSpec.describe 'API V1 ticket changes', :ci_guard, type: :request doendend+ it 'refuses a file in place of a title' do+ upload = Rack::Test::UploadedFile.new(Rails.root.join('spec/fixtures/files/test_file.txt'), 'text/plain')+ before = written+ post "/api/v1/tickets/#{ticket.id}/changes", params: { change: { title: upload } }, headers: headers(json: false)++ expect_invalid_input('Give the title (change[title]) as text.')+ expect(written).to eq(before)+ end++ # The body is read before any lookup, so it cannot tell a ticket from no ticket.+ it 'answers a body that is no JSON with a 400, the same for a missing ticket' do+ change_raw('{"change":')+ first = [response.status, response.body]+ change_raw('{"change":', ticket_id: SecureRandom.uuid)++ expect(response).to have_http_status(:bad_request)+ expect(body).to include('error' => 'bad_request', 'code' => 'invalid_input')+ expect([response.status, response.body]).to eq(first)+ end+it 'takes a multipart part in UTF-8' dochange_multipart('title', 'text/plain; charset=utf-8', 'Müller')diff --git a/spec/services/tickets/change_spec.rb b/spec/services/tickets/change_spec.rbindex 7462997..8f309bd 100644--- a/spec/services/tickets/change_spec.rb+++ b/spec/services/tickets/change_spec.rb@@ -210,8 +210,10 @@ RSpec.describe Tickets::Change, :ci_guard doendend- it 'holds no refusal outside REFUSALS' do- expect(%i[unknown_keys invalid_utf8 one_kind status_not_string assignees_overlap] - described_class::REFUSALS).to be_empty+ # REFUSALS is the list the surfaces word; a refusal outside it raises there.+ it 'lists every refusal it answers' do+ source = Rails.root.join('app/services/tickets/change.rb').read+ expect(source.scan(/refuse\(:(\w+)/).flatten.map(&:to_sym) - described_class::REFUSALS).to be_emptyendend@@ -289,8 +291,12 @@ RSpec.describe Tickets::Change, :ci_guard doendend- it 'reads a save the model refuses as a ticket not saved, without the board text' do- allow(Actors::ApplyTicketChanges).to receive(:call).and_return(actor_failure(:validation_failed, errors: ['Kartentext']))+ # Only a title hands on what the model said: for a field the actor has a+ # generic board text, whatever its record holds.+ it 'reads a save the model refuses as a ticket not saved, without any messages' do+ run = TicketBulkRun.new.tap { |record| record.errors.add(:base, 'Kartentext') }+ allow(Actors::ApplyTicketChanges).to receive(:call)+ .and_return(actor_failure(:validation_failed, errors: ['Kartentext'], resource: run))expect(write({ status: 'wip' })).to have_attributes(failure: :ticket_not_saved, reason: :validation_failed, messages: [])end