mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merged pull request #318 from joshk/fix_tests.
fix mass-assignment security tests
This commit is contained in:
commit
2cac007c41
2 changed files with 15 additions and 15 deletions
|
@ -35,10 +35,10 @@ class MassAssignmentSecurityTest < ActiveRecord::TestCase
|
||||||
p = LoosePerson.new
|
p = LoosePerson.new
|
||||||
p.assign_attributes(attributes_hash)
|
p.assign_attributes(attributes_hash)
|
||||||
|
|
||||||
assert_equal nil, p.id
|
assert_equal nil, p.id
|
||||||
assert_equal 'Josh', p.first_name
|
assert_equal 'Josh', p.first_name
|
||||||
assert_equal 'male', p.gender
|
assert_equal 'm', p.gender
|
||||||
assert_equal nil, p.comments
|
assert_equal nil, p.comments
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assign_attributes_skips_mass_assignment_security_protection_when_without_protection_is_used
|
def test_assign_attributes_skips_mass_assignment_security_protection_when_without_protection_is_used
|
||||||
|
@ -47,7 +47,7 @@ class MassAssignmentSecurityTest < ActiveRecord::TestCase
|
||||||
|
|
||||||
assert_equal 5, p.id
|
assert_equal 5, p.id
|
||||||
assert_equal 'Josh', p.first_name
|
assert_equal 'Josh', p.first_name
|
||||||
assert_equal 'male', p.gender
|
assert_equal 'm', p.gender
|
||||||
assert_equal 'rides a sweet bike', p.comments
|
assert_equal 'rides a sweet bike', p.comments
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class MassAssignmentSecurityTest < ActiveRecord::TestCase
|
||||||
|
|
||||||
assert_equal nil, p.id
|
assert_equal nil, p.id
|
||||||
assert_equal 'Josh', p.first_name
|
assert_equal 'Josh', p.first_name
|
||||||
assert_equal 'male', p.gender
|
assert_equal 'm', p.gender
|
||||||
assert_equal nil, p.comments
|
assert_equal nil, p.comments
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class MassAssignmentSecurityTest < ActiveRecord::TestCase
|
||||||
|
|
||||||
assert_equal nil, p.id
|
assert_equal nil, p.id
|
||||||
assert_equal 'Josh', p.first_name
|
assert_equal 'Josh', p.first_name
|
||||||
assert_equal 'male', p.gender
|
assert_equal 'm', p.gender
|
||||||
assert_equal 'rides a sweet bike', p.comments
|
assert_equal 'rides a sweet bike', p.comments
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class MassAssignmentSecurityTest < ActiveRecord::TestCase
|
||||||
|
|
||||||
assert_equal nil, p.id
|
assert_equal nil, p.id
|
||||||
assert_equal 'Josh', p.first_name
|
assert_equal 'Josh', p.first_name
|
||||||
assert_equal 'male', p.gender
|
assert_equal 'm', p.gender
|
||||||
assert_equal nil, p.comments
|
assert_equal nil, p.comments
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class MassAssignmentSecurityTest < ActiveRecord::TestCase
|
||||||
|
|
||||||
assert_equal nil, p.id
|
assert_equal nil, p.id
|
||||||
assert_equal 'Josh', p.first_name
|
assert_equal 'Josh', p.first_name
|
||||||
assert_equal 'male', p.gender
|
assert_equal 'm', p.gender
|
||||||
assert_equal 'rides a sweet bike', p.comments
|
assert_equal 'rides a sweet bike', p.comments
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class MassAssignmentSecurityTest < ActiveRecord::TestCase
|
||||||
{
|
{
|
||||||
:id => 5,
|
:id => 5,
|
||||||
:first_name => 'Josh',
|
:first_name => 'Josh',
|
||||||
:gender => 'male',
|
:gender => 'm',
|
||||||
:comments => 'rides a sweet bike'
|
:comments => 'rides a sweet bike'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -493,21 +493,21 @@ class PersistencesTest < ActiveRecord::TestCase
|
||||||
|
|
||||||
def test_update_attributes_as_admin
|
def test_update_attributes_as_admin
|
||||||
person = TightPerson.create
|
person = TightPerson.create
|
||||||
person.update_attributes({ "first_name" => 'Josh', "gender" => 'male', "comments" => 'from NZ' }, :as => :admin)
|
person.update_attributes({ "first_name" => 'Josh', "gender" => 'm', "comments" => 'from NZ' }, :as => :admin)
|
||||||
person.reload
|
person.reload
|
||||||
|
|
||||||
assert_equal 'Josh', person.first_name
|
assert_equal 'Josh', person.first_name
|
||||||
assert_equal 'male', person.gender
|
assert_equal 'm', person.gender
|
||||||
assert_equal 'from NZ', person.comments
|
assert_equal 'from NZ', person.comments
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_attributes_as_without_protection
|
def test_update_attributes_as_without_protection
|
||||||
person = TightPerson.create
|
person = TightPerson.create
|
||||||
person.update_attributes({ "first_name" => 'Josh', "gender" => 'male', "comments" => 'from NZ' }, :without_protection => true)
|
person.update_attributes({ "first_name" => 'Josh', "gender" => 'm', "comments" => 'from NZ' }, :without_protection => true)
|
||||||
person.reload
|
person.reload
|
||||||
|
|
||||||
assert_equal 'Josh', person.first_name
|
assert_equal 'Josh', person.first_name
|
||||||
assert_equal 'male', person.gender
|
assert_equal 'm', person.gender
|
||||||
assert_equal 'from NZ', person.comments
|
assert_equal 'from NZ', person.comments
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue