diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2009-12-30 19:42:19 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2009-12-30 19:42:19 +0000 |
commit | 9ffee0a5a4955502e60116e06b3e95bf58f02468 (patch) | |
tree | 34461861a1d0066fda78f86a70857b3ea46e1ecd /test/test_helper.rb | |
parent | 4cf2e7c216ab73c77f95776ad9b4699eb162a6af (diff) | |
download | redmine-9ffee0a5a4955502e60116e06b3e95bf58f02468.tar.gz redmine-9ffee0a5a4955502e60116e06b3e95bf58f02468.zip |
Added some shoulda macros for testing.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3269 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r-- | test/test_helper.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb index 4b8e03dd7..8e7927ab3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -75,4 +75,32 @@ class ActiveSupport::TestCase yield saved_settings.each {|k, v| Setting[k] = v} end + + # Shoulda macros + def self.should_render_404 + should_respond_with :not_found + should_render_template 'common/404' + end + + def self.should_have_before_filter(expected_method, options = {}) + should_have_filter('before', expected_method, options) + end + + def self.should_have_after_filter(expected_method, options = {}) + should_have_filter('after', expected_method, options) + end + + def self.should_have_filter(filter_type, expected_method, options) + description = "have #{filter_type}_filter :#{expected_method}" + description << " with #{options.inspect}" unless options.empty? + + should description do + klass = "action_controller/filters/#{filter_type}_filter".classify.constantize + expected = klass.new(:filter, expected_method.to_sym, options) + assert_equal 1, @controller.class.filter_chain.select { |filter| + filter.method == expected.method && filter.kind == expected.kind && + filter.options == expected.options && filter.class == expected.class + }.size + end + end end |