annotate .svn/pristine/dd/ddb17ba3f75574f7f21e99b4c8c77f26e54a423b.svn-base @ 1488:423d68919ebb redmine-2.4-integration

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