Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Rakefile and fix tests

  • Loading branch information...
commit 2f13d1047ff4cca2bda7382eae0a7ba002ac8adc 1 parent ab93650
@guilleiguaran guilleiguaran authored
View
10 Rakefile
@@ -1 +1,11 @@
+#!/usr/bin/env rake
require "bundler/gem_tasks"
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+ t.libs = ["test"]
+ t.pattern = "test/**/*_test.rb"
+ t.ruby_opts = ['-w']
+end
+
+task :default => :test
View
2  test/mass_assignment_security/black_list_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require "test_helper"
class BlackListTest < ActiveModel::TestCase
View
2  test/mass_assignment_security/permission_set_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require "test_helper"
class PermissionSetTest < ActiveModel::TestCase
View
2  test/mass_assignment_security/sanitizer_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require "test_helper"
require 'active_support/logger'
class SanitizerTest < ActiveModel::TestCase
View
2  test/mass_assignment_security/white_list_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require "test_helper"
class WhiteListTest < ActiveModel::TestCase
View
16 test/mass_assignment_security_test.rb
@@ -71,11 +71,11 @@ def test_attributes_protected_by_default
end
def test_mass_assignment_protection_inheritance
- assert_blank LoosePerson.accessible_attributes
- assert_equal Set.new(['credit_rating', 'administrator']), LoosePerson.protected_attributes
+ assert_blank SpecialLoosePerson.accessible_attributes
+ assert_equal Set.new(['credit_rating', 'administrator']), SpecialLoosePerson.protected_attributes
- assert_blank LoosePerson.accessible_attributes
- assert_equal Set.new(['credit_rating']), LoosePerson.protected_attributes(:admin)
+ assert_blank SpecialLoosePerson.accessible_attributes
+ assert_equal Set.new(['credit_rating']), SpecialLoosePerson.protected_attributes(:admin)
assert_blank LooseDescendant.accessible_attributes
assert_equal Set.new(['credit_rating', 'administrator', 'phone_number']), LooseDescendant.protected_attributes
@@ -84,11 +84,11 @@ def test_mass_assignment_protection_inheritance
assert_equal Set.new(['credit_rating', 'administrator', 'phone_number', 'name']), LooseDescendantSecond.protected_attributes,
'Running attr_protected twice in one class should merge the protections'
- assert_blank TightPerson.protected_attributes - TightPerson.attributes_protected_by_default
- assert_equal Set.new(['name', 'address']), TightPerson.accessible_attributes
+ assert_blank SpecialTightPerson.protected_attributes - SpecialTightPerson.attributes_protected_by_default
+ assert_equal Set.new(['name', 'address']), SpecialTightPerson.accessible_attributes
- assert_blank TightPerson.protected_attributes(:admin) - TightPerson.attributes_protected_by_default
- assert_equal Set.new(['name', 'address', 'admin']), TightPerson.accessible_attributes(:admin)
+ assert_blank SpecialTightPerson.protected_attributes(:admin) - SpecialTightPerson.attributes_protected_by_default
+ assert_equal Set.new(['name', 'address', 'admin']), SpecialTightPerson.accessible_attributes(:admin)
assert_blank TightDescendant.protected_attributes - TightDescendant.attributes_protected_by_default
assert_equal Set.new(['name', 'address', 'phone_number']), TightDescendant.accessible_attributes
View
10 test/models/mass_assignment_specific.rb
@@ -45,22 +45,22 @@ class Task
public :sanitize_for_mass_assignment
end
-class LoosePerson
+class SpecialLoosePerson
include ActiveModel::MassAssignmentSecurity
attr_protected :credit_rating, :administrator
attr_protected :credit_rating, :as => :admin
end
-class LooseDescendant < LoosePerson
+class LooseDescendant < SpecialLoosePerson
attr_protected :phone_number
end
-class LooseDescendantSecond< LoosePerson
+class LooseDescendantSecond< SpecialLoosePerson
attr_protected :phone_number
attr_protected :name
end
-class TightPerson
+class SpecialTightPerson
include ActiveModel::MassAssignmentSecurity
attr_accessible :name, :address
attr_accessible :name, :address, :admin, :as => :admin
@@ -70,7 +70,7 @@ def self.attributes_protected_by_default
end
end
-class TightDescendant < TightPerson
+class TightDescendant < SpecialTightPerson
attr_accessible :phone_number
attr_accessible :super_powers, :as => :admin
end
Please sign in to comment.
Something went wrong with that request. Please try again.