##// END OF EJS Templates
Fixed that enumerations option tags are escaped....
Jean-Philippe Lang -
r9498:69e55fb1ef26
parent child
Show More
@@ -1,12 +1,12
1 1 <h2><%= l(@enumeration.option_name) %>: <%=h @enumeration %></h2>
2 2
3 3 <%= form_tag({}, :method => :delete) do %>
4 4 <div class="box">
5 5 <p><strong><%= l(:text_enumeration_destroy_question, @enumeration.objects_count) %></strong></p>
6 6 <p><label for='reassign_to_id'><%= l(:text_enumeration_category_reassign_to) %></label>
7 <%= select_tag 'reassign_to_id', ("<option>--- #{l(:actionview_instancetag_blank_option)} ---</option>" + options_from_collection_for_select(@enumerations, 'id', 'name')) %></p>
7 <%= select_tag 'reassign_to_id', (content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---") + options_from_collection_for_select(@enumerations, 'id', 'name')) %></p>
8 8 </div>
9 9
10 10 <%= submit_tag l(:button_apply) %>
11 11 <%= link_to l(:button_cancel), enumerations_path %>
12 12 <% end %>
@@ -1,120 +1,123
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class EnumerationsControllerTest < ActionController::TestCase
21 21 fixtures :enumerations, :issues, :users
22 22
23 23 def setup
24 24 @request.session[:user_id] = 1 # admin
25 25 end
26 26
27 27 def test_index
28 28 get :index
29 29 assert_response :success
30 30 assert_template 'index'
31 31 end
32 32
33 33 def test_new
34 34 get :new, :type => 'IssuePriority'
35 35 assert_response :success
36 36 assert_template 'new'
37 37 assert_kind_of IssuePriority, assigns(:enumeration)
38 38 assert_tag 'input', :attributes => {:name => 'enumeration[type]', :value => 'IssuePriority'}
39 39 assert_tag 'input', :attributes => {:name => 'enumeration[name]'}
40 40 end
41 41
42 42 def test_new_with_invalid_type_should_respond_with_404
43 43 get :new, :type => 'UnknownType'
44 44 assert_response 404
45 45 end
46 46
47 47 def test_create
48 48 assert_difference 'IssuePriority.count' do
49 49 post :create, :enumeration => {:type => 'IssuePriority', :name => 'Lowest'}
50 50 end
51 51 assert_redirected_to '/enumerations?type=IssuePriority'
52 52 e = IssuePriority.find_by_name('Lowest')
53 53 assert_not_nil e
54 54 end
55 55
56 56 def test_create_with_failure
57 57 assert_no_difference 'IssuePriority.count' do
58 58 post :create, :enumeration => {:type => 'IssuePriority', :name => ''}
59 59 end
60 60 assert_response :success
61 61 assert_template 'new'
62 62 end
63 63
64 64 def test_edit
65 65 get :edit, :id => 6
66 66 assert_response :success
67 67 assert_template 'edit'
68 68 assert_tag 'input', :attributes => {:name => 'enumeration[name]', :value => 'High'}
69 69 end
70 70
71 71 def test_edit_invalid_should_respond_with_404
72 72 get :edit, :id => 999
73 73 assert_response 404
74 74 end
75 75
76 76 def test_update
77 77 assert_no_difference 'IssuePriority.count' do
78 78 put :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => 'New name'}
79 79 end
80 80 assert_redirected_to '/enumerations?type=IssuePriority'
81 81 e = IssuePriority.find(6)
82 82 assert_equal 'New name', e.name
83 83 end
84 84
85 85 def test_update_with_failure
86 86 assert_no_difference 'IssuePriority.count' do
87 87 put :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => ''}
88 88 end
89 89 assert_response :success
90 90 assert_template 'edit'
91 91 end
92 92
93 93 def test_destroy_enumeration_not_in_use
94 94 assert_difference 'IssuePriority.count', -1 do
95 95 delete :destroy, :id => 7
96 96 end
97 97 assert_redirected_to :controller => 'enumerations', :action => 'index'
98 98 assert_nil Enumeration.find_by_id(7)
99 99 end
100 100
101 101 def test_destroy_enumeration_in_use
102 102 assert_no_difference 'IssuePriority.count' do
103 103 delete :destroy, :id => 4
104 104 end
105 105 assert_response :success
106 106 assert_template 'destroy'
107 107 assert_not_nil Enumeration.find_by_id(4)
108 assert_select 'select[name=reassign_to_id]' do
109 assert_select 'option[value=6]', :text => 'High'
110 end
108 111 end
109 112
110 113 def test_destroy_enumeration_in_use_with_reassignment
111 114 issue = Issue.find(:first, :conditions => {:priority_id => 4})
112 115 assert_difference 'IssuePriority.count', -1 do
113 116 delete :destroy, :id => 4, :reassign_to_id => 6
114 117 end
115 118 assert_redirected_to :controller => 'enumerations', :action => 'index'
116 119 assert_nil Enumeration.find_by_id(4)
117 120 # check that the issue was reassign
118 121 assert_equal 6, issue.reload.priority_id
119 122 end
120 123 end
General Comments 0
You need to be logged in to leave comments. Login now