File viewer for attached text files.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1520 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-06-09 18:40:59 +00:00
parent aa0beecad0
commit 80a7486f95
14 changed files with 181 additions and 12 deletions
+37 -1
View File
@@ -36,4 +36,40 @@ attachments_003:
filename: logo.gif
description: This is a logo
author_id: 2
attachments_004:
created_on: 2006-07-19 21:07:27 +02:00
container_type: Issue
container_id: 3
downloads: 0
disk_filename: 060719210727_source.rb
digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
id: 4
filesize: 153
filename: source.rb
author_id: 2
description: This is a Ruby source file
content_type: application/x-ruby
attachments_005:
created_on: 2006-07-19 21:07:27 +02:00
container_type: Issue
container_id: 3
downloads: 0
disk_filename: 060719210727_changeset.diff
digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
id: 5
filesize: 687
filename: changeset.diff
author_id: 2
content_type: text/x-diff
attachments_006:
created_on: 2006-07-19 21:07:27 +02:00
container_type: Issue
container_id: 3
downloads: 0
disk_filename: 060719210727_archive.zip
digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
id: 6
filesize: 157
filename: archive.zip
author_id: 2
content_type: application/octet-stream
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
Index: trunk/app/controllers/issues_controller.rb
===================================================================
--- trunk/app/controllers/issues_controller.rb (r‚vision 1483)
+++ trunk/app/controllers/issues_controller.rb (r‚vision 1484)
@@ -149,7 +149,7 @@
attach_files(@issue, params[:attachments])
flash[:notice] = l(:notice_successful_create)
Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
- redirect_to :controller => 'issues', :action => 'show', :id => @issue, :project_id => @project
+ redirect_to :controller => 'issues', :action => 'show', :id => @issue
return
end
end
+10
View File
@@ -0,0 +1,10 @@
# The Greeter class
class Greeter
def initialize(name)
@name = name.capitalize
end
def salute
puts "Hello #{@name}!"
end
end
@@ -0,0 +1,59 @@
# redMine - project management software
# Copyright (C) 2006-2008 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.dirname(__FILE__) + '/../test_helper'
require 'attachments_controller'
# Re-raise errors caught by the controller.
class AttachmentsController; def rescue_action(e) raise e end; end
class AttachmentsControllerTest < Test::Unit::TestCase
fixtures :users, :projects, :issues, :attachments
def setup
@controller = AttachmentsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
Attachment.storage_path = "#{RAILS_ROOT}/test/fixtures/files"
User.current = nil
end
def test_show_diff
get :show, :id => 5
assert_response :success
assert_template 'diff'
end
def test_show_text_file
get :show, :id => 4
assert_response :success
assert_template 'file'
end
def test_show_other
get :show, :id => 6
assert_response :success
assert_equal 'application/octet-stream', @response.content_type
end
def test_download_text_file
get :download, :id => 4
assert_response :success
assert_equal 'application/x-ruby', @response.content_type
end
end
@@ -40,6 +40,8 @@ class DocumentsControllerTest < Test::Unit::TestCase
def test_new_with_one_attachment
@request.session[:user_id] = 2
set_tmp_attachments_directory
post :new, :project_id => 'ecookbook',
:document => { :title => 'DocumentsControllerTest#test_post_new',
:description => 'This is a new document',
@@ -361,6 +361,8 @@ class IssuesControllerTest < Test::Unit::TestCase
end
def test_post_edit_with_attachment_only
set_tmp_attachments_directory
# anonymous user
post :edit,
:id => 1,
+18
View File
@@ -1,3 +1,20 @@
# redMine - project management software
# Copyright (C) 2006-2008 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require "#{File.dirname(__FILE__)}/../test_helper"
class IssuesTest < ActionController::IntegrationTest
@@ -47,6 +64,7 @@ class IssuesTest < ActionController::IntegrationTest
# add then remove 2 attachments to an issue
def test_issue_attachements
log_user('jsmith', 'jsmith')
set_tmp_attachments_directory
post 'issues/edit/1',
:notes => 'Some notes',
+6
View File
@@ -57,6 +57,12 @@ class Test::Unit::TestCase
def test_uploaded_file(name, mime)
ActionController::TestUploadedFile.new(Test::Unit::TestCase.fixture_path + "/files/#{name}", mime)
end
# Use a temporary directory for attachment related tests
def set_tmp_attachments_directory
Dir.mkdir "#{RAILS_ROOT}/tmp/test/attachments" unless File.directory?("#{RAILS_ROOT}/tmp/test/attachments")
Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments"
end
end