Commit 9027d365 authored by jplang's avatar jplang

Unified diff link broken on specific file/revision diff view (#30850).

git-svn-id: https://svn.redmine.org/redmine/trunk@17962 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 5856e15e
......@@ -252,7 +252,7 @@ Rails.application.routes.draw do
get "projects/:id/repository/:repository_id/revisions/:rev/#{action}(/*path)",
:controller => 'repositories',
:action => action,
:format => 'html',
:format => false,
:constraints => {:rev => /[a-z0-9\.\-_]+/, :path => /.*/}
end
......@@ -260,7 +260,7 @@ Rails.application.routes.draw do
get "projects/:id/repository/:repository_id/#{action}(/*path)",
:controller => 'repositories',
:action => action,
:format => 'html',
:format => false,
:constraints => {:path => /.*/}
end
......
......@@ -26,6 +26,7 @@ class RepositoriesGitTest < Redmine::IntegrationTest
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
PRJ_ID = 3
NUM_REV = 28
def setup
User.current = nil
......@@ -48,5 +49,37 @@ class RepositoriesGitTest < Redmine::IntegrationTest
get "/projects/subproject1/repository/#{@repository.id}/diff?rev=61b685fbe&rev_to=2f9c0091"
assert_response :success
end
def test_get_raw_diff_of_a_whole_revision
@repository.fetch_changesets
assert_equal NUM_REV, @repository.changesets.count
get "/projects/subproject1/repository/#{@repository.id}/revisions/deff712f05a90d96edbd70facc47d944be5897e3/diff"
assert_response :success
assert a = css_select("a.diff").first
assert_equal 'Unified diff', a.text
get a['href']
assert_response :success
assert_match /\Acommit deff712f05a90d96edbd70facc47d944be5897e3/, response.body
end
def test_get_raw_diff_of_a_single_file_change
@repository.fetch_changesets
assert_equal NUM_REV, @repository.changesets.count
get "/projects/subproject1/repository/#{@repository.id}/revisions/deff712f05a90d96edbd70facc47d944be5897e3/diff/sources/watchers_controller.rb"
assert_response :success
assert a = css_select("a.diff").first
assert_equal 'Unified diff', a.text
get a['href']
assert_response :success
assert_match /\Acommit deff712f05a90d96edbd70facc47d944be5897e3/, response.body
end
else
puts "Git test repository NOT FOUND. Skipping integration tests !!!"
def test_fake; assert true end
end
end
......@@ -53,24 +53,24 @@ class RoutingRepositoriesTest < Redmine::RoutingTest
should_route 'GET /projects/foo/repository/foo/revisions.atom' => 'repositories#revisions', :id => 'foo', :repository_id => 'foo', :format => 'atom'
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', :format => 'html'
should_route 'GET /projects/foo/repository/foo/revisions/2457/show' => 'repositories#show', :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'
%w(show diff entry raw annotate).each do |action|
@paths.each do |path|
should_route "GET /projects/foo/repository/foo/revisions/2457/#{action}/#{path}" => "repositories##{action}",
:id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path, :format => 'html'
:id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path
end
end
end
def test_repositories_non_revisions_path_with_repository_id
should_route 'GET /projects/foo/repository/svn/changes' => 'repositories#changes', :id => 'foo', :repository_id => 'svn', :format => 'html'
should_route 'GET /projects/foo/repository/svn/changes' => 'repositories#changes', :id => 'foo', :repository_id => 'svn'
%w(changes diff browse entry raw annotate).each do |action|
@paths.each do |path|
should_route "GET /projects/foo/repository/svn/#{action}/#{path}" => "repositories##{action}",
:id => 'foo', :repository_id => 'svn', :path => path, :format => 'html'
:id => 'foo', :repository_id => 'svn', :path => path
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment