Changeset 3840
- Timestamp:
- 03/12/06 00:08:26 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/integration_test.rb
r3836 r3840 462 462 %w(get post cookies assigns).each do |method| 463 463 define_method(method) do |*args| 464 @integration_session.send(method, *args) 464 reset! unless @integration_session 465 returning @integration_session.send(method, *args) do 466 copy_session_variables! 467 end 465 468 end 466 469 end … … 480 483 481 484 # delegate the fixture accessors back to the test instance 482 klass = class<<session; self; end 483 tests = self 484 485 extras = Module.new { attr_accessor :delegate, :test_result } 485 486 self.class.fixture_table_names.each do |table_name| 486 487 name = table_name.tr(".", "_") 487 488 next unless respond_to?(name) 488 klass.send(:define_method, name) { |*args| tests.send(name, *args) }489 extras.send(:define_method, name) { |*args| delegate.send(name, *args) } 489 490 end 490 491 491 492 # delegate add_assertion to the test case 492 klass.send(:define_method, :add_assertion) { tests.add_assertion } 493 extras.send(:define_method, :add_assertion) { test_result.add_assertion } 494 session.extend(extras) 495 session.delegate = self 496 session.test_result = @_result 493 497 494 498 yield session if block_given? 495 499 session 500 end 501 502 # Copy the instance variables from the current session instance into the 503 # test instance. 504 def copy_session_variables! #:nodoc: 505 return unless @integration_session 506 %w(controller response request).each do |var| 507 instance_variable_set("@#{var}", @integration_session.send(var)) 508 end 496 509 end 497 510 … … 499 512 def method_missing(sym, *args, &block) 500 513 reset! unless @integration_session 501 @integration_session.send(sym, *args, &block) 514 returning @integration_session.send(sym, *args, &block) do 515 copy_session_variables! 516 end 502 517 end 503 518 end