aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_controller/test_case.rb12
-rw-r--r--actionpack/test/controller/url_rewriter_test.rb2
-rw-r--r--activerecord/test/cases/tasks/sqlite_rake_test.rb8
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute.rb9
4 files changed, 18 insertions, 13 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index eb7194ebaf..4ccb77992e 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -529,11 +529,19 @@ module ActionController
@response = TestResponse.new
@response.request = @request
+ @controller = nil unless defined? @controller
+
if klass = self.class.controller_class
- @controller ||= klass.new rescue nil
+ unless @controller
+ begin
+ @controller = klass.new
+ rescue
+ warn "could not construct controller #{klass}" if $VERBOSE
+ end
+ end
end
- if defined?(@controller) && @controller
+ if @controller
@controller.request = @request
@controller.params = {}
end
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb
index cc3706aeee..d9a1ae7d4f 100644
--- a/actionpack/test/controller/url_rewriter_test.rb
+++ b/actionpack/test/controller/url_rewriter_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'controller/fake_controllers'
-class UrlRewriterTests < ActionController::TestCase
+class UrlRewriterTests < ActiveSupport::TestCase
class Rewriter
def initialize(request)
@options = {
diff --git a/activerecord/test/cases/tasks/sqlite_rake_test.rb b/activerecord/test/cases/tasks/sqlite_rake_test.rb
index 06a1d0ffc2..7209c0f14d 100644
--- a/activerecord/test/cases/tasks/sqlite_rake_test.rb
+++ b/activerecord/test/cases/tasks/sqlite_rake_test.rb
@@ -162,8 +162,8 @@ module ActiveRecord
assert File.exists?(dbfile)
assert File.exists?(filename)
ensure
- FileUtils.rm(filename)
- FileUtils.rm(dbfile)
+ FileUtils.rm_f(filename)
+ FileUtils.rm_f(dbfile)
end
end
@@ -184,8 +184,8 @@ module ActiveRecord
ActiveRecord::Tasks::DatabaseTasks.structure_load @configuration, filename, '/rails/root'
assert File.exists?(dbfile)
ensure
- FileUtils.rm(filename)
- FileUtils.rm(dbfile)
+ FileUtils.rm_f(filename)
+ FileUtils.rm_f(dbfile)
end
end
end
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb
index 7b6f8ab0a1..da0a12136c 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -79,14 +79,12 @@ class Class
def self.#{name}=(val)
singleton_class.class_eval do
- remove_possible_method(:#{name})
- define_method(:#{name}) { val }
+ redefine_method(:#{name}) { val }
end
if singleton_class?
class_eval do
- remove_possible_method(:#{name})
- def #{name}
+ redefine_method(:#{name}) do
defined?(@#{name}) ? @#{name} : singleton_class.#{name}
end
end
@@ -95,8 +93,7 @@ class Class
end
if instance_reader
- remove_possible_method :#{name}
- def #{name}
+ redefine_method(:#{name}) do
defined?(@#{name}) ? @#{name} : self.class.#{name}
end