@@ -117,8 +117,8 class RepositoriesController < ApplicationController | |||||
117 |
|
117 | |||
118 | @content = @repository.cat(@path, @rev) |
|
118 | @content = @repository.cat(@path, @rev) | |
119 | show_error_not_found and return unless @content |
|
119 | show_error_not_found and return unless @content | |
120 | if 'raw' == params[:format] || @content.is_binary_data? |
|
120 | if 'raw' == params[:format] || @content.is_binary_data? || (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte) | |
121 |
# Force the download |
|
121 | # Force the download | |
122 | send_data @content, :filename => @path.split('/').last |
|
122 | send_data @content, :filename => @path.split('/').last | |
123 | else |
|
123 | else | |
124 | # Prevent empty lines when displaying a file with Windows style eol |
|
124 | # Prevent empty lines when displaying a file with Windows style eol |
@@ -94,6 +94,16 class RepositoriesSubversionControllerTest < Test::Unit::TestCase | |||||
94 | assert_response :success |
|
94 | assert_response :success | |
95 | assert_template 'entry' |
|
95 | assert_template 'entry' | |
96 | end |
|
96 | end | |
|
97 | ||||
|
98 | def test_entry_should_send_if_too_big | |||
|
99 | # no files in the test repo is larger than 1KB... | |||
|
100 | with_settings :file_max_size_displayed => 0 do | |||
|
101 | get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'] | |||
|
102 | assert_response :success | |||
|
103 | assert_template '' | |||
|
104 | assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] | |||
|
105 | end | |||
|
106 | end | |||
97 |
|
107 | |||
98 | def test_entry_at_given_revision |
|
108 | def test_entry_at_given_revision | |
99 | get :entry, :id => 1, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 |
|
109 | get :entry, :id => 1, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 | |
@@ -113,6 +123,8 class RepositoriesSubversionControllerTest < Test::Unit::TestCase | |||||
113 | def test_entry_download |
|
123 | def test_entry_download | |
114 | get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' |
|
124 | get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' | |
115 | assert_response :success |
|
125 | assert_response :success | |
|
126 | assert_template '' | |||
|
127 | assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] | |||
116 | end |
|
128 | end | |
117 |
|
129 | |||
118 | def test_directory_entry |
|
130 | def test_directory_entry |
@@ -64,4 +64,11 class Test::Unit::TestCase | |||||
64 | Dir.mkdir "#{RAILS_ROOT}/tmp/test/attachments" unless File.directory?("#{RAILS_ROOT}/tmp/test/attachments") |
|
64 | Dir.mkdir "#{RAILS_ROOT}/tmp/test/attachments" unless File.directory?("#{RAILS_ROOT}/tmp/test/attachments") | |
65 | Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments" |
|
65 | Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments" | |
66 | end |
|
66 | end | |
|
67 | ||||
|
68 | def with_settings(options, &block) | |||
|
69 | saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].dup; h} | |||
|
70 | options.each {|k, v| Setting[k] = v} | |||
|
71 | yield | |||
|
72 | saved_settings.each {|k, v| Setting[k] = v} | |||
|
73 | end | |||
67 | end |
|
74 | end |
General Comments 0
You need to be logged in to leave comments.
Login now