annotate .svn/pristine/44/448dc5ae56acac81ffaeeeb288586a6544fe08b0.svn-base @ 1327:287f201c2802 redmine-2.2-integration

Add italic
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 19 Jun 2013 20:56:22 +0100
parents cbb26bc654de
children
rev   line source
Chris@909 1 # Redmine - project management software
Chris@909 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@909 3 #
Chris@909 4 # This program is free software; you can redistribute it and/or
Chris@909 5 # modify it under the terms of the GNU General Public License
Chris@909 6 # as published by the Free Software Foundation; either version 2
Chris@909 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@909 9 # This program is distributed in the hope that it will be useful,
Chris@909 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@909 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@909 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@909 14 # You should have received a copy of the GNU General Public License
Chris@909 15 # along with this program; if not, write to the Free Software
Chris@909 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@909 17
Chris@909 18 require File.expand_path('../../test_helper', __FILE__)
Chris@909 19 require 'projects_controller'
Chris@909 20
Chris@909 21 # Re-raise errors caught by the controller.
Chris@909 22 class ProjectsController; def rescue_action(e) raise e end; end
Chris@909 23
Chris@909 24 class ProjectsControllerTest < ActionController::TestCase
Chris@909 25 fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
Chris@909 26 :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
Chris@909 27 :attachments, :custom_fields, :custom_values, :time_entries
Chris@909 28
Chris@909 29 def setup
Chris@909 30 @controller = ProjectsController.new
Chris@909 31 @request = ActionController::TestRequest.new
Chris@909 32 @response = ActionController::TestResponse.new
Chris@909 33 @request.session[:user_id] = nil
Chris@909 34 Setting.default_language = 'en'
Chris@909 35 end
Chris@909 36
Chris@909 37 def test_index
Chris@909 38 get :index
Chris@909 39 assert_response :success
Chris@909 40 assert_template 'index'
Chris@909 41 assert_not_nil assigns(:projects)
Chris@909 42
Chris@909 43 assert_tag :ul, :child => {:tag => 'li',
Chris@909 44 :descendant => {:tag => 'a', :content => 'eCookbook'},
Chris@909 45 :child => { :tag => 'ul',
Chris@909 46 :descendant => { :tag => 'a',
Chris@909 47 :content => 'Child of private child'
Chris@909 48 }
Chris@909 49 }
Chris@909 50 }
Chris@909 51
Chris@909 52 assert_no_tag :a, :content => /Private child of eCookbook/
Chris@909 53 end
Chris@909 54
Chris@909 55 def test_index_atom
Chris@909 56 get :index, :format => 'atom'
Chris@909 57 assert_response :success
Chris@909 58 assert_template 'common/feed.atom'
Chris@909 59 assert_select 'feed>title', :text => 'Redmine: Latest projects'
Chris@909 60 assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_condition(User.current))
Chris@909 61 end
Chris@909 62
Chris@909 63 context "#index" do
Chris@909 64 context "by non-admin user with view_time_entries permission" do
Chris@909 65 setup do
Chris@909 66 @request.session[:user_id] = 3
Chris@909 67 end
Chris@909 68 should "show overall spent time link" do
Chris@909 69 get :index
Chris@909 70 assert_template 'index'
Chris@909 71 assert_tag :a, :attributes => {:href => '/time_entries'}
Chris@909 72 end
Chris@909 73 end
Chris@909 74
Chris@909 75 context "by non-admin user without view_time_entries permission" do
Chris@909 76 setup do
Chris@909 77 Role.find(2).remove_permission! :view_time_entries
Chris@909 78 Role.non_member.remove_permission! :view_time_entries
Chris@909 79 Role.anonymous.remove_permission! :view_time_entries
Chris@909 80 @request.session[:user_id] = 3
Chris@909 81 end
Chris@909 82 should "not show overall spent time link" do
Chris@909 83 get :index
Chris@909 84 assert_template 'index'
Chris@909 85 assert_no_tag :a, :attributes => {:href => '/time_entries'}
Chris@909 86 end
Chris@909 87 end
Chris@909 88 end
Chris@909 89
Chris@909 90 context "#new" do
Chris@909 91 context "by admin user" do
Chris@909 92 setup do
Chris@909 93 @request.session[:user_id] = 1
Chris@909 94 end
Chris@909 95
Chris@909 96 should "accept get" do
Chris@909 97 get :new
Chris@909 98 assert_response :success
Chris@909 99 assert_template 'new'
Chris@909 100 end
Chris@909 101
Chris@909 102 end
Chris@909 103
Chris@909 104 context "by non-admin user with add_project permission" do
Chris@909 105 setup do
Chris@909 106 Role.non_member.add_permission! :add_project
Chris@909 107 @request.session[:user_id] = 9
Chris@909 108 end
Chris@909 109
Chris@909 110 should "accept get" do
Chris@909 111 get :new
Chris@909 112 assert_response :success
Chris@909 113 assert_template 'new'
Chris@909 114 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}
Chris@909 115 end
Chris@909 116 end
Chris@909 117
Chris@909 118 context "by non-admin user with add_subprojects permission" do
Chris@909 119 setup do
Chris@909 120 Role.find(1).remove_permission! :add_project
Chris@909 121 Role.find(1).add_permission! :add_subprojects
Chris@909 122 @request.session[:user_id] = 2
Chris@909 123 end
Chris@909 124
Chris@909 125 should "accept get" do
Chris@909 126 get :new, :parent_id => 'ecookbook'
Chris@909 127 assert_response :success
Chris@909 128 assert_template 'new'
Chris@909 129 # parent project selected
Chris@909 130 assert_tag :select, :attributes => {:name => 'project[parent_id]'},
Chris@909 131 :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}}
Chris@909 132 # no empty value
Chris@909 133 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'},
Chris@909 134 :child => {:tag => 'option', :attributes => {:value => ''}}
Chris@909 135 end
Chris@909 136 end
Chris@909 137
Chris@909 138 end
Chris@909 139
Chris@909 140 context "POST :create" do
Chris@909 141 context "by admin user" do
Chris@909 142 setup do
Chris@909 143 @request.session[:user_id] = 1
Chris@909 144 end
Chris@909 145
Chris@909 146 should "create a new project" do
Chris@909 147 post :create,
Chris@909 148 :project => {
Chris@909 149 :name => "blog",
Chris@909 150 :description => "weblog",
Chris@909 151 :homepage => 'http://weblog',
Chris@909 152 :identifier => "blog",
Chris@909 153 :is_public => 1,
Chris@909 154 :custom_field_values => { '3' => 'Beta' },
Chris@909 155 :tracker_ids => ['1', '3'],
Chris@909 156 # an issue custom field that is not for all project
Chris@909 157 :issue_custom_field_ids => ['9'],
Chris@909 158 :enabled_module_names => ['issue_tracking', 'news', 'repository']
Chris@909 159 }
Chris@909 160 assert_redirected_to '/projects/blog/settings'
Chris@909 161
Chris@909 162 project = Project.find_by_name('blog')
Chris@909 163 assert_kind_of Project, project
Chris@909 164 assert project.active?
Chris@909 165 assert_equal 'weblog', project.description
Chris@909 166 assert_equal 'http://weblog', project.homepage
Chris@909 167 assert_equal true, project.is_public?
Chris@909 168 assert_nil project.parent
Chris@909 169 assert_equal 'Beta', project.custom_value_for(3).value
Chris@909 170 assert_equal [1, 3], project.trackers.map(&:id).sort
Chris@909 171 assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort
Chris@909 172 assert project.issue_custom_fields.include?(IssueCustomField.find(9))
Chris@909 173 end
Chris@909 174
Chris@909 175 should "create a new subproject" do
Chris@909 176 post :create, :project => { :name => "blog",
Chris@909 177 :description => "weblog",
Chris@909 178 :identifier => "blog",
Chris@909 179 :is_public => 1,
Chris@909 180 :custom_field_values => { '3' => 'Beta' },
Chris@909 181 :parent_id => 1
Chris@909 182 }
Chris@909 183 assert_redirected_to '/projects/blog/settings'
Chris@909 184
Chris@909 185 project = Project.find_by_name('blog')
Chris@909 186 assert_kind_of Project, project
Chris@909 187 assert_equal Project.find(1), project.parent
Chris@909 188 end
Chris@909 189
Chris@909 190 should "continue" do
Chris@909 191 assert_difference 'Project.count' do
Chris@909 192 post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue'
Chris@909 193 end
Chris@909 194 assert_redirected_to '/projects/new?'
Chris@909 195 end
Chris@909 196 end
Chris@909 197
Chris@909 198 context "by non-admin user with add_project permission" do
Chris@909 199 setup do
Chris@909 200 Role.non_member.add_permission! :add_project
Chris@909 201 @request.session[:user_id] = 9
Chris@909 202 end
Chris@909 203
Chris@909 204 should "accept create a Project" do
Chris@909 205 post :create, :project => { :name => "blog",
Chris@909 206 :description => "weblog",
Chris@909 207 :identifier => "blog",
Chris@909 208 :is_public => 1,
Chris@909 209 :custom_field_values => { '3' => 'Beta' },
Chris@909 210 :tracker_ids => ['1', '3'],
Chris@909 211 :enabled_module_names => ['issue_tracking', 'news', 'repository']
Chris@909 212 }
Chris@909 213
Chris@909 214 assert_redirected_to '/projects/blog/settings'
Chris@909 215
Chris@909 216 project = Project.find_by_name('blog')
Chris@909 217 assert_kind_of Project, project
Chris@909 218 assert_equal 'weblog', project.description
Chris@909 219 assert_equal true, project.is_public?
Chris@909 220 assert_equal [1, 3], project.trackers.map(&:id).sort
Chris@909 221 assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort
Chris@909 222
Chris@909 223 # User should be added as a project member
Chris@909 224 assert User.find(9).member_of?(project)
Chris@909 225 assert_equal 1, project.members.size
Chris@909 226 end
Chris@909 227
Chris@909 228 should "fail with parent_id" do
Chris@909 229 assert_no_difference 'Project.count' do
Chris@909 230 post :create, :project => { :name => "blog",
Chris@909 231 :description => "weblog",
Chris@909 232 :identifier => "blog",
Chris@909 233 :is_public => 1,
Chris@909 234 :custom_field_values => { '3' => 'Beta' },
Chris@909 235 :parent_id => 1
Chris@909 236 }
Chris@909 237 end
Chris@909 238 assert_response :success
Chris@909 239 project = assigns(:project)
Chris@909 240 assert_kind_of Project, project
Chris@909 241 assert_not_nil project.errors[:parent_id]
Chris@909 242 end
Chris@909 243 end
Chris@909 244
Chris@909 245 context "by non-admin user with add_subprojects permission" do
Chris@909 246 setup do
Chris@909 247 Role.find(1).remove_permission! :add_project
Chris@909 248 Role.find(1).add_permission! :add_subprojects
Chris@909 249 @request.session[:user_id] = 2
Chris@909 250 end
Chris@909 251
Chris@909 252 should "create a project with a parent_id" do
Chris@909 253 post :create, :project => { :name => "blog",
Chris@909 254 :description => "weblog",
Chris@909 255 :identifier => "blog",
Chris@909 256 :is_public => 1,
Chris@909 257 :custom_field_values => { '3' => 'Beta' },
Chris@909 258 :parent_id => 1
Chris@909 259 }
Chris@909 260 assert_redirected_to '/projects/blog/settings'
Chris@909 261 project = Project.find_by_name('blog')
Chris@909 262 end
Chris@909 263
Chris@909 264 should "fail without parent_id" do
Chris@909 265 assert_no_difference 'Project.count' do
Chris@909 266 post :create, :project => { :name => "blog",
Chris@909 267 :description => "weblog",
Chris@909 268 :identifier => "blog",
Chris@909 269 :is_public => 1,
Chris@909 270 :custom_field_values => { '3' => 'Beta' }
Chris@909 271 }
Chris@909 272 end
Chris@909 273 assert_response :success
Chris@909 274 project = assigns(:project)
Chris@909 275 assert_kind_of Project, project
Chris@909 276 assert_not_nil project.errors[:parent_id]
Chris@909 277 end
Chris@909 278
Chris@909 279 should "fail with unauthorized parent_id" do
Chris@909 280 assert !User.find(2).member_of?(Project.find(6))
Chris@909 281 assert_no_difference 'Project.count' do
Chris@909 282 post :create, :project => { :name => "blog",
Chris@909 283 :description => "weblog",
Chris@909 284 :identifier => "blog",
Chris@909 285 :is_public => 1,
Chris@909 286 :custom_field_values => { '3' => 'Beta' },
Chris@909 287 :parent_id => 6
Chris@909 288 }
Chris@909 289 end
Chris@909 290 assert_response :success
Chris@909 291 project = assigns(:project)
Chris@909 292 assert_kind_of Project, project
Chris@909 293 assert_not_nil project.errors[:parent_id]
Chris@909 294 end
Chris@909 295 end
Chris@909 296 end
Chris@909 297
Chris@909 298 def test_create_should_preserve_modules_on_validation_failure
Chris@909 299 with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
Chris@909 300 @request.session[:user_id] = 1
Chris@909 301 assert_no_difference 'Project.count' do
Chris@909 302 post :create, :project => {
Chris@909 303 :name => "blog",
Chris@909 304 :identifier => "",
Chris@909 305 :enabled_module_names => %w(issue_tracking news)
Chris@909 306 }
Chris@909 307 end
Chris@909 308 assert_response :success
Chris@909 309 project = assigns(:project)
Chris@909 310 assert_equal %w(issue_tracking news), project.enabled_module_names.sort
Chris@909 311 end
Chris@909 312 end
Chris@909 313
Chris@909 314 def test_create_should_not_accept_get
Chris@909 315 @request.session[:user_id] = 1
Chris@909 316 get :create
Chris@909 317 assert_response :method_not_allowed
Chris@909 318 end
Chris@909 319
Chris@909 320 def test_show_by_id
Chris@909 321 get :show, :id => 1
Chris@909 322 assert_response :success
Chris@909 323 assert_template 'show'
Chris@909 324 assert_not_nil assigns(:project)
Chris@909 325 end
Chris@909 326
Chris@909 327 def test_show_by_identifier
Chris@909 328 get :show, :id => 'ecookbook'
Chris@909 329 assert_response :success
Chris@909 330 assert_template 'show'
Chris@909 331 assert_not_nil assigns(:project)
Chris@909 332 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
Chris@909 333
Chris@909 334 assert_tag 'li', :content => /Development status/
Chris@909 335 end
Chris@909 336
Chris@909 337 def test_show_should_not_display_hidden_custom_fields
Chris@909 338 ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
Chris@909 339 get :show, :id => 'ecookbook'
Chris@909 340 assert_response :success
Chris@909 341 assert_template 'show'
Chris@909 342 assert_not_nil assigns(:project)
Chris@909 343
Chris@909 344 assert_no_tag 'li', :content => /Development status/
Chris@909 345 end
Chris@909 346
Chris@909 347 def test_show_should_not_fail_when_custom_values_are_nil
Chris@909 348 project = Project.find_by_identifier('ecookbook')
Chris@909 349 project.custom_values.first.update_attribute(:value, nil)
Chris@909 350 get :show, :id => 'ecookbook'
Chris@909 351 assert_response :success
Chris@909 352 assert_template 'show'
Chris@909 353 assert_not_nil assigns(:project)
Chris@909 354 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
Chris@909 355 end
Chris@909 356
Chris@909 357 def show_archived_project_should_be_denied
Chris@909 358 project = Project.find_by_identifier('ecookbook')
Chris@909 359 project.archive!
Chris@909 360
Chris@909 361 get :show, :id => 'ecookbook'
Chris@909 362 assert_response 403
Chris@909 363 assert_nil assigns(:project)
Chris@909 364 assert_tag :tag => 'p', :content => /archived/
Chris@909 365 end
Chris@909 366
Chris@909 367 def test_private_subprojects_hidden
Chris@909 368 get :show, :id => 'ecookbook'
Chris@909 369 assert_response :success
Chris@909 370 assert_template 'show'
Chris@909 371 assert_no_tag :tag => 'a', :content => /Private child/
Chris@909 372 end
Chris@909 373
Chris@909 374 def test_private_subprojects_visible
Chris@909 375 @request.session[:user_id] = 2 # manager who is a member of the private subproject
Chris@909 376 get :show, :id => 'ecookbook'
Chris@909 377 assert_response :success
Chris@909 378 assert_template 'show'
Chris@909 379 assert_tag :tag => 'a', :content => /Private child/
Chris@909 380 end
Chris@909 381
Chris@909 382 def test_settings
Chris@909 383 @request.session[:user_id] = 2 # manager
Chris@909 384 get :settings, :id => 1
Chris@909 385 assert_response :success
Chris@909 386 assert_template 'settings'
Chris@909 387 end
Chris@909 388
Chris@909 389 def test_update
Chris@909 390 @request.session[:user_id] = 2 # manager
Chris@909 391 post :update, :id => 1, :project => {:name => 'Test changed name',
Chris@909 392 :issue_custom_field_ids => ['']}
Chris@909 393 assert_redirected_to '/projects/ecookbook/settings'
Chris@909 394 project = Project.find(1)
Chris@909 395 assert_equal 'Test changed name', project.name
Chris@909 396 end
Chris@909 397
Chris@909 398 def test_modules
Chris@909 399 @request.session[:user_id] = 2
Chris@909 400 Project.find(1).enabled_module_names = ['issue_tracking', 'news']
Chris@909 401
Chris@909 402 post :modules, :id => 1, :enabled_module_names => ['issue_tracking', 'repository', 'documents']
Chris@909 403 assert_redirected_to '/projects/ecookbook/settings/modules'
Chris@909 404 assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort
Chris@909 405 end
Chris@909 406
Chris@909 407 def test_modules_should_not_allow_get
Chris@909 408 @request.session[:user_id] = 1
Chris@909 409 get :modules, :id => 1
Chris@909 410 assert_response :method_not_allowed
Chris@909 411 end
Chris@909 412
Chris@909 413 def test_get_destroy
Chris@909 414 @request.session[:user_id] = 1 # admin
Chris@909 415 get :destroy, :id => 1
Chris@909 416 assert_response :success
Chris@909 417 assert_template 'destroy'
Chris@909 418 assert_not_nil Project.find_by_id(1)
Chris@909 419 end
Chris@909 420
Chris@909 421 def test_post_destroy
Chris@909 422 @request.session[:user_id] = 1 # admin
Chris@909 423 post :destroy, :id => 1, :confirm => 1
Chris@909 424 assert_redirected_to '/admin/projects'
Chris@909 425 assert_nil Project.find_by_id(1)
Chris@909 426 end
Chris@909 427
Chris@909 428 def test_archive
Chris@909 429 @request.session[:user_id] = 1 # admin
Chris@909 430 post :archive, :id => 1
Chris@909 431 assert_redirected_to '/admin/projects'
Chris@909 432 assert !Project.find(1).active?
Chris@909 433 end
Chris@909 434
Chris@909 435 def test_unarchive
Chris@909 436 @request.session[:user_id] = 1 # admin
Chris@909 437 Project.find(1).archive
Chris@909 438 post :unarchive, :id => 1
Chris@909 439 assert_redirected_to '/admin/projects'
Chris@909 440 assert Project.find(1).active?
Chris@909 441 end
Chris@909 442
Chris@909 443 def test_project_breadcrumbs_should_be_limited_to_3_ancestors
Chris@909 444 CustomField.delete_all
Chris@909 445 parent = nil
Chris@909 446 6.times do |i|
Chris@909 447 p = Project.create!(:name => "Breadcrumbs #{i}", :identifier => "breadcrumbs-#{i}")
Chris@909 448 p.set_parent!(parent)
Chris@909 449 get :show, :id => p
Chris@909 450 assert_tag :h1, :parent => { :attributes => {:id => 'header'}},
Chris@909 451 :children => { :count => [i, 3].min,
Chris@909 452 :only => { :tag => 'a' } }
Chris@909 453
Chris@909 454 parent = p
Chris@909 455 end
Chris@909 456 end
Chris@909 457
Chris@909 458 def test_get_copy
Chris@909 459 @request.session[:user_id] = 1 # admin
Chris@909 460 get :copy, :id => 1
Chris@909 461 assert_response :success
Chris@909 462 assert_template 'copy'
Chris@909 463 assert assigns(:project)
Chris@909 464 assert_equal Project.find(1).description, assigns(:project).description
Chris@909 465 assert_nil assigns(:project).id
Chris@909 466
Chris@909 467 assert_tag :tag => 'input',
Chris@909 468 :attributes => {:name => 'project[enabled_module_names][]', :value => 'issue_tracking'}
Chris@909 469 end
Chris@909 470
Chris@909 471 def test_get_copy_without_project
Chris@909 472 @request.session[:user_id] = 1 # admin
Chris@909 473 get :copy
Chris@909 474 assert_response :redirect
Chris@909 475 assert_redirected_to :controller => 'admin', :action => 'projects'
Chris@909 476 end
Chris@909 477
Chris@909 478 def test_post_copy_should_copy_requested_items
Chris@909 479 @request.session[:user_id] = 1 # admin
Chris@909 480 CustomField.delete_all
Chris@909 481
Chris@909 482 assert_difference 'Project.count' do
Chris@909 483 post :copy, :id => 1,
Chris@909 484 :project => {
Chris@909 485 :name => 'Copy',
Chris@909 486 :identifier => 'unique-copy',
Chris@909 487 :tracker_ids => ['1', '2', '3', ''],
Chris@909 488 :enabled_module_names => %w(issue_tracking time_tracking)
Chris@909 489 },
Chris@909 490 :only => %w(issues versions)
Chris@909 491 end
Chris@909 492 project = Project.find('unique-copy')
Chris@909 493 source = Project.find(1)
Chris@909 494 assert_equal %w(issue_tracking time_tracking), project.enabled_module_names.sort
Chris@909 495
Chris@909 496 assert_equal source.versions.count, project.versions.count, "All versions were not copied"
Chris@909 497 # issues assigned to a closed version won't be copied
Chris@909 498 assert_equal source.issues.select {|i| i.fixed_version.nil? || i.fixed_version.open?}.size,
Chris@909 499 project.issues.count, "All issues were not copied"
Chris@909 500 assert_equal 0, project.members.count
Chris@909 501 end
Chris@909 502
Chris@909 503 def test_post_copy_should_redirect_to_settings_when_successful
Chris@909 504 @request.session[:user_id] = 1 # admin
Chris@909 505 post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'}
Chris@909 506 assert_response :redirect
Chris@909 507 assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy'
Chris@909 508 end
Chris@909 509
Chris@909 510 def test_jump_should_redirect_to_active_tab
Chris@909 511 get :show, :id => 1, :jump => 'issues'
Chris@909 512 assert_redirected_to '/projects/ecookbook/issues'
Chris@909 513 end
Chris@909 514
Chris@909 515 def test_jump_should_not_redirect_to_inactive_tab
Chris@909 516 get :show, :id => 3, :jump => 'documents'
Chris@909 517 assert_response :success
Chris@909 518 assert_template 'show'
Chris@909 519 end
Chris@909 520
Chris@909 521 def test_jump_should_not_redirect_to_unknown_tab
Chris@909 522 get :show, :id => 3, :jump => 'foobar'
Chris@909 523 assert_response :success
Chris@909 524 assert_template 'show'
Chris@909 525 end
Chris@909 526
Chris@909 527 # A hook that is manually registered later
Chris@909 528 class ProjectBasedTemplate < Redmine::Hook::ViewListener
Chris@909 529 def view_layouts_base_html_head(context)
Chris@909 530 # Adds a project stylesheet
Chris@909 531 stylesheet_link_tag(context[:project].identifier) if context[:project]
Chris@909 532 end
Chris@909 533 end
Chris@909 534 # Don't use this hook now
Chris@909 535 Redmine::Hook.clear_listeners
Chris@909 536
Chris@909 537 def test_hook_response
Chris@909 538 Redmine::Hook.add_listener(ProjectBasedTemplate)
Chris@909 539 get :show, :id => 1
Chris@909 540 assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'},
Chris@909 541 :parent => {:tag => 'head'}
Chris@909 542
Chris@909 543 Redmine::Hook.clear_listeners
Chris@909 544 end
Chris@909 545 end