提交 da420b6e 编写于 作者: J Justin Collins

Add test for model name when rendering collection

instead of "UnknownModel"
上级 94fd4fb6
<tr>
<td><%= user.name %></td>
<td><%= render 'bio', :locals => { :user_bio => raw(user.bio) } %>
<td><%= user.password %></td>
<td><%= user.email %></td>
<td><%= user.role %></td>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
......@@ -12,18 +12,7 @@
<th></th>
</tr>
<% @users.each do |user| %>
<tr>
<td><%= user.name %></td>
<td><%= user.bio %></td>
<td><%= user.password %></td>
<td><%= user.email %></td>
<td><%= user.role %></td>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
<%= render 'user', :collection => @users %>
</table>
<br />
......
......@@ -335,7 +335,7 @@ class Rails3Tests < Test::Unit::TestCase
assert_warning :type => :template,
:warning_type => "Cross Site Scripting",
:line => 1,
:message => /^Unescaped model attribute near line 1: \(/,
:message => /^Unescaped model attribute near line 1: User.new.first_name/,
:confidence => 0,
:file => /_user\.html\.erb/
end
......
......@@ -13,7 +13,7 @@ class Rails31Tests < Test::Unit::TestCase
def expected
@expected ||= {
:model => 0,
:template => 16,
:template => 17,
:controller => 1,
:warning => 48 }
end
......@@ -527,6 +527,15 @@ class Rails31Tests < Test::Unit::TestCase
:file => /\/g\.html\.erb/
end
def test_model_name_in_collection_xss
assert_warning :type => :template,
:warning_type => "Cross Site Scripting",
:line => 1,
:message => /^Unescaped model attribute near line 1: User\.new\.bio/,
:confidence => 0,
:file => /_bio\.html\.erb/
end
def test_xss_multiple_exp_in_string_interpolation
assert_warning :type => :template,
:warning_type => "Cross Site Scripting",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册