Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 3 changed files with 2 additions and 152 deletions. Show diff stats Hide diff stats

  1. +1 1  lib/callbacks.rb
  2. +1 3 lib/filters.rb
  3. +0 148 test/filters_test.rb
2  lib/callbacks.rb
@@ -26,7 +26,7 @@ def #{callback}_with_conditions(*callbacks, &block)
26 26 callback.call(record)
27 27 else
28 28 raise ActiveRecord::ActiveRecordError,
29   - "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."
  29 + 'Callbacks must be a symbol denoting the method to call, a string to be evaluated or a block to be invoked.'
30 30 end
31 31 end
32 32 end
4 lib/filters.rb
@@ -18,13 +18,11 @@ def #{filter}_with_conditions(*filters, &block)
18 18 (! options[:unless].nil? && ActiveRecord::Base.evaluate_condition(options[:unless], controller))
19 19 if filter.class == Symbol
20 20 controller.send filter
21   - elsif filter.class == String
22   - eval(filter, binding)
23 21 elsif filter.class == Proc || filter.class == Method
24 22 filter.call(controller)
25 23 else
26 24 raise ActionController::ActionControllerError,
27   - "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."
  25 + 'Filters must be a symbol denoting the method to call evaluated or a block to be invoked.'
28 26 end
29 27 end
30 28 end
148 test/filters_test.rb
@@ -197,154 +197,6 @@ def rescue_action(exception)
197 197
198 198 conditions.each do |condition|
199 199 basic_filters.each do |filter|
200   - define_method "test_#{filter}_with_if_condition_#{condition.class}_which_returns_true_should_change_company_bio" do
201   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :if => condition
202   -
203   - CompaniesController.bio = 'thoughtbot'
204   - @controller.flag = true
205   -
206   - get :index
207   - assert_equal 'new bio', CompaniesController.bio
208   - end
209   -
210   - define_method "test_#{filter}_with_if_condition_#{condition.class}_which_returns_false_should_not_change_company_bio" do
211   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :if => condition
212   -
213   - CompaniesController.bio = 'thoughtbot'
214   - @controller.flag = false
215   -
216   - get :index
217   - assert_equal 'thoughtbot', CompaniesController.bio
218   - end
219   -
220   - define_method "test_#{filter}_with_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_bio" do
221   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :unless => condition
222   -
223   - CompaniesController.bio = 'thoughtbot'
224   - @controller.flag = true
225   -
226   - get :index
227   - assert_equal 'thoughtbot', CompaniesController.bio
228   - end
229   -
230   - define_method "test_#{filter}_with_unless_condition_#{condition.class}_which_returns_false_should_change_company_bio" do
231   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :unless => condition
232   -
233   - CompaniesController.bio = 'thoughtbot'
234   - @controller.flag = false
235   -
236   - get :index
237   - assert_equal 'new bio', CompaniesController.bio
238   - end
239   -
240   - define_method "test_#{filter}_with_only_option_with_if_condition_#{condition.class}_which_returns_true_should_change_company_bio" do
241   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :only => :show, :if => condition
242   -
243   - CompaniesController.bio = 'thoughtbot'
244   - @controller.flag = true
245   -
246   - get :index
247   - assert_equal 'thoughtbot', CompaniesController.bio
248   -
249   - get :show
250   - assert_equal 'new bio', CompaniesController.bio
251   - end
252   -
253   - define_method "test_#{filter}_with_only_option_if_condition_#{condition.class}_which_returns_false_should_not_change_company_bio" do
254   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :only => :show, :if => condition
255   -
256   - CompaniesController.bio = 'thoughtbot'
257   - @controller.flag = false
258   -
259   - get :index
260   - assert_equal 'thoughtbot', CompaniesController.bio
261   -
262   - get :show
263   - assert_equal 'thoughtbot', CompaniesController.bio
264   - end
265   -
266   - define_method "test_#{filter}_with_only_option_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_bio" do
267   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :only => :show, :unless => condition
268   -
269   - CompaniesController.bio = 'thoughtbot'
270   - @controller.flag = true
271   -
272   - get :index
273   - assert_equal 'thoughtbot', CompaniesController.bio
274   -
275   - get :show
276   - assert_equal 'thoughtbot', CompaniesController.bio
277   - end
278   -
279   - define_method "test_#{filter}_with_only_option_unless_condition_#{condition.class}_which_returns_false_should_change_company_bio" do
280   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :only => :show, :unless => condition
281   -
282   - CompaniesController.bio = 'thoughtbot'
283   - @controller.flag = false
284   -
285   - get :index
286   - assert_equal 'thoughtbot', CompaniesController.bio
287   -
288   - get :show
289   - assert_equal 'new bio', CompaniesController.bio
290   - end
291   -
292   - define_method "test_#{filter}_with_except_option_with_if_condition_#{condition.class}_which_returns_true_should_change_company_bio" do
293   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :except => :show, :if => condition
294   -
295   - CompaniesController.bio = 'thoughtbot'
296   - @controller.flag = true
297   -
298   - get :show
299   - assert_equal 'thoughtbot', CompaniesController.bio
300   -
301   - get :index
302   - assert_equal 'new bio', CompaniesController.bio
303   - end
304   -
305   - define_method "test_#{filter}_with_except_option_if_condition_#{condition.class}_which_returns_false_should_not_change_company_bio" do
306   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :except => :show, :if => condition
307   -
308   - CompaniesController.bio = 'thoughtbot'
309   - @controller.flag = false
310   -
311   - get :show
312   - assert_equal 'thoughtbot', CompaniesController.bio
313   -
314   - get :index
315   - assert_equal 'thoughtbot', CompaniesController.bio
316   - end
317   -
318   - define_method "test_#{filter}_with_except_option_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_bio" do
319   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :except => :show, :unless => condition
320   -
321   - CompaniesController.bio = 'thoughtbot'
322   - @controller.flag = true
323   -
324   - get :show
325   - assert_equal 'thoughtbot', CompaniesController.bio
326   -
327   - get :index
328   - assert_equal 'thoughtbot', CompaniesController.bio
329   - end
330   -
331   - define_method "test_#{filter}_with_except_option_unless_condition_#{condition.class}_which_returns_false_should_change_company_bio" do
332   - CompaniesController.send filter.to_sym, 'self.bio = "new bio"', :except => :show, :unless => condition
333   -
334   - CompaniesController.bio = 'thoughtbot'
335   - @controller.flag = false
336   -
337   - get :show
338   - assert_equal 'thoughtbot', CompaniesController.bio
339   -
340   - get :index
341   - assert_equal 'new bio', CompaniesController.bio
342   - end
343   - end
344   - end
345   -
346   - conditions.each do |condition|
347   - basic_filters.each do |filter|
348 200 define_method "test_#{filter}_with_block_callback_with_if_condition_#{condition.class}_which_returns_true_should_change_company_name" do
349 201 CompaniesController.send filter.to_sym, :if => condition do |controller|
350 202 controller.change_name

0 comments on commit f863008

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