mirror of
https://github.com/redmine/redmine.git
synced 2026-03-06 12:31:40 +01:00
Files module: makes version field non required (#1053).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2117 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user