Project

General

Profile

Defect #40208 » fix_robots_route.patch

Liane Hampe, 2024-02-07 13:21

View differences:

config/routes.rb
405 405

  
406 406
  match 'uploads', :to => 'attachments#upload', :via => :post
407 407

  
408
  get 'robots', :to => 'welcome#robots'
408
  get 'robots', :to => 'welcome#robots', :defaults => { format: 'txt' }
409 409

  
410 410
  Redmine::Plugin.directory.glob("*/config/routes.rb").sort.each do |plugin_routes_path|
411 411
    instance_eval(plugin_routes_path.read, plugin_routes_path.to_s)
test/integration/routing/welcome_test.rb
22 22
class RoutingWelcomeTest < Redmine::RoutingTest
23 23
  def test_welcome
24 24
    should_route 'GET /' => 'welcome#index'
25
    should_route 'GET /robots.txt' => 'welcome#robots', :format => 'txt'
25
    should_route 'GET /robots' => 'welcome#robots', :format => 'txt'
26 26
  end
27 27
end
test/integration/welcome_test.rb
43 43
    assert @response.body.match(%r{^Disallow: /projects/subproject1/issues\r?$})
44 44
  end
45 45

  
46
  def test_robots_when_no_format_is_given
47
    get '/robots'
48
    assert_response :success
49
    assert_equal 'text/plain', @response.media_type
50
  end
51

  
46 52
  def test_robots_when_login_is_required
47 53
    with_settings :login_required => '1' do
48 54
      get '/robots.txt'
(1-1/2)