Merged r2116, r2117 and r2187 from trunk.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.8-stable@2217 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-12-31 11:40:03 +00:00
parent dea10c54f9
commit 31178553f3
32 changed files with 284 additions and 104 deletions
@@ -76,4 +76,50 @@ class AttachmentsControllerTest < Test::Unit::TestCase
get :download, :id => 7
assert_redirected_to 'account/login'
end
def test_destroy_issue_attachment
issue = Issue.find(3)
@request.session[:user_id] = 2
assert_difference 'issue.attachments.count', -1 do
post :destroy, :id => 1
end
# no referrer
assert_redirected_to 'projects/show/ecookbook'
assert_nil Attachment.find_by_id(1)
j = issue.journals.find(:first, :order => 'created_on DESC')
assert_equal 'attachment', j.details.first.property
assert_equal '1', j.details.first.prop_key
assert_equal 'error281.txt', j.details.first.old_value
end
def test_destroy_wiki_page_attachment
@request.session[:user_id] = 2
assert_difference 'Attachment.count', -1 do
post :destroy, :id => 3
assert_response 302
end
end
def test_destroy_project_attachment
@request.session[:user_id] = 2
assert_difference 'Attachment.count', -1 do
post :destroy, :id => 8
assert_response 302
end
end
def test_destroy_version_attachment
@request.session[:user_id] = 2
assert_difference 'Attachment.count', -1 do
post :destroy, :id => 9
assert_response 302
end
end
def test_destroy_without_permission
post :destroy, :id => 3
assert_redirected_to '/login'
assert Attachment.find_by_id(3)
end
end
-13
View File
@@ -747,17 +747,4 @@ class IssuesControllerTest < Test::Unit::TestCase
assert_equal 2, TimeEntry.find(1).issue_id
assert_equal 2, TimeEntry.find(2).issue_id
end
def test_destroy_attachment
issue = Issue.find(3)
a = issue.attachments.size
@request.session[:user_id] = 2
post :destroy_attachment, :id => 3, :attachment_id => 1
assert_redirected_to 'issues/show/3'
assert_nil Attachment.find_by_id(1)
issue.reload
assert_equal((a-1), issue.attachments.size)
j = issue.journals.find(:first, :order => 'created_on DESC')
assert_equal 'attachment', j.details.first.property
end
end
+1 -1
View File
@@ -64,7 +64,7 @@ class MessagesControllerTest < Test::Unit::TestCase
def test_post_new
@request.session[:user_id] = 2
ActionMailer::Base.deliveries.clear
Setting.notified_events << 'message_posted'
Setting.notified_events = ['message_posted']
post :new, :board_id => 1,
:message => { :subject => 'Test created message',
+47 -2
View File
@@ -23,7 +23,8 @@ class ProjectsController; def rescue_action(e) raise e end; end
class ProjectsControllerTest < Test::Unit::TestCase
fixtures :projects, :versions, :users, :roles, :members, :issues, :journals, :journal_details,
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
:attachments
def setup
@controller = ProjectsController.new
@@ -112,12 +113,56 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_redirected_to 'admin/projects'
assert_nil Project.find_by_id(1)
end
def test_add_file
set_tmp_attachments_directory
@request.session[:user_id] = 2
Setting.notified_events = ['file_added']
ActionMailer::Base.deliveries.clear
assert_difference 'Attachment.count' do
post :add_file, :id => 1, :version_id => '',
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
end
assert_redirected_to 'projects/list_files/ecookbook'
a = Attachment.find(:first, :order => 'created_on DESC')
assert_equal 'testfile.txt', a.filename
assert_equal Project.find(1), a.container
mail = ActionMailer::Base.deliveries.last
assert_kind_of TMail::Mail, mail
assert_equal "[eCookbook] New file", mail.subject
assert mail.body.include?('testfile.txt')
end
def test_add_version_file
set_tmp_attachments_directory
@request.session[:user_id] = 2
Setting.notified_events = ['file_added']
assert_difference 'Attachment.count' do
post :add_file, :id => 1, :version_id => '2',
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
end
assert_redirected_to 'projects/list_files/ecookbook'
a = Attachment.find(:first, :order => 'created_on DESC')
assert_equal 'testfile.txt', a.filename
assert_equal Version.find(2), a.container
end
def test_list_files
get :list_files, :id => 1
assert_response :success
assert_template 'list_files'
assert_not_nil assigns(:versions)
assert_not_nil assigns(:containers)
# file attached to the project
assert_tag :a, :content => 'project_file.zip',
:attributes => { :href => '/attachments/download/8/project_file.zip' }
# file attached to a project's version
assert_tag :a, :content => 'version_file.zip',
:attributes => { :href => '/attachments/download/9/version_file.zip' }
end
def test_changelog
-7
View File
@@ -252,13 +252,6 @@ class WikiControllerTest < Test::Unit::TestCase
assert_template 'edit'
end
def test_destroy_attachment
@request.session[:user_id] = 2
assert_difference 'Attachment.count', -1 do
post :destroy_attachment, :id => 1, :page => 'Page_with_an_inline_image', :attachment_id => 3
end
end
def test_history_of_non_existing_page_should_return_404
get :history, :id => 1, :page => 'Unknown_page'
assert_response 404