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