Commit bfd7bc3c46775d4ea445b70f398afb99d3a8709a
1 parent
2ccaeaa8
Exists in
master
and in
28 other branches
r233@sede: terceiro | 2007-07-28 17:44:22 -0300
ActionItem0: improving tests git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@237 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
13 additions
and
1 deletions
Show diff stats
vendor/plugins/design/init.rb
@@ -5,6 +5,9 @@ class ActionController::Base | @@ -5,6 +5,9 @@ class ActionController::Base | ||
5 | # Declares that this controller uses design plugin to generate its layout. | 5 | # Declares that this controller uses design plugin to generate its layout. |
6 | # See the plugin README for options that can be passed to this method. | 6 | # See the plugin README for options that can be passed to this method. |
7 | def self.design(config = {}) | 7 | def self.design(config = {}) |
8 | + | ||
9 | + raise ArgumentError.new("design argument must be a Hash") unless config.kind_of? Hash | ||
10 | + | ||
8 | if (config.has_key?(:holder) && config.has_key?(:fixed)) || (!config.has_key?(:holder) && !config.has_key?(:fixed)) | 11 | if (config.has_key?(:holder) && config.has_key?(:fixed)) || (!config.has_key?(:holder) && !config.has_key?(:fixed)) |
9 | raise ArgumentError.new("You must supply either <tt>:holder</tt> or <tt>:fixed</tt> to design.") | 12 | raise ArgumentError.new("You must supply either <tt>:holder</tt> or <tt>:fixed</tt> to design.") |
10 | end | 13 | end |
vendor/plugins/design/test/design_test.rb
1 | require File.join(File.dirname(__FILE__), 'test_helper') | 1 | require File.join(File.dirname(__FILE__), 'test_helper') |
2 | 2 | ||
3 | -class FixedDesignHolderTest < Test::Unit::TestCase | 3 | +class DesignTest < Test::Unit::TestCase |
4 | 4 | ||
5 | def test_design_should_include_design_module | 5 | def test_design_should_include_design_module |
6 | assert FixedDesignTestController.included_modules.include?(Design) | 6 | assert FixedDesignTestController.included_modules.include?(Design) |
@@ -21,4 +21,10 @@ class FixedDesignHolderTest < Test::Unit::TestCase | @@ -21,4 +21,10 @@ class FixedDesignHolderTest < Test::Unit::TestCase | ||
21 | DesignEditorTestController.design :holder => 'something', :fixed => true end | 21 | DesignEditorTestController.design :holder => 'something', :fixed => true end |
22 | end | 22 | end |
23 | 23 | ||
24 | + def test_should_not_accept_non_hash | ||
25 | + assert_raise ArgumentError do | ||
26 | + DesignEditorTestController.design :fixed | ||
27 | + end | ||
28 | + end | ||
29 | + | ||
24 | end | 30 | end |
vendor/plugins/design/test/test_helper.rb
@@ -3,6 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environme | @@ -3,6 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environme | ||
3 | 3 | ||
4 | require 'test/unit' | 4 | require 'test/unit' |
5 | 5 | ||
6 | +# from Rails | ||
7 | +require 'test_help' | ||
8 | + | ||
6 | # load the database schema for the tests | 9 | # load the database schema for the tests |
7 | ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") | 10 | ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") |
8 | load(File.dirname(__FILE__) + '/schema.rb') | 11 | load(File.dirname(__FILE__) + '/schema.rb') |