Project

General

Profile

Defect #42875 ยป 42875.patch

Go MAEDA, 2025-06-16 12:04

View differences:

config/boot.rb
1 1
# frozen_string_literal: true
2 2

  
3
# Rack 3.1.14 or later limits query parameters to 4096 by default, which can
4
# prevent saving workflows with many statuses.
5
# Setting RACK_QUERY_PARSER_PARAMS_LIMIT to 65536 allows handling up to
6
# approximately 100 statuses.
7
#
8
# See also:
9
# - https://www.redmine.org/issues/42875
10
# - https://github.com/rack/rack/blob/v3.1.16/README.md#configuration
11
ENV['RACK_QUERY_PARSER_PARAMS_LIMIT'] ||= '65536'
12

  
3 13
# Set up gems listed in the Gemfile.
4 14
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5 15

  
test/functional/workflows_controller_test.rb
211 211
    assert w.assignee
212 212
  end
213 213

  
214
  def test_post_edit_with_large_number_of_statuses
215
    # This test ensures that workflows with many statuses can be saved.
216
    # Without setting `ENV['RACK_QUERY_PARSER_PARAMS_LIMIT']`, this raises
217
    # ActionController::BadRequest exception due to exceeding the default
218
    # query parameter limit of 4096.
219
    WorkflowTransition.delete_all
220

  
221
    num_statuses = 40
222
    transitions_data = {}
223

  
224
    # Allowed statuses for a new issue (status_id = 0)
225
    transitions_data['0'] = {}
226
    (1..num_statuses).each do |status_id|
227
      transitions_data['0'][status_id.to_s] = {'always' => '1'}
228
    end
229

  
230
    # Status transitions between statuses
231
    (1..num_statuses).each do |status_id_from| # rubocop:disable RuboCopStyle/CombinableLoops
232
      transitions_data[status_id_from.to_s] = {}
233
      (1..num_statuses).each do |status_id_to|
234
        # skip self-transitions
235
        next if status_id_from == status_id_to
236

  
237
        transitions_data[status_id_from.to_s][status_id_to.to_s] = {
238
          'always' => '1', 'author' => '1', 'assignee' => '1'
239
        }
240
      end
241
    end
242

  
243
    assert_nothing_raised do
244
      patch :update, :params => {
245
        :role_id => 2,
246
        :tracker_id => 1,
247
        :transitions => transitions_data
248
      }
249
    end
250
    assert_response :found
251
  end
252

  
214 253
  def test_get_permissions
215 254
    get :permissions
216 255

  
    (1-1/1)