Skip to content
This repository
Browse code

Made ActionController::Verification work with new_base

  • Loading branch information...
commit e21d1614bb9006e69bf4bb2467b823aa12e64485 1 parent 7f7fdc4
Pratik authored May 21, 2009
2  actionpack/Rakefile
@@ -63,7 +63,7 @@ Rake::TestTask.new(:test_new_base_on_old_tests) do |t|
63 63
   t.test_files = %w(
64 64
     addresses_render base benchmark caching capture content_type dispatcher
65 65
     flash mime_responds record_identifier redirect render rescue url_rewriter
66  
-    webservice
  66
+    webservice verification
67 67
   ).map { |name| "test/controller/#{name}_test.rb" }
68 68
 end
69 69
 
12  actionpack/lib/action_controller/base/verification.rb
... ...
@@ -1,7 +1,13 @@
1 1
 module ActionController #:nodoc:
2 2
   module Verification #:nodoc:
3  
-    def self.included(base) #:nodoc:
4  
-      base.extend(ClassMethods)
  3
+    extend ActiveSupport::DependencyModule
  4
+
  5
+    # TODO : Remove the defined? check when new base is the main base
  6
+    if defined?(ActionController::Http)
  7
+      depends_on AbstractController::Callbacks
  8
+      depends_on Session
  9
+      depends_on Flash
  10
+      depends_on Renderer
5 11
     end
6 12
 
7 13
     # This module provides a class-level method for specifying that certain
@@ -102,7 +108,7 @@ def prereqs_invalid?(options) # :nodoc:
102 108
     end
103 109
  
104 110
     def verify_presence_of_keys_in_hash_flash_or_params(options) # :nodoc:
105  
-      [*options[:params] ].find { |v| params[v].nil?  } ||
  111
+      [*options[:params] ].find { |v| v && params[v.to_sym].nil?  } ||
106 112
       [*options[:session]].find { |v| session[v].nil? } ||
107 113
       [*options[:flash]  ].find { |v| flash[v].nil?   }
108 114
     end
5  actionpack/lib/action_controller/new_base.rb
@@ -25,8 +25,9 @@ module ActionController
25 25
   autoload :UrlRewriter,       'action_controller/routing/generation/url_rewriter'
26 26
   autoload :UrlWriter,         'action_controller/routing/generation/url_rewriter'
27 27
 
28  
-  autoload :Flash, 'action_controller/base/chained/flash'
29  
-  
  28
+  autoload :Verification, 'action_controller/base/verification'
  29
+  autoload :Flash,        'action_controller/base/chained/flash'
  30
+
30 31
   require 'action_controller/routing'
31 32
 end
32 33
 
1  actionpack/lib/action_controller/new_base/base.rb
@@ -16,6 +16,7 @@ class Base < Http
16 16
 
17 17
     include ActionController::Session
18 18
     include ActionController::Flash
  19
+    include ActionController::Verification
19 20
 
20 21
     # Legacy modules
21 22
     include SessionManagement
4  actionpack/lib/action_controller/new_base/compatibility.rb
@@ -103,5 +103,9 @@ def method_for_action(action_name)
103 103
     def _layout_prefix(name)
104 104
       super unless name =~ /\blayouts/
105 105
     end
  106
+
  107
+    def performed?
  108
+      response_body
  109
+    end
106 110
   end
107 111
 end
2  actionpack/lib/action_controller/new_base/testing.rb
@@ -2,7 +2,7 @@ module ActionController
2 2
   module Testing
3 3
     
4 4
     # OMG MEGA HAX
5  
-    def process_with_test(request, response)
  5
+    def process_with_new_base_test(request, response)
6 6
       @_request = request
7 7
       @_response = response
8 8
       @_response.request = request
2  actionpack/lib/action_controller/testing/process2.rb
@@ -53,7 +53,7 @@ def process(action, parameters = nil, session = nil, flash = nil, http_method =
53 53
       @controller.request = @request
54 54
       @controller.params.merge!(parameters)
55 55
       # Base.class_eval { include ProcessWithTest } unless Base < ProcessWithTest
56  
-      @controller.process_with_test(@request, @response)
  56
+      @controller.process_with_new_base_test(@request, @response)
57 57
     end
58 58
     
59 59
     def build_request_uri(action, parameters)
14  actionpack/test/controller/verification_test.rb
@@ -103,17 +103,15 @@ def no_default_action
103 103
     end
104 104
 
105 105
     protected
106  
-      def rescue_action(e) raise end
107 106
 
108  
-      def unconditional_redirect
109  
-        redirect_to :action => "unguarded"
110  
-      end
  107
+    def unconditional_redirect
  108
+      redirect_to :action => "unguarded"
  109
+    end
111 110
   end
112 111
 
113  
-  def setup
114  
-    @controller = TestController.new
115  
-    @request    = ActionController::TestRequest.new
116  
-    @response   = ActionController::TestResponse.new
  112
+  tests TestController
  113
+
  114
+  setup do
117 115
     ActionController::Routing::Routes.add_named_route :foo, '/foo', :controller => 'test', :action => 'foo'
118 116
   end
119 117
 

0 notes on commit e21d161

Please sign in to comment.
Something went wrong with that request. Please try again.