aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-12-15 01:23:05 +0000
committerRick Olson <technoweenie@gmail.com>2007-12-15 01:23:05 +0000
commitabd7cf343c3f43516d25e3b787e96af38d12ebf4 (patch)
tree0cbbcdc46e53c34ea86c91f66f71d5986e7af8c5 /activerecord/lib/active_record
parent1ceccdeb7f86898a9e511e934ea6b0863d30590d (diff)
downloadrails-abd7cf343c3f43516d25e3b787e96af38d12ebf4.tar.gz
rails-abd7cf343c3f43516d25e3b787e96af38d12ebf4.tar.bz2
rails-abd7cf343c3f43516d25e3b787e96af38d12ebf4.zip
Make the Fixtures Test::Unit enhancements more supporting for double-loaded test cases. Closes #10379 [brynary]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8392 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/fixtures.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 7a00b5bb56..0da8c514d7 100755
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -916,6 +916,8 @@ module Test #:nodoc:
end
def setup_with_fixtures
+ return if @fixtures_setup
+ @fixtures_setup = true
return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
if pre_loaded_fixtures && !use_transactional_fixtures
@@ -947,6 +949,8 @@ module Test #:nodoc:
alias_method :setup, :setup_with_fixtures
def teardown_with_fixtures
+ return if @fixtures_teardown
+ @fixtures_teardown = true
return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
unless use_transactional_fixtures?
@@ -963,24 +967,31 @@ module Test #:nodoc:
alias_method :teardown, :teardown_with_fixtures
def self.method_added(method)
+ return if @__disable_method_added__
+ @__disable_method_added__ = true
+
case method.to_s
when 'setup'
unless method_defined?(:setup_without_fixtures)
alias_method :setup_without_fixtures, :setup
- define_method(:setup) do
+ define_method(:full_setup) do
setup_with_fixtures
setup_without_fixtures
end
end
+ alias_method :setup, :full_setup
when 'teardown'
unless method_defined?(:teardown_without_fixtures)
alias_method :teardown_without_fixtures, :teardown
- define_method(:teardown) do
+ define_method(:full_teardown) do
teardown_without_fixtures
teardown_with_fixtures
end
end
+ alias_method :teardown, :full_teardown
end
+
+ @__disable_method_added__ = false
end
private