##// END OF EJS Templates
Fix a few requires for metric_fu's rcov....
Eric Davis -
r3799:70973fda64de
parent child
Show More
@@ -1,83 +1,83
1 require 'test_helper'
1 require File.dirname(__FILE__) + '/../test_helper'
2
2
3 class AuthSourcesControllerTest < ActionController::TestCase
3 class AuthSourcesControllerTest < ActionController::TestCase
4 fixtures :all
4 fixtures :all
5
5
6 def setup
6 def setup
7 @request.session[:user_id] = 1
7 @request.session[:user_id] = 1
8 end
8 end
9
9
10 context "get :index" do
10 context "get :index" do
11 setup do
11 setup do
12 get :index
12 get :index
13 end
13 end
14
14
15 should_assign_to :auth_sources
15 should_assign_to :auth_sources
16 should_assign_to :auth_source_pages
16 should_assign_to :auth_source_pages
17 should_respond_with :success
17 should_respond_with :success
18 should_render_template :index
18 should_render_template :index
19 end
19 end
20
20
21 context "get :new" do
21 context "get :new" do
22 setup do
22 setup do
23 get :new
23 get :new
24 end
24 end
25
25
26 should_assign_to :auth_source
26 should_assign_to :auth_source
27 should_respond_with :success
27 should_respond_with :success
28 should_render_template :new
28 should_render_template :new
29
29
30 should "initilize a new AuthSource" do
30 should "initilize a new AuthSource" do
31 assert_equal AuthSource, assigns(:auth_source).class
31 assert_equal AuthSource, assigns(:auth_source).class
32 assert assigns(:auth_source).new_record?
32 assert assigns(:auth_source).new_record?
33 end
33 end
34 end
34 end
35
35
36 context "post :create" do
36 context "post :create" do
37 setup do
37 setup do
38 post :create, :auth_source => {:name => 'Test'}
38 post :create, :auth_source => {:name => 'Test'}
39 end
39 end
40
40
41 should_respond_with :redirect
41 should_respond_with :redirect
42 should_redirect_to("index") {{:action => 'index'}}
42 should_redirect_to("index") {{:action => 'index'}}
43 should_set_the_flash_to /success/i
43 should_set_the_flash_to /success/i
44 end
44 end
45
45
46 context "get :edit" do
46 context "get :edit" do
47 setup do
47 setup do
48 @auth_source = AuthSource.generate!(:name => 'TestEdit')
48 @auth_source = AuthSource.generate!(:name => 'TestEdit')
49 get :edit, :id => @auth_source.id
49 get :edit, :id => @auth_source.id
50 end
50 end
51
51
52 should_assign_to(:auth_source) {@auth_source}
52 should_assign_to(:auth_source) {@auth_source}
53 should_respond_with :success
53 should_respond_with :success
54 should_render_template :edit
54 should_render_template :edit
55 end
55 end
56
56
57 context "post :update" do
57 context "post :update" do
58 setup do
58 setup do
59 @auth_source = AuthSource.generate!(:name => 'TestEdit')
59 @auth_source = AuthSource.generate!(:name => 'TestEdit')
60 post :update, :id => @auth_source.id, :auth_source => {:name => 'TestUpdate'}
60 post :update, :id => @auth_source.id, :auth_source => {:name => 'TestUpdate'}
61 end
61 end
62
62
63 should_respond_with :redirect
63 should_respond_with :redirect
64 should_redirect_to("index") {{:action => 'index'}}
64 should_redirect_to("index") {{:action => 'index'}}
65 should_set_the_flash_to /update/i
65 should_set_the_flash_to /update/i
66 end
66 end
67
67
68 context "post :destroy" do
68 context "post :destroy" do
69 context "without users" do
69 context "without users" do
70 setup do
70 setup do
71 @auth_source = AuthSource.generate!(:name => 'TestEdit')
71 @auth_source = AuthSource.generate!(:name => 'TestEdit')
72 post :destroy, :id => @auth_source.id
72 post :destroy, :id => @auth_source.id
73 end
73 end
74
74
75 should_respond_with :redirect
75 should_respond_with :redirect
76 should_redirect_to("index") {{:action => 'index'}}
76 should_redirect_to("index") {{:action => 'index'}}
77 should_set_the_flash_to /deletion/i
77 should_set_the_flash_to /deletion/i
78
78
79 end
79 end
80
80
81 should "be tested with users"
81 should "be tested with users"
82 end
82 end
83 end
83 end
@@ -1,64 +1,64
1 require 'test_helper'
1 require File.dirname(__FILE__) + '/../test_helper'
2
2
3 class CalendarsControllerTest < ActionController::TestCase
3 class CalendarsControllerTest < ActionController::TestCase
4 fixtures :all
4 fixtures :all
5
5
6 def test_calendar
6 def test_calendar
7 get :show, :project_id => 1
7 get :show, :project_id => 1
8 assert_response :success
8 assert_response :success
9 assert_template 'calendar'
9 assert_template 'calendar'
10 assert_not_nil assigns(:calendar)
10 assert_not_nil assigns(:calendar)
11 end
11 end
12
12
13 def test_cross_project_calendar
13 def test_cross_project_calendar
14 get :show
14 get :show
15 assert_response :success
15 assert_response :success
16 assert_template 'calendar'
16 assert_template 'calendar'
17 assert_not_nil assigns(:calendar)
17 assert_not_nil assigns(:calendar)
18 end
18 end
19
19
20 def test_week_number_calculation
20 def test_week_number_calculation
21 Setting.start_of_week = 7
21 Setting.start_of_week = 7
22
22
23 get :show, :month => '1', :year => '2010'
23 get :show, :month => '1', :year => '2010'
24 assert_response :success
24 assert_response :success
25
25
26 assert_tag :tag => 'tr',
26 assert_tag :tag => 'tr',
27 :descendant => {:tag => 'td',
27 :descendant => {:tag => 'td',
28 :attributes => {:class => 'week-number'}, :content => '53'},
28 :attributes => {:class => 'week-number'}, :content => '53'},
29 :descendant => {:tag => 'td',
29 :descendant => {:tag => 'td',
30 :attributes => {:class => 'odd'}, :content => '27'},
30 :attributes => {:class => 'odd'}, :content => '27'},
31 :descendant => {:tag => 'td',
31 :descendant => {:tag => 'td',
32 :attributes => {:class => 'even'}, :content => '2'}
32 :attributes => {:class => 'even'}, :content => '2'}
33
33
34 assert_tag :tag => 'tr',
34 assert_tag :tag => 'tr',
35 :descendant => {:tag => 'td',
35 :descendant => {:tag => 'td',
36 :attributes => {:class => 'week-number'}, :content => '1'},
36 :attributes => {:class => 'week-number'}, :content => '1'},
37 :descendant => {:tag => 'td',
37 :descendant => {:tag => 'td',
38 :attributes => {:class => 'odd'}, :content => '3'},
38 :attributes => {:class => 'odd'}, :content => '3'},
39 :descendant => {:tag => 'td',
39 :descendant => {:tag => 'td',
40 :attributes => {:class => 'even'}, :content => '9'}
40 :attributes => {:class => 'even'}, :content => '9'}
41
41
42
42
43 Setting.start_of_week = 1
43 Setting.start_of_week = 1
44 get :show, :month => '1', :year => '2010'
44 get :show, :month => '1', :year => '2010'
45 assert_response :success
45 assert_response :success
46
46
47 assert_tag :tag => 'tr',
47 assert_tag :tag => 'tr',
48 :descendant => {:tag => 'td',
48 :descendant => {:tag => 'td',
49 :attributes => {:class => 'week-number'}, :content => '53'},
49 :attributes => {:class => 'week-number'}, :content => '53'},
50 :descendant => {:tag => 'td',
50 :descendant => {:tag => 'td',
51 :attributes => {:class => 'even'}, :content => '28'},
51 :attributes => {:class => 'even'}, :content => '28'},
52 :descendant => {:tag => 'td',
52 :descendant => {:tag => 'td',
53 :attributes => {:class => 'even'}, :content => '3'}
53 :attributes => {:class => 'even'}, :content => '3'}
54
54
55 assert_tag :tag => 'tr',
55 assert_tag :tag => 'tr',
56 :descendant => {:tag => 'td',
56 :descendant => {:tag => 'td',
57 :attributes => {:class => 'week-number'}, :content => '1'},
57 :attributes => {:class => 'week-number'}, :content => '1'},
58 :descendant => {:tag => 'td',
58 :descendant => {:tag => 'td',
59 :attributes => {:class => 'even'}, :content => '4'},
59 :attributes => {:class => 'even'}, :content => '4'},
60 :descendant => {:tag => 'td',
60 :descendant => {:tag => 'td',
61 :attributes => {:class => 'even'}, :content => '10'}
61 :attributes => {:class => 'even'}, :content => '10'}
62
62
63 end
63 end
64 end
64 end
@@ -1,56 +1,56
1 require 'test_helper'
1 require File.dirname(__FILE__) + '/../test_helper'
2
2
3 class GanttsControllerTest < ActionController::TestCase
3 class GanttsControllerTest < ActionController::TestCase
4 fixtures :all
4 fixtures :all
5
5
6 context "#gantt" do
6 context "#gantt" do
7 should "work" do
7 should "work" do
8 get :show, :project_id => 1
8 get :show, :project_id => 1
9 assert_response :success
9 assert_response :success
10 assert_template 'show.html.erb'
10 assert_template 'show.html.erb'
11 assert_not_nil assigns(:gantt)
11 assert_not_nil assigns(:gantt)
12 events = assigns(:gantt).events
12 events = assigns(:gantt).events
13 assert_not_nil events
13 assert_not_nil events
14 # Issue with start and due dates
14 # Issue with start and due dates
15 i = Issue.find(1)
15 i = Issue.find(1)
16 assert_not_nil i.due_date
16 assert_not_nil i.due_date
17 assert events.include?(Issue.find(1))
17 assert events.include?(Issue.find(1))
18 # Issue with without due date but targeted to a version with date
18 # Issue with without due date but targeted to a version with date
19 i = Issue.find(2)
19 i = Issue.find(2)
20 assert_nil i.due_date
20 assert_nil i.due_date
21 assert events.include?(i)
21 assert events.include?(i)
22 end
22 end
23
23
24 should "work cross project" do
24 should "work cross project" do
25 get :show
25 get :show
26 assert_response :success
26 assert_response :success
27 assert_template 'show.html.erb'
27 assert_template 'show.html.erb'
28 assert_not_nil assigns(:gantt)
28 assert_not_nil assigns(:gantt)
29 events = assigns(:gantt).events
29 events = assigns(:gantt).events
30 assert_not_nil events
30 assert_not_nil events
31 end
31 end
32
32
33 should "export to pdf" do
33 should "export to pdf" do
34 get :show, :project_id => 1, :format => 'pdf'
34 get :show, :project_id => 1, :format => 'pdf'
35 assert_response :success
35 assert_response :success
36 assert_equal 'application/pdf', @response.content_type
36 assert_equal 'application/pdf', @response.content_type
37 assert @response.body.starts_with?('%PDF')
37 assert @response.body.starts_with?('%PDF')
38 assert_not_nil assigns(:gantt)
38 assert_not_nil assigns(:gantt)
39 end
39 end
40
40
41 should "export to pdf cross project" do
41 should "export to pdf cross project" do
42 get :show, :format => 'pdf'
42 get :show, :format => 'pdf'
43 assert_response :success
43 assert_response :success
44 assert_equal 'application/pdf', @response.content_type
44 assert_equal 'application/pdf', @response.content_type
45 assert @response.body.starts_with?('%PDF')
45 assert @response.body.starts_with?('%PDF')
46 assert_not_nil assigns(:gantt)
46 assert_not_nil assigns(:gantt)
47 end
47 end
48
48
49 should "export to png" do
49 should "export to png" do
50 get :show, :project_id => 1, :format => 'png'
50 get :show, :project_id => 1, :format => 'png'
51 assert_response :success
51 assert_response :success
52 assert_equal 'image/png', @response.content_type
52 assert_equal 'image/png', @response.content_type
53 end if Object.const_defined?(:Magick)
53 end if Object.const_defined?(:Magick)
54
54
55 end
55 end
56 end
56 end
General Comments 0
You need to be logged in to leave comments. Login now