Chris@1115: # Redmine - project management software Chris@1115: # Copyright (C) 2006-2012 Jean-Philippe Lang Chris@1115: # Chris@1115: # This program is free software; you can redistribute it and/or Chris@1115: # modify it under the terms of the GNU General Public License Chris@1115: # as published by the Free Software Foundation; either version 2 Chris@1115: # of the License, or (at your option) any later version. Chris@1115: # Chris@1115: # This program is distributed in the hope that it will be useful, Chris@1115: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@1115: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@1115: # GNU General Public License for more details. Chris@1115: # Chris@1115: # You should have received a copy of the GNU General Public License Chris@1115: # along with this program; if not, write to the Free Software Chris@1115: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@1115: Chris@119: require File.expand_path('../../test_helper', __FILE__) Chris@0: Chris@0: class GanttsControllerTest < ActionController::TestCase Chris@909: fixtures :projects, :trackers, :issue_statuses, :issues, Chris@909: :enumerations, :users, :issue_categories, Chris@909: :projects_trackers, Chris@909: :roles, Chris@909: :member_roles, Chris@909: :members, Chris@909: :enabled_modules, Chris@909: :workflows, Chris@909: :versions Chris@0: Chris@1115: def test_gantt_should_work chris@22: i2 = Issue.find(2) chris@22: i2.update_attribute(:due_date, 1.month.from_now) Chris@0: get :show, :project_id => 1 Chris@0: assert_response :success Chris@909: assert_template 'gantts/show' Chris@0: assert_not_nil assigns(:gantt) Chris@0: # Issue with start and due dates Chris@0: i = Issue.find(1) Chris@0: assert_not_nil i.due_date chris@22: assert_select "div a.issue", /##{i.id}/ chris@22: # Issue with on a targeted version should not be in the events but loaded in the html Chris@0: i = Issue.find(2) chris@22: assert_select "div a.issue", /##{i.id}/ Chris@0: end Chris@909: Chris@1115: def test_gantt_should_work_without_issue_due_dates chris@37: Issue.update_all("due_date = NULL") chris@37: get :show, :project_id => 1 chris@37: assert_response :success Chris@909: assert_template 'gantts/show' chris@37: assert_not_nil assigns(:gantt) chris@37: end Chris@909: Chris@1115: def test_gantt_should_work_without_issue_and_version_due_dates chris@37: Issue.update_all("due_date = NULL") chris@37: Version.update_all("effective_date = NULL") chris@37: get :show, :project_id => 1 chris@37: assert_response :success Chris@909: assert_template 'gantts/show' chris@37: assert_not_nil assigns(:gantt) chris@37: end Chris@0: Chris@1115: def test_gantt_should_work_cross_project Chris@0: get :show Chris@0: assert_response :success Chris@909: assert_template 'gantts/show' Chris@0: assert_not_nil assigns(:gantt) chris@22: assert_not_nil assigns(:gantt).query chris@22: assert_nil assigns(:gantt).project Chris@0: end Chris@0: Chris@1115: def test_gantt_should_not_disclose_private_projects Chris@119: get :show Chris@119: assert_response :success Chris@909: assert_template 'gantts/show' Chris@119: assert_tag 'a', :content => /eCookbook/ Chris@119: # Root private project Chris@119: assert_no_tag 'a', {:content => /OnlineStore/} Chris@119: # Private children of a public project Chris@119: assert_no_tag 'a', :content => /Private child of eCookbook/ Chris@119: end Chris@119: Chris@1115: def test_gantt_should_export_to_pdf Chris@0: get :show, :project_id => 1, :format => 'pdf' Chris@0: assert_response :success Chris@0: assert_equal 'application/pdf', @response.content_type Chris@0: assert @response.body.starts_with?('%PDF') Chris@0: assert_not_nil assigns(:gantt) Chris@0: end Chris@0: Chris@1115: def test_gantt_should_export_to_pdf_cross_project Chris@0: get :show, :format => 'pdf' Chris@0: assert_response :success Chris@0: assert_equal 'application/pdf', @response.content_type Chris@0: assert @response.body.starts_with?('%PDF') Chris@0: assert_not_nil assigns(:gantt) Chris@0: end Chris@909: Chris@1115: if Object.const_defined?(:Magick) Chris@1115: def test_gantt_should_export_to_png Chris@1115: get :show, :project_id => 1, :format => 'png' Chris@1115: assert_response :success Chris@1115: assert_equal 'image/png', @response.content_type Chris@1115: end Chris@1115: end Chris@0: end