To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / 44 / 44669c27372c172ef04555f4bb81865f6ca83884.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (2.82 KB)

1
require File.expand_path('../../test_helper', __FILE__)
2

    
3
class GanttsControllerTest < ActionController::TestCase
4
  fixtures :projects, :trackers, :issue_statuses, :issues,
5
           :enumerations, :users, :issue_categories,
6
           :projects_trackers,
7
           :roles,
8
           :member_roles,
9
           :members,
10
           :enabled_modules,
11
           :workflows,
12
           :versions
13

    
14
  context "#gantt" do
15
    should "work" do
16
      i2 = Issue.find(2)
17
      i2.update_attribute(:due_date, 1.month.from_now)
18

    
19
      get :show, :project_id => 1
20
      assert_response :success
21
      assert_template 'gantts/show'
22
      assert_not_nil assigns(:gantt)
23
      # Issue with start and due dates
24
      i = Issue.find(1)
25
      assert_not_nil i.due_date
26
      assert_select "div a.issue", /##{i.id}/
27
      # Issue with on a targeted version should not be in the events but loaded in the html
28
      i = Issue.find(2)
29
      assert_select "div a.issue", /##{i.id}/
30
    end
31

    
32
    should "work without issue due dates" do
33
      Issue.update_all("due_date = NULL")
34

    
35
      get :show, :project_id => 1
36
      assert_response :success
37
      assert_template 'gantts/show'
38
      assert_not_nil assigns(:gantt)
39
    end
40

    
41
    should "work without issue and version due dates" do
42
      Issue.update_all("due_date = NULL")
43
      Version.update_all("effective_date = NULL")
44

    
45
      get :show, :project_id => 1
46
      assert_response :success
47
      assert_template 'gantts/show'
48
      assert_not_nil assigns(:gantt)
49
    end
50

    
51
    should "work cross project" do
52
      get :show
53
      assert_response :success
54
      assert_template 'gantts/show'
55
      assert_not_nil assigns(:gantt)
56
      assert_not_nil assigns(:gantt).query
57
      assert_nil assigns(:gantt).project
58
    end
59

    
60
    should "not disclose private projects" do
61
      get :show
62
      assert_response :success
63
      assert_template 'gantts/show'
64

    
65
      assert_tag 'a', :content => /eCookbook/
66
      # Root private project
67
      assert_no_tag 'a', {:content => /OnlineStore/}
68
      # Private children of a public project
69
      assert_no_tag 'a', :content => /Private child of eCookbook/
70
    end
71

    
72
    should "export to pdf" do
73
      get :show, :project_id => 1, :format => 'pdf'
74
      assert_response :success
75
      assert_equal 'application/pdf', @response.content_type
76
      assert @response.body.starts_with?('%PDF')
77
      assert_not_nil assigns(:gantt)
78
    end
79

    
80
    should "export to pdf cross project" do
81
      get :show, :format => 'pdf'
82
      assert_response :success
83
      assert_equal 'application/pdf', @response.content_type
84
      assert @response.body.starts_with?('%PDF')
85
      assert_not_nil assigns(:gantt)
86
    end
87

    
88
    should "export to png" do
89
      get :show, :project_id => 1, :format => 'png'
90
      assert_response :success
91
      assert_equal 'image/png', @response.content_type
92
    end if Object.const_defined?(:Magick)
93

    
94
  end
95
end