0
@@ -16,6 +16,8 @@ class FiltersTest < ActionController::TestCase
0
@response = ActionController::TestResponse.new
0
ActionController::Routing::Routes.draw do |map|
0
map.connect 'companies', :controller => 'companies'
0
+ map.connect 'companies/show', :controller => 'companies',
0
@@ -65,6 +67,110 @@ class FiltersTest < ActionController::TestCase
0
assert_equal 'new name', @controller.name
0
+ define_method "test_#{filter}_with_only_option_with_if_condition_#{condition.class}_which_returns_true_should_change_company_name" do
0
+ CompaniesController.send filter.to_sym, :change_name, :only => :show, :if => condition
0
+ @controller.name = 'thoughtbot'
0
+ @controller.flag = true
0
+ assert_equal 'thoughtbot', @controller.name
0
+ assert_equal 'new name', @controller.name
0
+ define_method "test_#{filter}_with_only_option_if_condition_#{condition.class}_which_returns_false_should_not_change_company_name" do
0
+ CompaniesController.send filter.to_sym, :change_name, :only => :show, :if => condition
0
+ @controller.name = 'thoughtbot'
0
+ @controller.flag = false
0
+ assert_equal 'thoughtbot', @controller.name
0
+ assert_equal 'thoughtbot', @controller.name
0
+ define_method "test_#{filter}_with_only_option_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_name" do
0
+ CompaniesController.send filter.to_sym, :change_name, :only => :show, :unless => condition
0
+ @controller.name = 'thoughtbot'
0
+ @controller.flag = true
0
+ assert_equal 'thoughtbot', @controller.name
0
+ assert_equal 'thoughtbot', @controller.name
0
+ define_method "test_#{filter}_with_only_option_unless_condition_#{condition.class}_which_returns_false_should_change_company_name" do
0
+ CompaniesController.send filter.to_sym, :change_name, :only => :show, :unless => condition
0
+ @controller.name = 'thoughtbot'
0
+ @controller.flag = false
0
+ assert_equal 'thoughtbot', @controller.name
0
+ assert_equal 'new name', @controller.name
0
+ define_method "test_#{filter}_with_except_option_with_if_condition_#{condition.class}_which_returns_true_should_change_company_name" do
0
+ CompaniesController.send filter.to_sym, :change_name, :except => :show, :if => condition
0
+ @controller.name = 'thoughtbot'
0
+ @controller.flag = true
0
+ assert_equal 'thoughtbot', @controller.name
0
+ assert_equal 'new name', @controller.name
0
+ define_method "test_#{filter}_with_except_option_if_condition_#{condition.class}_which_returns_false_should_not_change_company_name" do
0
+ CompaniesController.send filter.to_sym, :change_name, :except => :show, :if => condition
0
+ @controller.name = 'thoughtbot'
0
+ @controller.flag = false
0
+ assert_equal 'thoughtbot', @controller.name
0
+ assert_equal 'thoughtbot', @controller.name
0
+ define_method "test_#{filter}_with_except_option_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_name" do
0
+ CompaniesController.send filter.to_sym, :change_name, :except => :show, :unless => condition
0
+ @controller.name = 'thoughtbot'
0
+ @controller.flag = true
0
+ assert_equal 'thoughtbot', @controller.name
0
+ assert_equal 'thoughtbot', @controller.name
0
+ define_method "test_#{filter}_with_except_option_unless_condition_#{condition.class}_which_returns_false_should_change_company_name" do
0
+ CompaniesController.send filter.to_sym, :change_name, :except => :show, :unless => condition
0
+ @controller.name = 'thoughtbot'
0
+ @controller.flag = false
0
+ assert_equal 'thoughtbot', @controller.name
0
+ assert_equal 'new name', @controller.name
0
define_method "test_#{filter}_with_if_condition_#{condition.class}_which_returns_true_should_raise_an_exception_if_its_callback_is_not_a_symbol" do
0
CompaniesController.send filter.to_sym, CompaniesController, :if => condition
Comments
No one has commented yet.