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