##// END OF EJS Templates
replace shoulda to Rails standard tests at functional gantts controller test...
Toshi MARUYAMA -
r9878:eb6260314400
parent child
Show More
@@ -1,95 +1,90
1 require File.expand_path('../../test_helper', __FILE__)
1 require File.expand_path('../../test_helper', __FILE__)
2
2
3 class GanttsControllerTest < ActionController::TestCase
3 class GanttsControllerTest < ActionController::TestCase
4 fixtures :projects, :trackers, :issue_statuses, :issues,
4 fixtures :projects, :trackers, :issue_statuses, :issues,
5 :enumerations, :users, :issue_categories,
5 :enumerations, :users, :issue_categories,
6 :projects_trackers,
6 :projects_trackers,
7 :roles,
7 :roles,
8 :member_roles,
8 :member_roles,
9 :members,
9 :members,
10 :enabled_modules,
10 :enabled_modules,
11 :workflows,
11 :workflows,
12 :versions
12 :versions
13
13
14 context "#gantt" do
14 def test_gantt_should_work
15 should "work" do
16 i2 = Issue.find(2)
15 i2 = Issue.find(2)
17 i2.update_attribute(:due_date, 1.month.from_now)
16 i2.update_attribute(:due_date, 1.month.from_now)
18
19 get :show, :project_id => 1
17 get :show, :project_id => 1
20 assert_response :success
18 assert_response :success
21 assert_template 'gantts/show'
19 assert_template 'gantts/show'
22 assert_not_nil assigns(:gantt)
20 assert_not_nil assigns(:gantt)
23 # Issue with start and due dates
21 # Issue with start and due dates
24 i = Issue.find(1)
22 i = Issue.find(1)
25 assert_not_nil i.due_date
23 assert_not_nil i.due_date
26 assert_select "div a.issue", /##{i.id}/
24 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
25 # Issue with on a targeted version should not be in the events but loaded in the html
28 i = Issue.find(2)
26 i = Issue.find(2)
29 assert_select "div a.issue", /##{i.id}/
27 assert_select "div a.issue", /##{i.id}/
30 end
28 end
31
29
32 should "work without issue due dates" do
30 def test_gantt_should_work_without_issue_due_dates
33 Issue.update_all("due_date = NULL")
31 Issue.update_all("due_date = NULL")
34
35 get :show, :project_id => 1
32 get :show, :project_id => 1
36 assert_response :success
33 assert_response :success
37 assert_template 'gantts/show'
34 assert_template 'gantts/show'
38 assert_not_nil assigns(:gantt)
35 assert_not_nil assigns(:gantt)
39 end
36 end
40
37
41 should "work without issue and version due dates" do
38 def test_gantt_should_work_without_issue_and_version_due_dates
42 Issue.update_all("due_date = NULL")
39 Issue.update_all("due_date = NULL")
43 Version.update_all("effective_date = NULL")
40 Version.update_all("effective_date = NULL")
44
45 get :show, :project_id => 1
41 get :show, :project_id => 1
46 assert_response :success
42 assert_response :success
47 assert_template 'gantts/show'
43 assert_template 'gantts/show'
48 assert_not_nil assigns(:gantt)
44 assert_not_nil assigns(:gantt)
49 end
45 end
50
46
51 should "work cross project" do
47 def test_gantt_should_work_cross_project
52 get :show
48 get :show
53 assert_response :success
49 assert_response :success
54 assert_template 'gantts/show'
50 assert_template 'gantts/show'
55 assert_not_nil assigns(:gantt)
51 assert_not_nil assigns(:gantt)
56 assert_not_nil assigns(:gantt).query
52 assert_not_nil assigns(:gantt).query
57 assert_nil assigns(:gantt).project
53 assert_nil assigns(:gantt).project
58 end
54 end
59
55
60 should "not disclose private projects" do
56 def test_gantt_should_not_disclose_private_projects
61 get :show
57 get :show
62 assert_response :success
58 assert_response :success
63 assert_template 'gantts/show'
59 assert_template 'gantts/show'
64
65 assert_tag 'a', :content => /eCookbook/
60 assert_tag 'a', :content => /eCookbook/
66 # Root private project
61 # Root private project
67 assert_no_tag 'a', {:content => /OnlineStore/}
62 assert_no_tag 'a', {:content => /OnlineStore/}
68 # Private children of a public project
63 # Private children of a public project
69 assert_no_tag 'a', :content => /Private child of eCookbook/
64 assert_no_tag 'a', :content => /Private child of eCookbook/
70 end
65 end
71
66
72 should "export to pdf" do
67 def test_gantt_should_export_to_pdf
73 get :show, :project_id => 1, :format => 'pdf'
68 get :show, :project_id => 1, :format => 'pdf'
74 assert_response :success
69 assert_response :success
75 assert_equal 'application/pdf', @response.content_type
70 assert_equal 'application/pdf', @response.content_type
76 assert @response.body.starts_with?('%PDF')
71 assert @response.body.starts_with?('%PDF')
77 assert_not_nil assigns(:gantt)
72 assert_not_nil assigns(:gantt)
78 end
73 end
79
74
80 should "export to pdf cross project" do
75 def test_gantt_should_export_to_pdf_cross_project
81 get :show, :format => 'pdf'
76 get :show, :format => 'pdf'
82 assert_response :success
77 assert_response :success
83 assert_equal 'application/pdf', @response.content_type
78 assert_equal 'application/pdf', @response.content_type
84 assert @response.body.starts_with?('%PDF')
79 assert @response.body.starts_with?('%PDF')
85 assert_not_nil assigns(:gantt)
80 assert_not_nil assigns(:gantt)
86 end
81 end
87
82
88 should "export to png" do
83 if Object.const_defined?(:Magick)
84 def test_gantt_should_export_to_png
89 get :show, :project_id => 1, :format => 'png'
85 get :show, :project_id => 1, :format => 'png'
90 assert_response :success
86 assert_response :success
91 assert_equal 'image/png', @response.content_type
87 assert_equal 'image/png', @response.content_type
92 end if Object.const_defined?(:Magick)
88 end
93
94 end
89 end
95 end
90 end
General Comments 0
You need to be logged in to leave comments. Login now