Skip to content

Commit

Permalink
Merged r6073 from trunk.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@6162 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed Jul 3, 2011
1 parent 97b697a commit 30255b8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/repositories_controller.rb
Expand Up @@ -208,7 +208,7 @@ def diff
User.current.preference.save
end
@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)
@diff = @repository.diff(@path, @rev, @rev_to)
show_error_not_found unless @diff
Expand Down
31 changes: 31 additions & 0 deletions test/functional/repositories_git_controller_test.rb
Expand Up @@ -48,6 +48,8 @@ def setup
if @char_1.respond_to?(:force_encoding)
@char_1.force_encoding('UTF-8')
end

Setting.default_language = 'en'
end

if File.directory?(REPOSITORY_PATH)
Expand Down Expand Up @@ -204,6 +206,27 @@ def test_diff
assert_tag :tag => 'h2', :content => /2f9c0091/
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
@repository.fetch_changesets
@repository.reload
Expand Down Expand Up @@ -336,4 +359,12 @@ def puts_ruby19_non_utf8_pass
puts "Git test repository NOT FOUND. Skipping functional tests !!!"
def test_fake; assert true 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

0 comments on commit 30255b8

Please sign in to comment.