Permalink
Browse files

Add Rakefile and fix tests

  • Loading branch information...
1 parent ab93650 commit 2f13d1047ff4cca2bda7382eae0a7ba002ac8adc @guilleiguaran committed Sep 5, 2012
View
@@ -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
@@ -1,4 +1,4 @@
-require "cases/helper"
+require "test_helper"
class BlackListTest < ActiveModel::TestCase
@@ -1,4 +1,4 @@
-require "cases/helper"
+require "test_helper"
class PermissionSetTest < ActiveModel::TestCase
@@ -1,4 +1,4 @@
-require "cases/helper"
+require "test_helper"
require 'active_support/logger'
class SanitizerTest < ActiveModel::TestCase
@@ -1,4 +1,4 @@
-require "cases/helper"
+require "test_helper"
class WhiteListTest < ActiveModel::TestCase
@@ -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
@@ -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

0 comments on commit 2f13d10

Please sign in to comment.