From a9b7f12900ff7811d056a848fd90df50e57767f6 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Tue, 26 Dec 2023 15:47:43 +0000 Subject: [PATCH] Fixes that diff of a javascript file in repository module is not displayed with layout in Rails 7.1 (#39747, #36320). git-svn-id: https://svn.redmine.org/redmine/trunk@22563 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/repositories/diff.html.erb | 2 +- config/routes.rb | 9 +++++---- test/integration/routing/repositories_test.rb | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/views/repositories/diff.html.erb b/app/views/repositories/diff.html.erb index 3dcc0fdc7..3551c38c4 100644 --- a/app/views/repositories/diff.html.erb +++ b/app/views/repositories/diff.html.erb @@ -48,7 +48,7 @@ <% end -%> <% other_formats_links do |f| %> - <%= f.link_to_with_query_parameters 'Diff', {}, :caption => 'Unified diff' %> + <%= f.link_to_with_query_parameters 'Diff', { path: nil }, :caption => 'Unified diff' %> <% end %> <% html_title(with_leading_slash(@path), 'Diff') -%> diff --git a/config/routes.rb b/config/routes.rb index 12be7b3ec..15aa87de4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -299,12 +299,13 @@ Rails.application.routes.draw do get "projects/:id/repository/:repository_id/revisions/:rev/diff(/*path)", :to => 'repositories#diff', - :format => false, - :constraints => {:rev => /[a-z0-9\.\-_]+/, :path => /.*/} + :format => 'html', + :constraints => {:rev => /[a-z0-9\.\-_]+/, :path => /.*/, format: /(html|diff)/ } + get "projects/:id/repository/:repository_id/diff(/*path)", :to => 'repositories#diff', - :format => false, - :constraints => {:path => /.*/} + :format => 'html', + :constraints => {:path => /.*/, format: /(html|diff)/ } get 'projects/:id/repository/:repository_id/show/*path', :to => 'repositories#show', :format => 'html', :constraints => {:path => /.*/} diff --git a/test/integration/routing/repositories_test.rb b/test/integration/routing/repositories_test.rb index f0d2e9cdb..5b1a4aa74 100644 --- a/test/integration/routing/repositories_test.rb +++ b/test/integration/routing/repositories_test.rb @@ -56,7 +56,7 @@ class RoutingRepositoriesTest < Redmine::RoutingTest should_route 'GET /projects/foo/repository/foo/revisions/2457' => 'repositories#revision', :id => 'foo', :repository_id => 'foo', :rev => '2457' should_route 'GET /projects/foo/repository/foo/revisions/2457/show' => 'repositories#show', :id => 'foo', :repository_id => 'foo', :rev => '2457', :format => 'html' - should_route 'GET /projects/foo/repository/foo/revisions/2457/diff' => 'repositories#diff', :id => 'foo', :repository_id => 'foo', :rev => '2457' + should_route 'GET /projects/foo/repository/foo/revisions/2457/diff' => 'repositories#diff', :id => 'foo', :repository_id => 'foo', :rev => '2457', :format => 'html' %w(show entry raw annotate).each do |action| @paths.each do |path| @@ -66,7 +66,7 @@ class RoutingRepositoriesTest < Redmine::RoutingTest end @paths.each do |path| should_route "GET /projects/foo/repository/foo/revisions/2457/diff/#{path}" => "repositories#diff", - :id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path + :id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path, :format => 'html' end end @@ -85,7 +85,7 @@ class RoutingRepositoriesTest < Redmine::RoutingTest end @paths.each do |path| should_route "GET /projects/foo/repository/svn/diff/#{path}" => "repositories#diff", - :id => 'foo', :repository_id => 'svn', :path => path + :id => 'foo', :repository_id => 'svn', :path => path, :format => 'html' end end -- 2.39.5