Do not cache I18n strings when truncating a long diff (#5089).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6073 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
22de20fe61
commit
115d227298
|
@ -208,7 +208,7 @@ class RepositoriesController < ApplicationController
|
||||||
User.current.preference.save
|
User.current.preference.save
|
||||||
end
|
end
|
||||||
@cache_key = "repositories/diff/#{@repository.id}/" +
|
@cache_key = "repositories/diff/#{@repository.id}/" +
|
||||||
Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")
|
Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}")
|
||||||
unless read_fragment(@cache_key)
|
unless read_fragment(@cache_key)
|
||||||
@diff = @repository.diff(@path, @rev, @rev_to)
|
@diff = @repository.diff(@path, @rev, @rev_to)
|
||||||
show_error_not_found unless @diff
|
show_error_not_found unless @diff
|
||||||
|
|
|
@ -56,6 +56,8 @@ class RepositoriesGitControllerTest < ActionController::TestCase
|
||||||
if @char_1.respond_to?(:force_encoding)
|
if @char_1.respond_to?(:force_encoding)
|
||||||
@char_1.force_encoding('UTF-8')
|
@char_1.force_encoding('UTF-8')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Setting.default_language = 'en'
|
||||||
end
|
end
|
||||||
|
|
||||||
if File.directory?(REPOSITORY_PATH)
|
if File.directory?(REPOSITORY_PATH)
|
||||||
|
@ -219,6 +221,27 @@ class RepositoriesGitControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_diff_truncated
|
||||||
|
@repository.fetch_changesets
|
||||||
|
@repository.reload
|
||||||
|
Setting.diff_max_lines_displayed = 5
|
||||||
|
|
||||||
|
# Truncated diff of changeset 2f9c0091
|
||||||
|
with_cache do
|
||||||
|
get :diff, :id => PRJ_ID, :type => 'inline',
|
||||||
|
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||||
|
assert_response :success
|
||||||
|
assert @response.body.include?("... This diff was truncated")
|
||||||
|
|
||||||
|
Setting.default_language = 'fr'
|
||||||
|
get :diff, :id => PRJ_ID, :type => 'inline',
|
||||||
|
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||||
|
assert_response :success
|
||||||
|
assert ! @response.body.include?("... This diff was truncated")
|
||||||
|
assert @response.body.include?("... Ce diff")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_diff_two_revs
|
def test_diff_two_revs
|
||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@repository.reload
|
@repository.reload
|
||||||
|
@ -361,4 +384,12 @@ class RepositoriesGitControllerTest < ActionController::TestCase
|
||||||
puts "Git test repository NOT FOUND. Skipping functional tests !!!"
|
puts "Git test repository NOT FOUND. Skipping functional tests !!!"
|
||||||
def test_fake; assert true end
|
def test_fake; assert true end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def with_cache(&block)
|
||||||
|
before = ActionController::Base.perform_caching
|
||||||
|
ActionController::Base.perform_caching = true
|
||||||
|
block.call
|
||||||
|
ActionController::Base.perform_caching = before
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue