'with_kcode' removed.

Testing Sandbox removed.
This commit is contained in:
Arun Agrawal 2011-12-21 15:39:50 +05:30
parent de78c7e8e4
commit 7276fc63be
7 changed files with 18 additions and 58 deletions

View File

@ -1,15 +0,0 @@
module TestingSandbox
# Temporarily replaces KCODE for the block
def with_kcode(kcode)
if RUBY_VERSION < '1.9'
old_kcode, $KCODE = $KCODE, kcode
begin
yield
ensure
$KCODE = old_kcode
end
else
yield
end
end
end

View File

@ -1,9 +1,7 @@
require 'abstract_unit' require 'abstract_unit'
require 'testing_sandbox'
class OutputSafetyHelperTest < ActionView::TestCase class OutputSafetyHelperTest < ActionView::TestCase
tests ActionView::Helpers::OutputSafetyHelper tests ActionView::Helpers::OutputSafetyHelper
include TestingSandbox
def setup def setup
@string = "hello" @string = "hello"

View File

@ -1,11 +1,9 @@
require 'abstract_unit' require 'abstract_unit'
require 'testing_sandbox'
# The exhaustive tests are in test/controller/html/sanitizer_test.rb. # The exhaustive tests are in test/controller/html/sanitizer_test.rb.
# This tests the that the helpers hook up correctly to the sanitizer classes. # This tests the that the helpers hook up correctly to the sanitizer classes.
class SanitizeHelperTest < ActionView::TestCase class SanitizeHelperTest < ActionView::TestCase
tests ActionView::Helpers::SanitizeHelper tests ActionView::Helpers::SanitizeHelper
include TestingSandbox
def test_strip_links def test_strip_links
assert_equal "Dont touch me", strip_links("Dont touch me") assert_equal "Dont touch me", strip_links("Dont touch me")

View File

@ -1,10 +1,8 @@
# encoding: utf-8 # encoding: utf-8
require 'abstract_unit' require 'abstract_unit'
require 'testing_sandbox'
class TextHelperTest < ActionView::TestCase class TextHelperTest < ActionView::TestCase
tests ActionView::Helpers::TextHelper tests ActionView::Helpers::TextHelper
include TestingSandbox
def setup def setup
super super

View File

@ -56,18 +56,5 @@ module ActiveRecord
ensure ensure
ActiveRecord::SQLCounter.ignored_sql = prev_ignored_sql ActiveRecord::SQLCounter.ignored_sql = prev_ignored_sql
end end
def with_kcode(kcode)
if RUBY_VERSION < '1.9'
orig_kcode, $KCODE = $KCODE, kcode
begin
yield
ensure
$KCODE = orig_kcode
end
else
yield
end
end
end end
end end

View File

@ -91,7 +91,6 @@ class AssociationValidationTest < ActiveRecord::TestCase
end end
def test_validates_size_of_association_utf8 def test_validates_size_of_association_utf8
with_kcode('UTF8') do
assert_nothing_raised { Owner.validates_size_of :pets, :minimum => 1 } assert_nothing_raised { Owner.validates_size_of :pets, :minimum => 1 }
o = Owner.new('name' => 'あいうえおかきくけこ') o = Owner.new('name' => 'あいうえおかきくけこ')
assert !o.save assert !o.save
@ -99,7 +98,6 @@ class AssociationValidationTest < ActiveRecord::TestCase
o.pets.build('name' => 'あいうえおかきくけこ') o.pets.build('name' => 'あいうえおかきくけこ')
assert o.valid? assert o.valid?
end end
end
def test_validates_presence_of_belongs_to_association__parent_is_new_record def test_validates_presence_of_belongs_to_association__parent_is_new_record
repair_validations(Interest) do repair_validations(Interest) do

View File

@ -149,7 +149,6 @@ class UniquenessValidationTest < ActiveRecord::TestCase
assert t2.valid?, "should validate with nil" assert t2.valid?, "should validate with nil"
assert t2.save, "should save with nil" assert t2.save, "should save with nil"
with_kcode('UTF8') do
t_utf8 = Topic.new("title" => "Я тоже уникальный!") t_utf8 = Topic.new("title" => "Я тоже уникальный!")
assert t_utf8.save, "Should save t_utf8 as unique" assert t_utf8.save, "Should save t_utf8 as unique"
@ -160,7 +159,6 @@ class UniquenessValidationTest < ActiveRecord::TestCase
assert !t2_utf8.save, "Shouldn't save t2_utf8 as unique" assert !t2_utf8.save, "Shouldn't save t2_utf8 as unique"
end end
end end
end
def test_validate_case_sensitive_uniqueness_with_special_sql_like_chars def test_validate_case_sensitive_uniqueness_with_special_sql_like_chars
Topic.validates_uniqueness_of(:title, :case_sensitive => true) Topic.validates_uniqueness_of(:title, :case_sensitive => true)
@ -256,14 +254,12 @@ class UniquenessValidationTest < ActiveRecord::TestCase
end end
def test_validate_uniqueness_with_limit_and_utf8 def test_validate_uniqueness_with_limit_and_utf8
with_kcode('UTF8') do
# Event.title is limited to 5 characters # Event.title is limited to 5 characters
e1 = Event.create(:title => "一二三四五") e1 = Event.create(:title => "一二三四五")
assert e1.valid?, "Could not create an event with a unique, 5 character title" assert e1.valid?, "Could not create an event with a unique, 5 character title"
e2 = Event.create(:title => "一二三四五六七八") e2 = Event.create(:title => "一二三四五六七八")
assert !e2.valid?, "Created an event whose title, with limit taken into account, is not unique" assert !e2.valid?, "Created an event whose title, with limit taken into account, is not unique"
end end
end
def test_validate_straight_inheritance_uniqueness def test_validate_straight_inheritance_uniqueness
w1 = IneptWizard.create(:name => "Rincewind", :city => "Ankh-Morpork") w1 = IneptWizard.create(:name => "Rincewind", :city => "Ankh-Morpork")