comparison .svn/pristine/dd/ddb17ba3f75574f7f21e99b4c8c77f26e54a423b.svn-base @ 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
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
18 require File.expand_path('../../test_helper', __FILE__)
19
20 class SettingsControllerTest < ActionController::TestCase
21 fixtures :users
22
23 def setup
24 User.current = nil
25 @request.session[:user_id] = 1 # admin
26 end
27
28 def test_index
29 get :index
30 assert_response :success
31 assert_template 'edit'
32 end
33
34 def test_get_edit
35 get :edit
36 assert_response :success
37 assert_template 'edit'
38
39 assert_tag 'input', :attributes => {:name => 'settings[enabled_scm][]', :value => ''}
40 end
41
42 def test_get_edit_should_preselect_default_issue_list_columns
43 with_settings :issue_list_default_columns => %w(tracker subject status updated_on) do
44 get :edit
45 assert_response :success
46 end
47
48 assert_select 'select[id=selected_columns][name=?]', 'settings[issue_list_default_columns][]' do
49 assert_select 'option', 4
50 assert_select 'option[value=tracker]', :text => 'Tracker'
51 assert_select 'option[value=subject]', :text => 'Subject'
52 assert_select 'option[value=status]', :text => 'Status'
53 assert_select 'option[value=updated_on]', :text => 'Updated'
54 end
55
56 assert_select 'select[id=available_columns]' do
57 assert_select 'option[value=tracker]', 0
58 assert_select 'option[value=priority]', :text => 'Priority'
59 end
60 end
61
62 def test_get_edit_without_trackers_should_succeed
63 Tracker.delete_all
64
65 get :edit
66 assert_response :success
67 end
68
69 def test_post_edit_notifications
70 post :edit, :settings => {:mail_from => 'functional@test.foo',
71 :bcc_recipients => '0',
72 :notified_events => %w(issue_added issue_updated news_added),
73 :emails_footer => 'Test footer'
74 }
75 assert_redirected_to '/settings'
76 assert_equal 'functional@test.foo', Setting.mail_from
77 assert !Setting.bcc_recipients?
78 assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
79 assert_equal 'Test footer', Setting.emails_footer
80 Setting.clear_cache
81 end
82
83 def test_get_plugin_settings
84 Setting.stubs(:plugin_foo).returns({'sample_setting' => 'Plugin setting value'})
85 ActionController::Base.append_view_path(File.join(Rails.root, "test/fixtures/plugins"))
86 Redmine::Plugin.register :foo do
87 settings :partial => "foo_plugin/foo_plugin_settings"
88 end
89
90 get :plugin, :id => 'foo'
91 assert_response :success
92 assert_template 'plugin'
93 assert_tag 'form', :attributes => {:action => '/settings/plugin/foo'},
94 :descendant => {:tag => 'input', :attributes => {:name => 'settings[sample_setting]', :value => 'Plugin setting value'}}
95
96 Redmine::Plugin.clear
97 end
98
99 def test_get_invalid_plugin_settings
100 get :plugin, :id => 'none'
101 assert_response 404
102 end
103
104 def test_get_non_configurable_plugin_settings
105 Redmine::Plugin.register(:foo) {}
106
107 get :plugin, :id => 'foo'
108 assert_response 404
109
110 Redmine::Plugin.clear
111 end
112
113 def test_post_plugin_settings
114 Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true)
115 Redmine::Plugin.register(:foo) do
116 settings :partial => 'not blank' # so that configurable? is true
117 end
118
119 post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
120 assert_redirected_to '/settings/plugin/foo'
121 end
122
123 def test_post_non_configurable_plugin_settings
124 Redmine::Plugin.register(:foo) {}
125
126 post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
127 assert_response 404
128
129 Redmine::Plugin.clear
130 end
131 end