Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a compatibility layer to get legacy filter tests to pass on new…

… base
  • Loading branch information...
commit bd7e3dc47d8ab4da1028c9c18c94474178f84bdd 1 parent e70bd6b
Yehuda Katz + Carl Lerche authored
Showing with 27 additions and 5 deletions.
  1. +27 −5 actionpack/test/controller/filters_test.rb
View
32 actionpack/test/controller/filters_test.rb
@@ -1,10 +1,32 @@
require 'abstract_unit'
+require 'active_support/core_ext/symbol'
-class << ActionController::Base
- %w(append_around_filter prepend_after_filter prepend_around_filter prepend_before_filter skip_after_filter skip_before_filter skip_filter).each do |pending|
- define_method(pending) do |*args|
- $stderr.puts "#{pending} unimplemented: #{args.inspect}"
- end unless method_defined?(pending)
+class ActionController::Base
+ class << self
+ %w(append_around_filter prepend_after_filter prepend_around_filter prepend_before_filter skip_after_filter skip_before_filter skip_filter).each do |pending|
+ define_method(pending) do |*args|
+ $stderr.puts "#{pending} unimplemented: #{args.inspect}"
+ end unless method_defined?(pending)
+ end
+
+ if defined?(ActionController::Http)
+ def before_filters
+ filters = _process_action_callbacks.select { |c| c.kind == :before }
+ filters.map! { |c| c.instance_variable_get(:@raw_filter) }
+ end
+ end
+ end
+
+ if defined?(ActionController::Http)
+ def assigns(key = nil)
+ assigns = {}
+ instance_variable_names.each do |ivar|
+ next if ActionController::Base.protected_instance_variables.include?(ivar)
+ assigns[ivar[1..-1]] = instance_variable_get(ivar)
+ end
+
+ key.nil? ? assigns : assigns[key.to_s]
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.