Fixed: Custom values with a nil value cause error on (project|account)/show (#3705).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2894 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
41cbd239c4
commit
52a6b0a21e
@ -10,7 +10,7 @@
|
|||||||
<li><%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %></li>
|
<li><%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% for custom_value in @custom_values %>
|
<% for custom_value in @custom_values %>
|
||||||
<% if !custom_value.value.empty? %>
|
<% if !custom_value.value.blank? %>
|
||||||
<li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
<li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
|
<%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% @project.custom_values.each do |custom_value| %>
|
<% @project.custom_values.each do |custom_value| %>
|
||||||
<% if !custom_value.value.empty? %>
|
<% if !custom_value.value.blank? %>
|
||||||
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -38,6 +38,18 @@ class AccountControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:user)
|
assert_not_nil assigns(:user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_show_should_not_fail_when_custom_values_are_nil
|
||||||
|
user = User.find(2)
|
||||||
|
|
||||||
|
# Create a custom field to illustrate the issue
|
||||||
|
custom_field = CustomField.create!(:name => 'Testing', :field_format => 'text')
|
||||||
|
custom_value = user.custom_values.build(:custom_field => custom_field).save!
|
||||||
|
|
||||||
|
get :show, :id => 2
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_show_inactive
|
def test_show_inactive
|
||||||
get :show, :id => 5
|
get :show, :id => 5
|
||||||
assert_response 404
|
assert_response 404
|
||||||
|
@ -161,6 +161,16 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||||||
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_show_should_not_fail_when_custom_values_are_nil
|
||||||
|
project = Project.find_by_identifier('ecookbook')
|
||||||
|
project.custom_values.first.update_attribute(:value, nil)
|
||||||
|
get :show, :id => 'ecookbook'
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'show'
|
||||||
|
assert_not_nil assigns(:project)
|
||||||
|
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
||||||
|
end
|
||||||
|
|
||||||
def test_private_subprojects_hidden
|
def test_private_subprojects_hidden
|
||||||
get :show, :id => 'ecookbook'
|
get :show, :id => 'ecookbook'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
Loading…
x
Reference in New Issue
Block a user