Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed support for String filters

git-svn-id: https://svn.thoughtbot.com/plugins/when/trunk@347 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
commit f8630086e8b81116b1b4d7772fc44a6e1b32f0c7 1 parent 06047c4
jcarroll authored
Showing with 2 additions and 152 deletions.
  1. +1 −1  lib/callbacks.rb
  2. +1 −3 lib/filters.rb
  3. +0 −148 test/filters_test.rb
View
2  lib/callbacks.rb
@@ -26,7 +26,7 @@ def #{callback}_with_conditions(*callbacks, &block)
callback.call(record)
else
raise ActiveRecord::ActiveRecordError,
- "Callbacks must be a symbol denoting the method to call, a string to be evaluated, a block to be invoked, or an object responding to the callback method."
+ 'Callbacks must be a symbol denoting the method to call, a string to be evaluated or a block to be invoked.'
end
end
end
View
4 lib/filters.rb
@@ -18,13 +18,11 @@ def #{filter}_with_conditions(*filters, &block)
(! options[:unless].nil? && ActiveRecord::Base.evaluate_condition(options[:unless], controller))
if filter.class == Symbol
controller.send filter
- elsif filter.class == String
- eval(filter, binding)
elsif filter.class == Proc || filter.class == Method
filter.call(controller)
else
raise ActionController::ActionControllerError,
- "Filters must be a symbol denoting the method to call, a string to be evaluated, a block to be invoked, or an object responding to the callback method."
+ 'Filters must be a symbol denoting the method to call evaluated or a block to be invoked.'
end
end
end
View
148 test/filters_test.rb
@@ -197,154 +197,6 @@ def rescue_action(exception)
conditions.each do |condition|
basic_filters.each do |filter|
- define_method "test_#{filter}_with_if_condition_#{condition.class}_which_returns_true_should_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :if => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = true
-
- get :index
- assert_equal 'new bio', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_if_condition_#{condition.class}_which_returns_false_should_not_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :if => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = false
-
- get :index
- assert_equal 'thoughtbot', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :unless => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = true
-
- get :index
- assert_equal 'thoughtbot', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_unless_condition_#{condition.class}_which_returns_false_should_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :unless => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = false
-
- get :index
- assert_equal 'new bio', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_only_option_with_if_condition_#{condition.class}_which_returns_true_should_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :only => :show, :if => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = true
-
- get :index
- assert_equal 'thoughtbot', CompaniesController.bio
-
- get :show
- assert_equal 'new bio', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_only_option_if_condition_#{condition.class}_which_returns_false_should_not_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :only => :show, :if => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = false
-
- get :index
- assert_equal 'thoughtbot', CompaniesController.bio
-
- get :show
- assert_equal 'thoughtbot', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_only_option_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :only => :show, :unless => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = true
-
- get :index
- assert_equal 'thoughtbot', CompaniesController.bio
-
- get :show
- assert_equal 'thoughtbot', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_only_option_unless_condition_#{condition.class}_which_returns_false_should_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :only => :show, :unless => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = false
-
- get :index
- assert_equal 'thoughtbot', CompaniesController.bio
-
- get :show
- assert_equal 'new bio', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_except_option_with_if_condition_#{condition.class}_which_returns_true_should_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :except => :show, :if => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = true
-
- get :show
- assert_equal 'thoughtbot', CompaniesController.bio
-
- get :index
- assert_equal 'new bio', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_except_option_if_condition_#{condition.class}_which_returns_false_should_not_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :except => :show, :if => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = false
-
- get :show
- assert_equal 'thoughtbot', CompaniesController.bio
-
- get :index
- assert_equal 'thoughtbot', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_except_option_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :except => :show, :unless => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = true
-
- get :show
- assert_equal 'thoughtbot', CompaniesController.bio
-
- get :index
- assert_equal 'thoughtbot', CompaniesController.bio
- end
-
- define_method "test_#{filter}_with_except_option_unless_condition_#{condition.class}_which_returns_false_should_change_company_bio" do
- CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :except => :show, :unless => condition
-
- CompaniesController.bio = 'thoughtbot'
- @controller.flag = false
-
- get :show
- assert_equal 'thoughtbot', CompaniesController.bio
-
- get :index
- assert_equal 'new bio', CompaniesController.bio
- end
- end
- end
-
- conditions.each do |condition|
- basic_filters.each do |filter|
define_method "test_#{filter}_with_block_callback_with_if_condition_#{condition.class}_which_returns_true_should_change_company_name" do
CompaniesController.send filter.to_sym, :if => condition do |controller|
controller.change_name
Please sign in to comment.
Something went wrong with that request. Please try again.