Index: app/models/attachment.rb =================================================================== --- app/models/attachment.rb (revision 17462) +++ app/models/attachment.rb (working copy) @@ -235,7 +235,8 @@ end def is_text? - Redmine::MimeType.is_type?('text', filename) + Redmine::MimeType.is_type?('text', filename) || + ! Redmine::Utils.binary?(File.read(diskfile, 4096)) rescue false end def is_image? Index: app/views/projects/settings/_versions.html.erb =================================================================== --- app/views/projects/settings/_versions.html.erb (revision 17467) +++ app/views/projects/settings/_versions.html.erb (working copy) @@ -16,7 +16,6 @@ - @@ -28,7 +27,6 @@ <% @versions.sort.each do |version| %> - Index: lib/redmine/scm/adapters/abstract_adapter.rb =================================================================== --- lib/redmine/scm/adapters/abstract_adapter.rb (revision 17462) +++ lib/redmine/scm/adapters/abstract_adapter.rb (working copy) @@ -425,9 +425,7 @@ module ScmData def self.binary?(data) - unless data.empty? - data.count( "^ -~", "^\r\n" ).fdiv(data.size) > 0.3 || data.index( "\x00" ) - end + Redmine::Utils.binary?(data) end end end Index: lib/redmine/utils.rb =================================================================== --- lib/redmine/utils.rb (revision 17462) +++ lib/redmine/utils.rb (working copy) @@ -61,6 +61,12 @@ end end end + + def binary?(data) + unless data.empty? + data.count( "^ -~", "^\r\n" ).fdiv(data.size) > 0.3 || data.index( "\x00" ) + end + end end module Shell Index: test/fixtures/files/hello.go =================================================================== --- test/fixtures/files/hello.go (nonexistent) +++ test/fixtures/files/hello.go (working copy) @@ -0,0 +1,14 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello, world!") +} +package main + +import "fmt" + +func main() { + fmt.Println("Hello, world!") +} Index: test/functional/my_controller_test.rb =================================================================== --- test/functional/my_controller_test.rb (revision 17465) +++ test/functional/my_controller_test.rb (working copy) @@ -208,7 +208,7 @@ assert_select 'div#block-activity' do assert_select 'h3' do - assert_select 'a[href=?]', activity_path(from: Date.current, user_id: user.id), :text => 'Activity' + assert_select 'a[href=?]', activity_path(from: Date.today, user_id: user.id), :text => 'Activity' end assert_select 'div#activity' do assert_select 'dt', 10 Index: test/functional/projects_controller_test.rb =================================================================== --- test/functional/projects_controller_test.rb (revision 17467) +++ test/functional/projects_controller_test.rb (working copy) @@ -641,27 +641,6 @@ assert_select 'a#tab-versions[href=?]', '/projects/ecookbook/settings/versions?version_name=.1&version_status=' end - def test_settings_should_show_default_version_in_versions_tab - project = Project.find(1) - project.default_version_id = 3 - project.save! - - @request.session[:user_id] = 2 - - get :settings, :params => { - :id => 'ecookbook', - :tab => 'versions', - } - assert_response :success - - assert_select 'table.versions tbody' do - # asserts that only one version is marked as default - assert_select 'td.tick span.icon-checked', 1 - # asserts which version is marked as default - assert_select 'tr:first-child td.tick span.icon-checked', 1 - end - end - def test_settings_should_show_locked_members user = User.generate! member = User.add_to_project(user, Project.find(1)) Index: test/unit/attachment_test.rb =================================================================== --- test/unit/attachment_test.rb (revision 17462) +++ test/unit/attachment_test.rb (working copy) @@ -444,4 +444,24 @@ puts '(ImageMagick convert not available)' end + def test_is_text + files = [ + {:name => 'testfile.txt', :type => 'text/plain'}, + {:name => 'hello.go', :type => 'text/plain'}, + {:name => '2006/07/060719210727_archive.zip', :type => 'application/octet-stream'} + ] + + a_text, a_go, a_bin = files.map do |f| + a = Attachment.new(:container => Issue.find(1), + :file => uploaded_test_file(f[:name], f[:type]), + :author => User.find(1)) + a.save! + a + end + + assert a_text.is_text? + assert a_go.is_text? + assert_not a_bin.is_text? + end + end
<%= l(:label_version) %><%= l(:field_default_version) %> <%= l(:field_effective_date) %> <%= l(:field_description) %> <%= l(:field_status) %>
<%= link_to_version version %><%= checked_image(version.id == @project.default_version_id) %> <%= format_date(version.effective_date) %> <%= version.description %> <%= l("version_status_#{version.status}") %>