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

Changeset 3668

Show
Ignore:
Timestamp:
02/26/06 17:49:09 (3 years ago)
Author:
ulysses
Message:

Remove ::Controllers related cruft; fix AP tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/base.rb

    r3606 r3668  
    325325          components = self.name.to_s.split('::') 
    326326          components[-1] = $1 if /^(.*)Controller$/ =~ components.last 
    327           # Accomodate the root Controllers module. 
    328           components.shift if components.first == 'Controllers' 
    329327          @controller_path = components.map { |name| name.underscore }.join('/') 
    330328        end 
  • trunk/actionpack/lib/action_controller/helpers.rb

    r2938 r3668  
    110110      private  
    111111        def default_helper_module! 
    112           module_name = name.sub(/^Controllers::/, '').sub(/Controller$|$/, 'Helper') 
     112          module_name = name.sub(/Controller$|$/, 'Helper') 
    113113          module_path = module_name.split('::').map { |m| m.underscore }.join('/') 
    114114          require_dependency module_path 
     
    129129            raise unless e.is_missing?("helpers/#{child.controller_path}_helper") 
    130130          end 
    131         end         
     131        end 
    132132    end 
    133133  end 
  • trunk/actionpack/test/controller/base_test.rb

    r2696 r3668  
    33require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late 
    44 
    5 # This file currently contains a few controller UTs 
    6 # I couldn't find where the current base tests are, so I created this file. 
    7 # If there aren't any base-specific UTs, then this file should grow as they 
    8 # are written. If there are, or there is a better place for these, then I will 
    9 # move them to the correct location. 
    10 
    11 # Nicholas Seckar aka. Ulysses 
    12  
    13 # Provide a static version of the Controllers module instead of the auto-loading version. 
    14 # We don't want these tests to fail when dependencies are to blame. 
    15 module Controllers 
    16   module Submodule 
    17     class ContainedEmptyController < ActionController::Base 
    18     end 
    19     class ContainedNonEmptyController < ActionController::Base 
    20       def public_action 
    21       end 
    22        
    23       hide_action :hidden_action 
    24       def hidden_action 
    25       end 
    26        
    27       def another_hidden_action 
    28       end 
    29       hide_action :another_hidden_action 
    30     end 
    31     class SubclassedController < ContainedNonEmptyController 
    32       hide_action :public_action # Hiding it here should not affect the superclass. 
    33     end 
     5# Provide some controller to run the tests on. 
     6module Submodule 
     7  class ContainedEmptyController < ActionController::Base 
    348  end 
    35   class EmptyController < ActionController::Base 
    36     include ActionController::Caching 
    37   end 
    38   class NonEmptyController < ActionController::Base 
     9  class ContainedNonEmptyController < ActionController::Base 
    3910    def public_action 
    4011    end 
     
    4314    def hidden_action 
    4415    end 
     16     
     17    def another_hidden_action 
     18    end 
     19    hide_action :another_hidden_action 
     20  end 
     21  class SubclassedController < ContainedNonEmptyController 
     22    hide_action :public_action # Hiding it here should not affect the superclass. 
     23  end 
     24end 
     25class EmptyController < ActionController::Base 
     26  include ActionController::Caching 
     27end 
     28class NonEmptyController < ActionController::Base 
     29  def public_action 
     30  end 
     31   
     32  hide_action :hidden_action 
     33  def hidden_action 
    4534  end 
    4635end 
     
    4837class ControllerClassTests < Test::Unit::TestCase 
    4938  def test_controller_path 
    50     assert_equal 'empty', Controllers::EmptyController.controller_path 
    51     assert_equal 'submodule/contained_empty', Controllers::Submodule::ContainedEmptyController.controller_path 
     39    assert_equal 'empty', EmptyController.controller_path 
     40    assert_equal 'submodule/contained_empty', Submodule::ContainedEmptyController.controller_path 
    5241  end 
    5342  def test_controller_name 
    54     assert_equal 'empty', Controllers::EmptyController.controller_name 
    55     assert_equal 'contained_empty', Controllers::Submodule::ContainedEmptyController.controller_name 
     43    assert_equal 'empty', EmptyController.controller_name 
     44    assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name 
    5645 end 
    5746end 
     
    5948class ControllerInstanceTests < Test::Unit::TestCase 
    6049  def setup 
    61     @empty = Controllers::EmptyController.new 
    62     @contained = Controllers::Submodule::ContainedEmptyController.new 
    63     @empty_controllers = [@empty, @contained, Controllers::Submodule::SubclassedController.new] 
     50    @empty = EmptyController.new 
     51    @contained = Submodule::ContainedEmptyController.new 
     52    @empty_controllers = [@empty, @contained, Submodule::SubclassedController.new] 
    6453     
    65     @non_empty_controllers = [Controllers::NonEmptyController.new, 
    66                               Controllers::Submodule::ContainedNonEmptyController.new] 
     54    @non_empty_controllers = [NonEmptyController.new, 
     55                              Submodule::ContainedNonEmptyController.new] 
    6756  end 
    6857 
  • trunk/actionpack/test/controller/benchmark_test.rb

    r2039 r3668  
    22require 'test/unit' 
    33 
    4 # Provide a static version of the Controllers module instead of the auto-loading version. 
    5 # We don't want these tests to fail when dependencies are to blame. 
    6 module Controllers 
    7   class BenchmarkedController < ActionController::Base 
    8     def public_action 
    9       render :nothing => true 
    10     end 
     4# Provide some static controllers. 
     5class BenchmarkedController < ActionController::Base 
     6  def public_action 
     7    render :nothing => true 
     8  end 
    119 
    12     def rescue_action(e) 
    13       raise e 
    14     end 
     10  def rescue_action(e) 
     11    raise e 
    1512  end 
    1613end 
     
    2320 
    2421  def setup 
    25     @controller = Controllers::BenchmarkedController.new 
     22    @controller = BenchmarkedController.new 
    2623    # benchmark doesn't do anything unless a logger is set 
    2724    @controller.logger = MockLogger.new 
  • trunk/activesupport/lib/active_support/core_ext/class/removal.rb

    r3532 r3668  
    99 
    1010  def remove_class(*klasses) 
    11     klasses.each do |klass| 
     11    klasses.flatten.each do |klass| 
    1212      # Skip this class if there is nothing bound to this name 
    1313      next unless defined?(klass.name) 
    14      
     14       
    1515      basename = klass.to_s.split("::").last 
    1616      parent = klass.parent 
    17      
     17       
    1818      # Skip this class if it does not match the current one bound to this name 
    1919      next unless parent.const_defined?(basename) && klass = parent.const_get(basename) 
    20  
     20       
    2121      parent.send :remove_const, basename unless parent == klass 
    2222    end 
  • trunk/activesupport/lib/active_support/dependencies.rb

    r3526 r3668  
    9999  # require_association when using single-table inheritance. 
    100100  def const_missing(class_id) 
    101     if Object.const_defined?(:Controllers) && Object::Controllers.const_available?(class_id) 
    102       return Object::Controllers.const_get(class_id) 
    103     end 
    104      
    105101    file_name = class_id.to_s.demodulize.underscore 
    106102    file_path = as_load_path.empty? ? file_name : "#{as_load_path}/#{file_name}" 
  • trunk/railties/builtin/controllers/rails_info_controller.rb

    r2933 r3668  
    1 module Controllers #:nodoc: 
    2   class RailsInfoController < ApplicationController 
    3     def properties 
    4       if local_request? 
    5         render :inline => Rails::Info.to_html 
    6       else 
    7         render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => 500 
    8       end 
     1class RailsInfoController < ApplicationController 
     2  def properties 
     3    if local_request? 
     4      render :inline => Rails::Info.to_html 
     5    else 
     6      render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => 500 
    97    end 
    108  end 
  • trunk/railties/lib/commands/servers/lighttpd.rb

    r3641 r3668  
    3131     "..", "..", "..", "configs", "lighttpd.conf")) 
    3232  puts "=> #{config_file} not found, copying from #{source}" 
    33   FileUtils.cp source, config_file 
     33  config = File.read source 
     34  config = config.gsub "CWD", File.expand_path(RAILS_ROOT).inspect 
     35  File.open(config_file, 'w') { |f| f.write config } 
    3436end 
    3537 
  • trunk/railties/test/dispatcher_test.rb

    r2841 r3668  
    2525    @output = StringIO.new 
    2626    ENV['REQUEST_METHOD'] = "GET" 
    27     setup_minimal_environment 
    2827  end 
    2928 
    3029  def teardown 
    3130    ENV['REQUEST_METHOD'] = nil 
    32     teardown_minimal_environment 
    3331  end 
    3432 
     
    9290      Dispatcher.dispatch(nil, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, @output) 
    9391    end 
    94  
    95     def setup_minimal_environment 
    96       value = Dependencies::LoadingModule.root 
    97       Object.const_set("Controllers", value) 
    98     end 
    99  
    100     def teardown_minimal_environment 
    101       Object.send(:remove_const, "Controllers") 
    102     end 
    10392end 
  • trunk/railties/test/rails_info_controller_test.rb

    r2933 r3668  
    88require 'action_controller/test_process' 
    99require 'rails_info' 
    10  
    11 module Controllers; def self.const_available?(constant); false end end 
    1210 
    1311class ApplicationController < ActionController::Base 
     
    3028 
    3129# Re-raise errors caught by the controller. 
    32 class Controllers::RailsInfoController; def rescue_action(e) raise e end; end 
     30class RailsInfoController; def rescue_action(e) raise e end; end 
    3331 
    3432class RailsInfoControllerTest < Test::Unit::TestCase 
    3533  def setup 
    36     @controller = Controllers::RailsInfoController.new 
     34    @controller = RailsInfoController.new 
    3735    @request    = ActionController::TestRequest.new 
    3836    @response   = ActionController::TestResponse.new 
     
    4038 
    4139  def test_rails_info_properties_table_rendered_for_local_request 
    42     Controllers::RailsInfoController.local_request = true 
     40    RailsInfoController.local_request = true 
    4341    get :properties 
    4442    assert_tag :tag => 'table' 
     
    4745   
    4846  def test_rails_info_properties_error_rendered_for_non_local_request 
    49     Controllers::RailsInfoController.local_request = false 
     47    RailsInfoController.local_request = false 
    5048    get :properties 
    5149    assert_tag :tag => 'p'