Defect #3705 ยป custom_values_can_be_nil.diff
test/functional/account_controller_test.rb (working copy) | ||
---|---|---|
37 | 37 |
assert_template 'show' |
38 | 38 |
assert_not_nil assigns(:user) |
39 | 39 |
end |
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 |
|
40 | 51 |
|
52 | ||
41 | 53 |
def test_show_inactive |
42 | 54 |
get :show, :id => 5 |
43 | 55 |
assert_response 404 |
test/functional/projects_controller_test.rb (working copy) | ||
---|---|---|
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 |
app/views/projects/show.rhtml (working copy) | ||
---|---|---|
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 || '').empty? %>
|
|
13 | 13 |
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li> |
14 | 14 |
<% end %> |
15 | 15 |
<% end %> |
app/views/account/show.rhtml (working copy) | ||
---|---|---|
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 || '').empty? %>
|
|
14 | 14 |
<li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li> |
15 | 15 |
<% end %> |
16 | 16 |
<% end %> |