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

Add tests for more mass assignment methods

上级 1b3621f7
......@@ -109,6 +109,16 @@ class HomeController < ApplicationController
YAML.parse_file("whatever/" + params[:file_name])
end
def test_more_mass_assignment_methods
User.new(params[:user])
User.first_or_create(params[:user])
User.first_or_create!(:name => params[:user][:name])
User.first_or_initialize!(params[:user])
User.update(params[:id], :alive => false) #No warning
User.update(1, params[:update])
User.find(1).assign_attributes(params[:update])
end
private
def filter_it
......
......@@ -598,6 +598,51 @@ class Rails3Tests < Test::Unit::TestCase
:file => /other_controller\.rb/
end
def test_mass_assignment_first_or_create
assert_warning :type => :warning,
:warning_type => "Mass Assignment",
:line => 114,
:message => /^Unprotected\ mass\ assignment/,
:confidence => 0,
:file => /home_controller\.rb/
end
def test_mass_assignment_first_or_create!
assert_warning :type => :warning,
:warning_type => "Mass Assignment",
:line => 115,
:message => /^Unprotected\ mass\ assignment/,
:confidence => 2,
:file => /home_controller\.rb/
end
def test_mass_assignment_first_or_initialize!
assert_warning :type => :warning,
:warning_type => "Mass Assignment",
:line => 116,
:message => /^Unprotected\ mass\ assignment/,
:confidence => 0,
:file => /home_controller\.rb/
end
def test_mass_assignment_update
assert_warning :type => :warning,
:warning_type => "Mass Assignment",
:line => 118,
:message => /^Unprotected\ mass\ assignment/,
:confidence => 0,
:file => /home_controller\.rb/
end
def test_mass_assignment_assign_attributes
assert_warning :type => :warning,
:warning_type => "Mass Assignment",
:line => 119,
:message => /^Unprotected\ mass\ assignment/,
:confidence => 0,
:file => /home_controller\.rb/
end
def test_translate_bug
assert_warning :type => :warning,
:warning_type => "Cross Site Scripting",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册