annotate test/functional/gantts_controller_test.rb @ 1465:ab8bd24eeb65 bug_635

Close obsolete branch bug_635
author Chris Cannam
date Fri, 19 Jul 2013 12:13:20 +0100
parents 433d4f72a19b
children 622f24f53b42 261b3d9a4903
rev   line source
Chris@1115 1 # Redmine - project management software
Chris@1115 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
Chris@1115 3 #
Chris@1115 4 # This program is free software; you can redistribute it and/or
Chris@1115 5 # modify it under the terms of the GNU General Public License
Chris@1115 6 # as published by the Free Software Foundation; either version 2
Chris@1115 7 # of the License, or (at your option) any later version.
Chris@1115 8 #
Chris@1115 9 # This program is distributed in the hope that it will be useful,
Chris@1115 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1115 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1115 12 # GNU General Public License for more details.
Chris@1115 13 #
Chris@1115 14 # You should have received a copy of the GNU General Public License
Chris@1115 15 # along with this program; if not, write to the Free Software
Chris@1115 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1115 17
Chris@119 18 require File.expand_path('../../test_helper', __FILE__)
Chris@0 19
Chris@0 20 class GanttsControllerTest < ActionController::TestCase
Chris@909 21 fixtures :projects, :trackers, :issue_statuses, :issues,
Chris@909 22 :enumerations, :users, :issue_categories,
Chris@909 23 :projects_trackers,
Chris@909 24 :roles,
Chris@909 25 :member_roles,
Chris@909 26 :members,
Chris@909 27 :enabled_modules,
Chris@909 28 :workflows,
Chris@909 29 :versions
Chris@0 30
Chris@1115 31 def test_gantt_should_work
chris@22 32 i2 = Issue.find(2)
chris@22 33 i2.update_attribute(:due_date, 1.month.from_now)
Chris@0 34 get :show, :project_id => 1
Chris@0 35 assert_response :success
Chris@909 36 assert_template 'gantts/show'
Chris@0 37 assert_not_nil assigns(:gantt)
Chris@0 38 # Issue with start and due dates
Chris@0 39 i = Issue.find(1)
Chris@0 40 assert_not_nil i.due_date
chris@22 41 assert_select "div a.issue", /##{i.id}/
chris@22 42 # Issue with on a targeted version should not be in the events but loaded in the html
Chris@0 43 i = Issue.find(2)
chris@22 44 assert_select "div a.issue", /##{i.id}/
Chris@0 45 end
Chris@909 46
Chris@1115 47 def test_gantt_should_work_without_issue_due_dates
chris@37 48 Issue.update_all("due_date = NULL")
chris@37 49 get :show, :project_id => 1
chris@37 50 assert_response :success
Chris@909 51 assert_template 'gantts/show'
chris@37 52 assert_not_nil assigns(:gantt)
chris@37 53 end
Chris@909 54
Chris@1115 55 def test_gantt_should_work_without_issue_and_version_due_dates
chris@37 56 Issue.update_all("due_date = NULL")
chris@37 57 Version.update_all("effective_date = NULL")
chris@37 58 get :show, :project_id => 1
chris@37 59 assert_response :success
Chris@909 60 assert_template 'gantts/show'
chris@37 61 assert_not_nil assigns(:gantt)
chris@37 62 end
Chris@0 63
Chris@1115 64 def test_gantt_should_work_cross_project
Chris@0 65 get :show
Chris@0 66 assert_response :success
Chris@909 67 assert_template 'gantts/show'
Chris@0 68 assert_not_nil assigns(:gantt)
chris@22 69 assert_not_nil assigns(:gantt).query
chris@22 70 assert_nil assigns(:gantt).project
Chris@0 71 end
Chris@0 72
Chris@1115 73 def test_gantt_should_not_disclose_private_projects
Chris@119 74 get :show
Chris@119 75 assert_response :success
Chris@909 76 assert_template 'gantts/show'
Chris@119 77 assert_tag 'a', :content => /eCookbook/
Chris@119 78 # Root private project
Chris@119 79 assert_no_tag 'a', {:content => /OnlineStore/}
Chris@119 80 # Private children of a public project
Chris@119 81 assert_no_tag 'a', :content => /Private child of eCookbook/
Chris@119 82 end
Chris@119 83
Chris@1115 84 def test_gantt_should_export_to_pdf
Chris@0 85 get :show, :project_id => 1, :format => 'pdf'
Chris@0 86 assert_response :success
Chris@0 87 assert_equal 'application/pdf', @response.content_type
Chris@0 88 assert @response.body.starts_with?('%PDF')
Chris@0 89 assert_not_nil assigns(:gantt)
Chris@0 90 end
Chris@0 91
Chris@1115 92 def test_gantt_should_export_to_pdf_cross_project
Chris@0 93 get :show, :format => 'pdf'
Chris@0 94 assert_response :success
Chris@0 95 assert_equal 'application/pdf', @response.content_type
Chris@0 96 assert @response.body.starts_with?('%PDF')
Chris@0 97 assert_not_nil assigns(:gantt)
Chris@0 98 end
Chris@909 99
Chris@1115 100 if Object.const_defined?(:Magick)
Chris@1115 101 def test_gantt_should_export_to_png
Chris@1115 102 get :show, :project_id => 1, :format => 'png'
Chris@1115 103 assert_response :success
Chris@1115 104 assert_equal 'image/png', @response.content_type
Chris@1115 105 end
Chris@1115 106 end
Chris@0 107 end