Mercurial > hg > soundsoftware-site
comparison test/functional/projects_controller_test.rb @ 119:8661b858af72
* Update to Redmine trunk rev 4705
| author | Chris Cannam |
|---|---|
| date | Thu, 13 Jan 2011 14:12:06 +0000 |
| parents | 94944d00e43c |
| children | cbce1fd3b1b7 |
comparison
equal
deleted
inserted
replaced
| 39:150ceac17a8d | 119:8661b858af72 |
|---|---|
| 13 # | 13 # |
| 14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
| 15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
| 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | 17 |
| 18 require File.dirname(__FILE__) + '/../test_helper' | 18 require File.expand_path('../../test_helper', __FILE__) |
| 19 require 'projects_controller' | 19 require 'projects_controller' |
| 20 | 20 |
| 21 # Re-raise errors caught by the controller. | 21 # Re-raise errors caught by the controller. |
| 22 class ProjectsController; def rescue_action(e) raise e end; end | 22 class ProjectsController; def rescue_action(e) raise e end; end |
| 23 | 23 |
| 142 setup do | 142 setup do |
| 143 @request.session[:user_id] = 1 | 143 @request.session[:user_id] = 1 |
| 144 end | 144 end |
| 145 | 145 |
| 146 should "create a new project" do | 146 should "create a new project" do |
| 147 post :create, :project => { :name => "blog", | 147 post :create, |
| 148 :description => "weblog", | 148 :project => { |
| 149 :identifier => "blog", | 149 :name => "blog", |
| 150 :is_public => 1, | 150 :description => "weblog", |
| 151 :custom_field_values => { '3' => 'Beta' } | 151 :homepage => 'http://weblog', |
| 152 } | 152 :identifier => "blog", |
| 153 :is_public => 1, | |
| 154 :custom_field_values => { '3' => 'Beta' }, | |
| 155 :tracker_ids => ['1', '3'], | |
| 156 # an issue custom field that is not for all project | |
| 157 :issue_custom_field_ids => ['9'], | |
| 158 :enabled_module_names => ['issue_tracking', 'news', 'repository'] | |
| 159 } | |
| 153 assert_redirected_to '/projects/blog/settings' | 160 assert_redirected_to '/projects/blog/settings' |
| 154 | 161 |
| 155 project = Project.find_by_name('blog') | 162 project = Project.find_by_name('blog') |
| 156 assert_kind_of Project, project | 163 assert_kind_of Project, project |
| 164 assert project.active? | |
| 157 assert_equal 'weblog', project.description | 165 assert_equal 'weblog', project.description |
| 166 assert_equal 'http://weblog', project.homepage | |
| 158 assert_equal true, project.is_public? | 167 assert_equal true, project.is_public? |
| 159 assert_nil project.parent | 168 assert_nil project.parent |
| 169 assert_equal 'Beta', project.custom_value_for(3).value | |
| 170 assert_equal [1, 3], project.trackers.map(&:id).sort | |
| 171 assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort | |
| 172 assert project.issue_custom_fields.include?(IssueCustomField.find(9)) | |
| 160 end | 173 end |
| 161 | 174 |
| 162 should "create a new subproject" do | 175 should "create a new subproject" do |
| 163 post :create, :project => { :name => "blog", | 176 post :create, :project => { :name => "blog", |
| 164 :description => "weblog", | 177 :description => "weblog", |
| 184 should "accept create a Project" do | 197 should "accept create a Project" do |
| 185 post :create, :project => { :name => "blog", | 198 post :create, :project => { :name => "blog", |
| 186 :description => "weblog", | 199 :description => "weblog", |
| 187 :identifier => "blog", | 200 :identifier => "blog", |
| 188 :is_public => 1, | 201 :is_public => 1, |
| 189 :custom_field_values => { '3' => 'Beta' } | 202 :custom_field_values => { '3' => 'Beta' }, |
| 203 :tracker_ids => ['1', '3'], | |
| 204 :enabled_module_names => ['issue_tracking', 'news', 'repository'] | |
| 190 } | 205 } |
| 191 | 206 |
| 192 assert_redirected_to '/projects/blog/settings' | 207 assert_redirected_to '/projects/blog/settings' |
| 193 | 208 |
| 194 project = Project.find_by_name('blog') | 209 project = Project.find_by_name('blog') |
| 195 assert_kind_of Project, project | 210 assert_kind_of Project, project |
| 196 assert_equal 'weblog', project.description | 211 assert_equal 'weblog', project.description |
| 197 assert_equal true, project.is_public? | 212 assert_equal true, project.is_public? |
| 213 assert_equal [1, 3], project.trackers.map(&:id).sort | |
| 214 assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort | |
| 198 | 215 |
| 199 # User should be added as a project member | 216 # User should be added as a project member |
| 200 assert User.find(9).member_of?(project) | 217 assert User.find(9).member_of?(project) |
| 201 assert_equal 1, project.members.size | 218 assert_equal 1, project.members.size |
| 202 end | 219 end |
| 269 assert_not_nil project.errors.on(:parent_id) | 286 assert_not_nil project.errors.on(:parent_id) |
| 270 end | 287 end |
| 271 end | 288 end |
| 272 end | 289 end |
| 273 | 290 |
| 291 def test_create_should_not_accept_get | |
| 292 @request.session[:user_id] = 1 | |
| 293 get :create | |
| 294 assert_response :method_not_allowed | |
| 295 end | |
| 296 | |
| 274 def test_show_by_id | 297 def test_show_by_id |
| 275 get :show, :id => 1 | 298 get :show, :id => 1 |
| 276 assert_response :success | 299 assert_response :success |
| 277 assert_template 'show' | 300 assert_template 'show' |
| 278 assert_not_nil assigns(:project) | 301 assert_not_nil assigns(:project) |
| 345 post :update, :id => 1, :project => {:name => 'Test changed name', | 368 post :update, :id => 1, :project => {:name => 'Test changed name', |
| 346 :issue_custom_field_ids => ['']} | 369 :issue_custom_field_ids => ['']} |
| 347 assert_redirected_to '/projects/ecookbook/settings' | 370 assert_redirected_to '/projects/ecookbook/settings' |
| 348 project = Project.find(1) | 371 project = Project.find(1) |
| 349 assert_equal 'Test changed name', project.name | 372 assert_equal 'Test changed name', project.name |
| 373 end | |
| 374 | |
| 375 def test_modules | |
| 376 @request.session[:user_id] = 2 | |
| 377 Project.find(1).enabled_module_names = ['issue_tracking', 'news'] | |
| 378 | |
| 379 post :modules, :id => 1, :enabled_module_names => ['issue_tracking', 'repository', 'documents'] | |
| 380 assert_redirected_to '/projects/ecookbook/settings/modules' | |
| 381 assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort | |
| 382 end | |
| 383 | |
| 384 def test_modules_should_not_allow_get | |
| 385 @request.session[:user_id] = 1 | |
| 386 get :modules, :id => 1 | |
| 387 assert_response :method_not_allowed | |
| 350 end | 388 end |
| 351 | 389 |
| 352 def test_get_destroy | 390 def test_get_destroy |
| 353 @request.session[:user_id] = 1 # admin | 391 @request.session[:user_id] = 1 # admin |
| 354 get :destroy, :id => 1 | 392 get :destroy, :id => 1 |
| 416 | 454 |
| 417 should "redirect to the project settings when successful" do | 455 should "redirect to the project settings when successful" do |
| 418 @request.session[:user_id] = 1 # admin | 456 @request.session[:user_id] = 1 # admin |
| 419 post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'} | 457 post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'} |
| 420 assert_response :redirect | 458 assert_response :redirect |
| 421 assert_redirected_to :controller => 'projects', :action => 'settings' | 459 assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy' |
| 422 end | 460 end |
| 423 end | 461 end |
| 424 | 462 |
| 425 def test_jump_should_redirect_to_active_tab | 463 def test_jump_should_redirect_to_active_tab |
| 426 get :show, :id => 1, :jump => 'issues' | 464 get :show, :id => 1, :jump => 'issues' |
