You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

settings_controller_test.rb 4.5 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2013 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. require File.expand_path('../../test_helper', __FILE__)
  18. class SettingsControllerTest < ActionController::TestCase
  19. fixtures :users
  20. def setup
  21. User.current = nil
  22. @request.session[:user_id] = 1 # admin
  23. end
  24. def test_index
  25. get :index
  26. assert_response :success
  27. assert_template 'edit'
  28. end
  29. def test_get_edit
  30. get :edit
  31. assert_response :success
  32. assert_template 'edit'
  33. assert_tag 'input', :attributes => {:name => 'settings[enabled_scm][]', :value => ''}
  34. end
  35. def test_get_edit_should_preselect_default_issue_list_columns
  36. with_settings :issue_list_default_columns => %w(tracker subject status updated_on) do
  37. get :edit
  38. assert_response :success
  39. end
  40. assert_select 'select[id=selected_columns][name=?]', 'settings[issue_list_default_columns][]' do
  41. assert_select 'option', 4
  42. assert_select 'option[value=tracker]', :text => 'Tracker'
  43. assert_select 'option[value=subject]', :text => 'Subject'
  44. assert_select 'option[value=status]', :text => 'Status'
  45. assert_select 'option[value=updated_on]', :text => 'Updated'
  46. end
  47. assert_select 'select[id=available_columns]' do
  48. assert_select 'option[value=tracker]', 0
  49. assert_select 'option[value=priority]', :text => 'Priority'
  50. end
  51. end
  52. def test_get_edit_without_trackers_should_succeed
  53. Tracker.delete_all
  54. get :edit
  55. assert_response :success
  56. end
  57. def test_post_edit_notifications
  58. post :edit, :settings => {:mail_from => 'functional@test.foo',
  59. :bcc_recipients => '0',
  60. :notified_events => %w(issue_added issue_updated news_added),
  61. :emails_footer => 'Test footer'
  62. }
  63. assert_redirected_to '/settings'
  64. assert_equal 'functional@test.foo', Setting.mail_from
  65. assert !Setting.bcc_recipients?
  66. assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
  67. assert_equal 'Test footer', Setting.emails_footer
  68. Setting.clear_cache
  69. end
  70. def test_get_plugin_settings
  71. Setting.stubs(:plugin_foo).returns({'sample_setting' => 'Plugin setting value'})
  72. ActionController::Base.append_view_path(File.join(Rails.root, "test/fixtures/plugins"))
  73. Redmine::Plugin.register :foo do
  74. settings :partial => "foo_plugin/foo_plugin_settings"
  75. end
  76. get :plugin, :id => 'foo'
  77. assert_response :success
  78. assert_template 'plugin'
  79. assert_tag 'form', :attributes => {:action => '/settings/plugin/foo'},
  80. :descendant => {:tag => 'input', :attributes => {:name => 'settings[sample_setting]', :value => 'Plugin setting value'}}
  81. Redmine::Plugin.clear
  82. end
  83. def test_get_invalid_plugin_settings
  84. get :plugin, :id => 'none'
  85. assert_response 404
  86. end
  87. def test_get_non_configurable_plugin_settings
  88. Redmine::Plugin.register(:foo) {}
  89. get :plugin, :id => 'foo'
  90. assert_response 404
  91. Redmine::Plugin.clear
  92. end
  93. def test_post_plugin_settings
  94. Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true)
  95. Redmine::Plugin.register(:foo) do
  96. settings :partial => 'not blank' # so that configurable? is true
  97. end
  98. post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
  99. assert_redirected_to '/settings/plugin/foo'
  100. end
  101. def test_post_non_configurable_plugin_settings
  102. Redmine::Plugin.register(:foo) {}
  103. post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
  104. assert_response 404
  105. Redmine::Plugin.clear
  106. end
  107. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...