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 / test / functional / .svn / text-base / gantts_controller_test.rb.svn-base @ 441:cbce1fd3b1b7

History | View | Annotate | Download (2.6 KB)

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

    
3
class GanttsControllerTest < ActionController::TestCase
4
  fixtures :all
5

    
6
  context "#gantt" do
7
    should "work" do
8
      i2 = Issue.find(2)
9
      i2.update_attribute(:due_date, 1.month.from_now)
10
      
11
      get :show, :project_id => 1
12
      assert_response :success
13
      assert_template 'show.html.erb'
14
      assert_not_nil assigns(:gantt)
15
      # Issue with start and due dates
16
      i = Issue.find(1)
17
      assert_not_nil i.due_date
18
      assert_select "div a.issue", /##{i.id}/
19
      # Issue with on a targeted version should not be in the events but loaded in the html
20
      i = Issue.find(2)
21
      assert_select "div a.issue", /##{i.id}/
22
    end
23
    
24
    should "work without issue due dates" do
25
      Issue.update_all("due_date = NULL")
26
      
27
      get :show, :project_id => 1
28
      assert_response :success
29
      assert_template 'show.html.erb'
30
      assert_not_nil assigns(:gantt)
31
    end
32
    
33
    should "work without issue and version due dates" do
34
      Issue.update_all("due_date = NULL")
35
      Version.update_all("effective_date = NULL")
36
      
37
      get :show, :project_id => 1
38
      assert_response :success
39
      assert_template 'show.html.erb'
40
      assert_not_nil assigns(:gantt)
41
    end
42

    
43
    should "work cross project" do
44
      get :show
45
      assert_response :success
46
      assert_template 'show.html.erb'
47
      assert_not_nil assigns(:gantt)
48
      assert_not_nil assigns(:gantt).query
49
      assert_nil assigns(:gantt).project
50
    end
51

    
52
    should "not disclose private projects" do
53
      get :show
54
      assert_response :success
55
      assert_template 'show.html.erb'
56
      
57
      assert_tag 'a', :content => /eCookbook/
58
      # Root private project
59
      assert_no_tag 'a', {:content => /OnlineStore/}
60
      # Private children of a public project
61
      assert_no_tag 'a', :content => /Private child of eCookbook/
62
    end
63

    
64
    should "export to pdf" do
65
      get :show, :project_id => 1, :format => 'pdf'
66
      assert_response :success
67
      assert_equal 'application/pdf', @response.content_type
68
      assert @response.body.starts_with?('%PDF')
69
      assert_not_nil assigns(:gantt)
70
    end
71

    
72
    should "export to pdf cross project" do
73
      get :show, :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 png" do
81
      get :show, :project_id => 1, :format => 'png'
82
      assert_response :success
83
      assert_equal 'image/png', @response.content_type
84
    end if Object.const_defined?(:Magick)
85

    
86
  end
87
end