annotate .svn/pristine/dd/ddb17ba3f75574f7f21e99b4c8c77f26e54a423b.svn-base @ 1295:622f24f53b42 redmine-2.3

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