##// END OF EJS Templates
Fixed: Custom values with a nil value cause error on (project|account)/show (#3705)....
Jean-Philippe Lang -
r2780:52a6b0a21e5e
parent child
Show More
@@ -10,7 +10,7
10 10 <li><%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %></li>
11 11 <% end %>
12 12 <% for custom_value in @custom_values %>
13 <% if !custom_value.value.empty? %>
13 <% if !custom_value.value.blank? %>
14 14 <li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
15 15 <% end %>
16 16 <% end %>
@@ -9,7 +9,7
9 9 <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
10 10 <% end %>
11 11 <% @project.custom_values.each do |custom_value| %>
12 <% if !custom_value.value.empty? %>
12 <% if !custom_value.value.blank? %>
13 13 <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
14 14 <% end %>
15 15 <% end %>
@@ -38,6 +38,18 class AccountControllerTest < ActionController::TestCase
38 38 assert_not_nil assigns(:user)
39 39 end
40 40
41 def test_show_should_not_fail_when_custom_values_are_nil
42 user = User.find(2)
43
44 # Create a custom field to illustrate the issue
45 custom_field = CustomField.create!(:name => 'Testing', :field_format => 'text')
46 custom_value = user.custom_values.build(:custom_field => custom_field).save!
47
48 get :show, :id => 2
49 assert_response :success
50 end
51
52
41 53 def test_show_inactive
42 54 get :show, :id => 5
43 55 assert_response 404
@@ -161,6 +161,16 class ProjectsControllerTest < ActionController::TestCase
161 161 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
162 162 end
163 163
164 def test_show_should_not_fail_when_custom_values_are_nil
165 project = Project.find_by_identifier('ecookbook')
166 project.custom_values.first.update_attribute(:value, nil)
167 get :show, :id => 'ecookbook'
168 assert_response :success
169 assert_template 'show'
170 assert_not_nil assigns(:project)
171 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
172 end
173
164 174 def test_private_subprojects_hidden
165 175 get :show, :id => 'ecookbook'
166 176 assert_response :success
General Comments 0
You need to be logged in to leave comments. Login now