Mercurial > hg > soundsoftware-site
comparison test/functional/admin_controller_test.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
25 @request.session[:user_id] = 1 # admin | 25 @request.session[:user_id] = 1 # admin |
26 end | 26 end |
27 | 27 |
28 def test_index | 28 def test_index |
29 get :index | 29 get :index |
30 assert_no_tag :tag => 'div', | 30 assert_select 'div.nodata', 0 |
31 :attributes => { :class => /nodata/ } | |
32 end | 31 end |
33 | 32 |
34 def test_index_with_no_configuration_data | 33 def test_index_with_no_configuration_data |
35 delete_configuration_data | 34 delete_configuration_data |
36 get :index | 35 get :index |
37 assert_tag :tag => 'div', | 36 assert_select 'div.nodata' |
38 :attributes => { :class => /nodata/ } | |
39 end | 37 end |
40 | 38 |
41 def test_projects | 39 def test_projects |
42 get :projects | 40 get :projects |
43 assert_response :success | 41 assert_response :success |
88 user.pref[:no_self_notified] = '1' | 86 user.pref[:no_self_notified] = '1' |
89 user.pref.save! | 87 user.pref.save! |
90 ActionMailer::Base.deliveries.clear | 88 ActionMailer::Base.deliveries.clear |
91 | 89 |
92 get :test_email | 90 get :test_email |
93 assert_redirected_to '/settings/edit?tab=notifications' | 91 assert_redirected_to '/settings?tab=notifications' |
94 mail = ActionMailer::Base.deliveries.last | 92 mail = ActionMailer::Base.deliveries.last |
95 assert_not_nil mail | 93 assert_not_nil mail |
96 user = User.find(1) | 94 user = User.find(1) |
97 assert_equal [user.mail], mail.bcc | 95 assert_equal [user.mail], mail.bcc |
98 end | 96 end |
99 | 97 |
100 def test_test_email_failure_should_display_the_error | 98 def test_test_email_failure_should_display_the_error |
101 Mailer.stubs(:test_email).raises(Exception, 'Some error message') | 99 Mailer.stubs(:test_email).raises(Exception, 'Some error message') |
102 get :test_email | 100 get :test_email |
103 assert_redirected_to '/settings/edit?tab=notifications' | 101 assert_redirected_to '/settings?tab=notifications' |
104 assert_match /Some error message/, flash[:error] | 102 assert_match /Some error message/, flash[:error] |
105 end | 103 end |
106 | 104 |
107 def test_no_plugins | 105 def test_no_plugins |
108 Redmine::Plugin.clear | 106 Redmine::Plugin.clear |
126 | 124 |
127 get :plugins | 125 get :plugins |
128 assert_response :success | 126 assert_response :success |
129 assert_template 'plugins' | 127 assert_template 'plugins' |
130 | 128 |
131 assert_tag :td, :child => { :tag => 'span', :content => 'Foo plugin' } | 129 assert_select 'tr#plugin-foo' do |
132 assert_tag :td, :child => { :tag => 'span', :content => 'Bar' } | 130 assert_select 'td span.name', :text => 'Foo plugin' |
131 assert_select 'td.configure a[href=/settings/plugin/foo]' | |
132 end | |
133 assert_select 'tr#plugin-bar' do | |
134 assert_select 'td span.name', :text => 'Bar' | |
135 assert_select 'td.configure a', 0 | |
136 end | |
133 end | 137 end |
134 | 138 |
135 def test_info | 139 def test_info |
136 get :info | 140 get :info |
137 assert_response :success | 141 assert_response :success |
143 menu.push :test_admin_menu_plugin_extension, '/foo/bar', :caption => 'Test' | 147 menu.push :test_admin_menu_plugin_extension, '/foo/bar', :caption => 'Test' |
144 end | 148 end |
145 | 149 |
146 get :index | 150 get :index |
147 assert_response :success | 151 assert_response :success |
148 assert_tag :a, :attributes => { :href => '/foo/bar' }, | 152 assert_select 'div#admin-menu a[href=/foo/bar]', :text => 'Test' |
149 :content => 'Test' | |
150 | 153 |
151 Redmine::MenuManager.map :admin_menu do |menu| | 154 Redmine::MenuManager.map :admin_menu do |menu| |
152 menu.delete :test_admin_menu_plugin_extension | 155 menu.delete :test_admin_menu_plugin_extension |
153 end | 156 end |
154 end | 157 end |