You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gantts_controller_test.rb 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. require File.expand_path('../../test_helper', __FILE__)
  2. class GanttsControllerTest < ActionController::TestCase
  3. fixtures :projects, :trackers, :issue_statuses, :issues,
  4. :enumerations, :users, :issue_categories,
  5. :projects_trackers,
  6. :roles,
  7. :member_roles,
  8. :members,
  9. :enabled_modules,
  10. :workflows,
  11. :versions
  12. context "#gantt" do
  13. should "work" do
  14. i2 = Issue.find(2)
  15. i2.update_attribute(:due_date, 1.month.from_now)
  16. get :show, :project_id => 1
  17. assert_response :success
  18. assert_template 'gantts/show'
  19. assert_not_nil assigns(:gantt)
  20. # Issue with start and due dates
  21. i = Issue.find(1)
  22. assert_not_nil i.due_date
  23. assert_select "div a.issue", /##{i.id}/
  24. # Issue with on a targeted version should not be in the events but loaded in the html
  25. i = Issue.find(2)
  26. assert_select "div a.issue", /##{i.id}/
  27. end
  28. should "work without issue due dates" do
  29. Issue.update_all("due_date = NULL")
  30. get :show, :project_id => 1
  31. assert_response :success
  32. assert_template 'gantts/show'
  33. assert_not_nil assigns(:gantt)
  34. end
  35. should "work without issue and version due dates" do
  36. Issue.update_all("due_date = NULL")
  37. Version.update_all("effective_date = NULL")
  38. get :show, :project_id => 1
  39. assert_response :success
  40. assert_template 'gantts/show'
  41. assert_not_nil assigns(:gantt)
  42. end
  43. should "work cross project" do
  44. get :show
  45. assert_response :success
  46. assert_template 'gantts/show'
  47. assert_not_nil assigns(:gantt)
  48. assert_not_nil assigns(:gantt).query
  49. assert_nil assigns(:gantt).project
  50. end
  51. should "not disclose private projects" do
  52. get :show
  53. assert_response :success
  54. assert_template 'gantts/show'
  55. assert_tag 'a', :content => /eCookbook/
  56. # Root private project
  57. assert_no_tag 'a', {:content => /OnlineStore/}
  58. # Private children of a public project
  59. assert_no_tag 'a', :content => /Private child of eCookbook/
  60. end
  61. should "export to pdf" do
  62. get :show, :project_id => 1, :format => 'pdf'
  63. assert_response :success
  64. assert_equal 'application/pdf', @response.content_type
  65. assert @response.body.starts_with?('%PDF')
  66. assert_not_nil assigns(:gantt)
  67. end
  68. should "export to pdf cross project" do
  69. get :show, :format => 'pdf'
  70. assert_response :success
  71. assert_equal 'application/pdf', @response.content_type
  72. assert @response.body.starts_with?('%PDF')
  73. assert_not_nil assigns(:gantt)
  74. end
  75. should "export to png" do
  76. get :show, :project_id => 1, :format => 'png'
  77. assert_response :success
  78. assert_equal 'image/png', @response.content_type
  79. end if Object.const_defined?(:Magick)
  80. end
  81. end