diff options
Diffstat (limited to 'test/functional/projects_controller_test.rb')
-rw-r--r-- | test/functional/projects_controller_test.rb | 199 |
1 files changed, 176 insertions, 23 deletions
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 4b8c6c402..25f9ad78e 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -33,7 +33,14 @@ class ProjectsControllerTest < Test::Unit::TestCase @request.session[:user_id] = nil Setting.default_language = 'en' end - + + def test_index_routing + assert_routing( + {:method => :get, :path => '/projects'}, + :controller => 'projects', :action => 'index' + ) + end + def test_index get :index assert_response :success @@ -50,7 +57,14 @@ class ProjectsControllerTest < Test::Unit::TestCase } assert_no_tag :a, :content => /Private child of eCookbook/ - end
+ end + + def test_index_atom_routing + assert_routing( + {:method => :get, :path => '/projects.atom'}, + :controller => 'projects', :action => 'index', :format => 'atom' + ) + end def test_index_atom get :index, :format => 'atom' @@ -59,12 +73,34 @@ class ProjectsControllerTest < Test::Unit::TestCase assert_select 'feed>title', :text => 'Redmine: Latest projects' assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current)) end -
- def test_show_by_id
- get :show, :id => 1
+ + def test_add_routing + assert_routing( + {:method => :get, :path => '/projects/new'}, + :controller => 'projects', :action => 'add' + ) + assert_recognizes( + {:controller => 'projects', :action => 'add'}, + {:method => :post, :path => '/projects/new'} + ) + assert_recognizes( + {:controller => 'projects', :action => 'add'}, + {:method => :post, :path => '/projects'} + ) + end + + def test_show_routing + assert_routing( + {:method => :get, :path => '/projects/test'}, + :controller => 'projects', :action => 'show', :id => 'test' + ) + end + + def test_show_by_id + get :show, :id => 1 assert_response :success - assert_template 'show'
- assert_not_nil assigns(:project)
+ assert_template 'show' + assert_not_nil assigns(:project) end def test_show_by_identifier @@ -90,6 +126,17 @@ class ProjectsControllerTest < Test::Unit::TestCase assert_tag :tag => 'a', :content => /Private child/ end + def test_settings_routing + assert_routing( + {:method => :get, :path => '/projects/4223/settings'}, + :controller => 'projects', :action => 'settings', :id => '4223' + ) + assert_routing( + {:method => :get, :path => '/projects/4223/settings/members'}, + :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members' + ) + end + def test_settings @request.session[:user_id] = 2 # manager get :settings, :id => 1 @@ -106,13 +153,49 @@ class ProjectsControllerTest < Test::Unit::TestCase assert_equal 'Test changed name', project.name end + def test_add_version_routing + assert_routing( + {:method => :get, :path => 'projects/64/versions/new'}, + :controller => 'projects', :action => 'add_version', :id => '64' + ) + assert_routing( + #TODO: use PUT + {:method => :post, :path => 'projects/64/versions/new'}, + :controller => 'projects', :action => 'add_version', :id => '64' + ) + end + + def test_add_issue_category_routing + assert_routing( + {:method => :get, :path => 'projects/test/categories/new'}, + :controller => 'projects', :action => 'add_issue_category', :id => 'test' + ) + assert_routing( + #TODO: use PUT and update form + {:method => :post, :path => 'projects/64/categories/new'}, + :controller => 'projects', :action => 'add_issue_category', :id => '64' + ) + end + + def test_destroy_routing + assert_routing( + {:method => :get, :path => '/projects/567/destroy'}, + :controller => 'projects', :action => 'destroy', :id => '567' + ) + assert_routing( + #TODO: use DELETE and update form + {:method => :post, :path => 'projects/64/destroy'}, + :controller => 'projects', :action => 'destroy', :id => '64' + ) + end + def test_get_destroy @request.session[:user_id] = 1 # admin get :destroy, :id => 1 assert_response :success assert_template 'destroy' assert_not_nil Project.find_by_id(1) - end
+ end def test_post_destroy @request.session[:user_id] = 1 # admin @@ -142,6 +225,17 @@ class ProjectsControllerTest < Test::Unit::TestCase assert mail.body.include?('testfile.txt') end + def test_add_file_routing + assert_routing( + {:method => :get, :path => '/projects/33/files/new'}, + :controller => 'projects', :action => 'add_file', :id => '33' + ) + assert_routing( + {:method => :post, :path => '/projects/33/files/new'}, + :controller => 'projects', :action => 'add_file', :id => '33' + ) + end + def test_add_version_file set_tmp_attachments_directory @request.session[:user_id] = 2 @@ -156,27 +250,48 @@ class ProjectsControllerTest < Test::Unit::TestCase 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'
+ + def test_list_files + get :list_files, :id => 1 + assert_response :success + assert_template 'list_files' 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
- get :changelog, :id => 1
- assert_response :success
- assert_template 'changelog'
- assert_not_nil assigns(:versions)
+ end + + def test_list_files_routing + assert_routing( + {:method => :get, :path => '/projects/33/files'}, + :controller => 'projects', :action => 'list_files', :id => '33' + ) + end + + def test_changelog_routing + assert_routing( + {:method => :get, :path => '/projects/44/changelog'}, + :controller => 'projects', :action => 'changelog', :id => '44' + ) + end + + def test_changelog + get :changelog, :id => 1 + assert_response :success + assert_template 'changelog' + assert_not_nil assigns(:versions) + end + + def test_roadmap_routing + assert_routing( + {:method => :get, :path => 'projects/33/roadmap'}, + :controller => 'projects', :action => 'roadmap', :id => '33' + ) end def test_roadmap @@ -200,7 +315,21 @@ class ProjectsControllerTest < Test::Unit::TestCase # Completed version appears assert assigns(:versions).include?(Version.find(1)) end - + + def test_project_activity_routing + assert_routing( + {:method => :get, :path => '/projects/1/activity'}, + :controller => 'projects', :action => 'activity', :id => '1' + ) + end + + def test_project_activity_atom_routing + assert_routing( + {:method => :get, :path => '/projects/1/activity.atom'}, + :controller => 'projects', :action => 'activity', :id => '1', :format => 'atom' + ) + end + def test_project_activity get :activity, :id => 1, :with_subprojects => 0 assert_response :success @@ -237,6 +366,10 @@ class ProjectsControllerTest < Test::Unit::TestCase } end + def test_global_activity_routing + assert_routing({:method => :get, :path => '/activity'}, :controller => 'projects', :action => 'activity') + end + def test_global_activity get :activity assert_response :success @@ -273,19 +406,39 @@ class ProjectsControllerTest < Test::Unit::TestCase } end + def test_global_activity_atom_routing + assert_routing({:method => :get, :path => '/activity.atom'}, :controller => 'projects', :action => 'activity', :format => 'atom') + end + def test_activity_atom_feed get :activity, :format => 'atom' assert_response :success assert_template 'common/feed.atom.rxml' end - def test_archive + def test_archive_routing + assert_routing( + #TODO: use PUT to project path and modify form + {:method => :post, :path => 'projects/64/archive'}, + :controller => 'projects', :action => 'archive', :id => '64' + ) + end + + def test_archive @request.session[:user_id] = 1 # admin post :archive, :id => 1 assert_redirected_to 'admin/projects' assert !Project.find(1).active? end + def test_unarchive_routing + assert_routing( + #TODO: use PUT to project path and modify form + {:method => :post, :path => '/projects/567/unarchive'}, + :controller => 'projects', :action => 'unarchive', :id => '567' + ) + end + def test_unarchive @request.session[:user_id] = 1 # admin Project.find(1).archive |