Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made ActionController::Verification work with new_base

  • Loading branch information...
commit e21d1614bb9006e69bf4bb2467b823aa12e64485 1 parent 7f7fdc4
@lifo lifo authored
View
2  actionpack/Rakefile
@@ -63,7 +63,7 @@ Rake::TestTask.new(:test_new_base_on_old_tests) do |t|
t.test_files = %w(
addresses_render base benchmark caching capture content_type dispatcher
flash mime_responds record_identifier redirect render rescue url_rewriter
- webservice
+ webservice verification
).map { |name| "test/controller/#{name}_test.rb" }
end
View
12 actionpack/lib/action_controller/base/verification.rb
@@ -1,7 +1,13 @@
module ActionController #:nodoc:
module Verification #:nodoc:
- def self.included(base) #:nodoc:
- base.extend(ClassMethods)
+ extend ActiveSupport::DependencyModule
+
+ # TODO : Remove the defined? check when new base is the main base
+ if defined?(ActionController::Http)
+ depends_on AbstractController::Callbacks
+ depends_on Session
+ depends_on Flash
+ depends_on Renderer
end
# This module provides a class-level method for specifying that certain
@@ -102,7 +108,7 @@ def prereqs_invalid?(options) # :nodoc:
end
def verify_presence_of_keys_in_hash_flash_or_params(options) # :nodoc:
- [*options[:params] ].find { |v| params[v].nil? } ||
+ [*options[:params] ].find { |v| v && params[v.to_sym].nil? } ||
[*options[:session]].find { |v| session[v].nil? } ||
[*options[:flash] ].find { |v| flash[v].nil? }
end
View
5 actionpack/lib/action_controller/new_base.rb
@@ -25,8 +25,9 @@ module ActionController
autoload :UrlRewriter, 'action_controller/routing/generation/url_rewriter'
autoload :UrlWriter, 'action_controller/routing/generation/url_rewriter'
- autoload :Flash, 'action_controller/base/chained/flash'
-
+ autoload :Verification, 'action_controller/base/verification'
+ autoload :Flash, 'action_controller/base/chained/flash'
+
require 'action_controller/routing'
end
View
1  actionpack/lib/action_controller/new_base/base.rb
@@ -16,6 +16,7 @@ class Base < Http
include ActionController::Session
include ActionController::Flash
+ include ActionController::Verification
# Legacy modules
include SessionManagement
View
4 actionpack/lib/action_controller/new_base/compatibility.rb
@@ -103,5 +103,9 @@ def method_for_action(action_name)
def _layout_prefix(name)
super unless name =~ /\blayouts/
end
+
+ def performed?
+ response_body
+ end
end
end
View
2  actionpack/lib/action_controller/new_base/testing.rb
@@ -2,7 +2,7 @@ module ActionController
module Testing
# OMG MEGA HAX
- def process_with_test(request, response)
+ def process_with_new_base_test(request, response)
@_request = request
@_response = response
@_response.request = request
View
2  actionpack/lib/action_controller/testing/process2.rb
@@ -53,7 +53,7 @@ def process(action, parameters = nil, session = nil, flash = nil, http_method =
@controller.request = @request
@controller.params.merge!(parameters)
# Base.class_eval { include ProcessWithTest } unless Base < ProcessWithTest
- @controller.process_with_test(@request, @response)
+ @controller.process_with_new_base_test(@request, @response)
end
def build_request_uri(action, parameters)
View
14 actionpack/test/controller/verification_test.rb
@@ -103,17 +103,15 @@ def no_default_action
end
protected
- def rescue_action(e) raise end
- def unconditional_redirect
- redirect_to :action => "unguarded"
- end
+ def unconditional_redirect
+ redirect_to :action => "unguarded"
+ end
end
- def setup
- @controller = TestController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
+ tests TestController
+
+ setup do
ActionController::Routing::Routes.add_named_route :foo, '/foo', :controller => 'test', :action => 'foo'
end
Please sign in to comment.
Something went wrong with that request. Please try again.