Commit 7832b7eae23111f094af1bd333118745609d7e5c
1 parent
4cefe47d
Exists in
master
and in
29 other branches
rails3: fix creation of plugins filter
This method of adding plugins filters should be refactored. This works for now.
Showing
2 changed files
with
4 additions
and
4 deletions
Show diff stats
app/controllers/application_controller.rb
... | ... | @@ -138,11 +138,11 @@ class ApplicationController < ActionController::Base |
138 | 138 | plugins.each do |plugin| |
139 | 139 | filters = plugin.send(self.class.name.underscore + '_filters') |
140 | 140 | filters = [filters] if !filters.kind_of?(Array) |
141 | - controller_filters = self.class.filter_chain.map {|c| c.method } | |
141 | + controller_filters = self.class._process_action_callbacks.map {|c| c.filter.to_sym } | |
142 | 142 | filters.each do |plugin_filter| |
143 | - filter_method = plugin.class.name.underscore.gsub('/','_') + '_' + plugin_filter[:method_name] | |
143 | + filter_method = (plugin.class.name.underscore.gsub('/','_') + '_' + plugin_filter[:method_name]).to_sym | |
144 | 144 | unless controller_filters.include?(filter_method) |
145 | - self.class.send(plugin_filter[:type], filter_method, (plugin_filter[:options] || {})) | |
145 | + self.class.send(plugin_filter[:type], filter_method.to_sym, (plugin_filter[:options] || {})) | |
146 | 146 | self.class.send(:define_method, filter_method) do |
147 | 147 | instance_eval(&plugin_filter[:block]) if environment.plugin_enabled?(plugin.class) |
148 | 148 | end | ... | ... |
test/functional/application_controller_test.rb
... | ... | @@ -506,7 +506,7 @@ class ApplicationControllerTest < ActionController::TestCase |
506 | 506 | |
507 | 507 | get :index |
508 | 508 | get :index |
509 | - assert_equal 1, @controller.class.filter_chain.select{|c| c.method == 'application_controller_test_filter_plugin_filter_plugin'}.count | |
509 | + assert_equal 1, @controller.class._process_action_callbacks.select{|c| c.filter == :application_controller_test_filter_plugin_filter_plugin}.count | |
510 | 510 | end |
511 | 511 | |
512 | 512 | should 'do not call plugin filter block on a environment that this plugin is not enabled' do | ... | ... |