Refactor: move method, ProjectsController#add_file to FilesController#new.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4052 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -26,4 +26,42 @@ class FilesControllerTest < ActionController::TestCase
|
||||
:attributes => { :href => '/attachments/download/9/version_file.zip' }
|
||||
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 :new, :id => 1, :version_id => '',
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
assert_response :redirect
|
||||
end
|
||||
assert_redirected_to 'projects/ecookbook/files'
|
||||
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 :new, :id => 1, :version_id => '2',
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
assert_response :redirect
|
||||
end
|
||||
assert_redirected_to 'projects/ecookbook/files'
|
||||
a = Attachment.find(:first, :order => 'created_on DESC')
|
||||
assert_equal 'testfile.txt', a.filename
|
||||
assert_equal Version.find(2), a.container
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -317,42 +317,6 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||
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' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
end
|
||||
assert_redirected_to 'projects/ecookbook/files'
|
||||
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' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
end
|
||||
assert_redirected_to 'projects/ecookbook/files'
|
||||
a = Attachment.find(:first, :order => 'created_on DESC')
|
||||
assert_equal 'testfile.txt', a.filename
|
||||
assert_equal Version.find(2), a.container
|
||||
end
|
||||
|
||||
def test_archive
|
||||
@request.session[:user_id] = 1 # admin
|
||||
post :archive, :id => 1
|
||||
|
||||
@@ -173,7 +173,7 @@ class RoutingTest < ActionController::IntegrationTest
|
||||
should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
|
||||
should_route :get, "/projects/567/destroy", :controller => 'projects', :action => 'destroy', :id => '567'
|
||||
should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :id => '33'
|
||||
should_route :get, "/projects/33/files/new", :controller => 'projects', :action => 'add_file', :id => '33'
|
||||
should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
|
||||
should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
|
||||
should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
|
||||
should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
|
||||
@@ -182,7 +182,7 @@ class RoutingTest < ActionController::IntegrationTest
|
||||
should_route :post, "/projects.xml", :controller => 'projects', :action => 'add', :format => 'xml'
|
||||
should_route :post, "/projects/4223/edit", :controller => 'projects', :action => 'edit', :id => '4223'
|
||||
should_route :post, "/projects/64/destroy", :controller => 'projects', :action => 'destroy', :id => '64'
|
||||
should_route :post, "/projects/33/files/new", :controller => 'projects', :action => 'add_file', :id => '33'
|
||||
should_route :post, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
|
||||
should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
|
||||
should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
|
||||
should_route :post, "/projects/64/activities/save", :controller => 'projects', :action => 'save_activities', :id => '64'
|
||||
|
||||
Reference in New Issue
Block a user