annotate .svn/pristine/2e/2eb44b7abed16dd8cc469c08dde7704eb259a823.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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