Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4954

Show
Ignore:
Timestamp:
09/03/06 23:34:57 (2 years ago)
Author:
bitsweat
Message:

Integration tests: thoroughly test ActionController::Integration::Session. Closes #6022.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r4953 r4954  
    11*SVN* 
     2 
     3* Integration tests: thoroughly test ActionController::Integration::Session.  #6022 [Kevin Clark] 
     4    (tests skipped unless you `gem install mocha`) 
    25 
    36* Added deprecation language for pagination which will become a plugin by Rails 2.0 [DHH] 
  • trunk/actionpack/lib/action_controller/integration.rb

    r4952 r4954  
    152152      end 
    153153 
    154       # keep the docs for #get 
    155       %w( post put delete head ).each do |method| 
    156         class_eval <<-EOV, __FILE__, __LINE__ 
    157           def #{method}(path, parameters=nil, headers=nil) 
    158             process :#{method}, path, parameters, headers 
    159           end 
    160         EOV 
     154      # Performs a POST request with the given parameters. See get() for more details. 
     155      def post(path, parameters=nil, headers=nil) 
     156        process :post, path, parameters, headers 
     157      end 
     158 
     159      # Performs a PUT request with the given parameters. See get() for more details. 
     160      def put(path, parameters=nil, headers=nil) 
     161        process :put, path, parameters, headers 
     162      end 
     163       
     164      # Performs a DELETE request with the given parameters. See get() for more details. 
     165      def delete(path, parameters=nil, headers=nil) 
     166        process :delete, path, parameters, headers 
     167      end 
     168       
     169      # Performs a HEAD request with the given parameters. See get() for more details. 
     170      def head(path, parameters=nil, headers=nil) 
     171        process :head, path, parameters, headers 
    161172      end 
    162173 
  • trunk/actionpack/test/controller/base_test.rb

    r4755 r4954  
    7575  def test_action_methods 
    7676    @empty_controllers.each do |c| 
     77      hide_mocha_methods_from_controller(c) 
    7778      assert_equal Set.new, c.send(:action_methods), "#{c.controller_path} should be empty!" 
    7879    end 
    7980    @non_empty_controllers.each do |c| 
     81      hide_mocha_methods_from_controller(c) 
    8082      assert_equal Set.new('public_action'), c.send(:action_methods), "#{c.controller_path} should not be empty!" 
    8183    end 
     84  end 
     85   
     86  protected 
     87   
     88  # Mocha adds methods to Object which are then included in the public_instance_methods 
     89  # This method hides those from the controller so the above tests won't know the difference 
     90  def hide_mocha_methods_from_controller(controller) 
     91    mocha_methods = [:expects, :metaclass, :mocha, :mocha_inspect, :reset_mocha, :stubba_object, :stubba_method, :stubs, :verify] 
     92    controller.class.send(:hide_action, *mocha_methods) 
    8293  end 
    8394