diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb
index f7d4c48..dbec31d 100644
--- a/app/helpers/boxes_helper.rb
+++ b/app/helpers/boxes_helper.rb
@@ -61,6 +61,8 @@ module BoxesHelper
end
when Proc
self.instance_eval(&content)
+ when NilClass
+ ''
else
raise "Unsupported content for block (#{content.class})"
end
diff --git a/app/models/block.rb b/app/models/block.rb
index 334005b..3c48963 100644
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -25,11 +25,21 @@ class Block < ActiveRecord::Base
# * Proc: the Proc is evaluated in the scope of BoxesHelper. The
# block can then use render, link_to, etc.
#
+ # The method can also return nil, which means "no footer".
+ #
# See BoxesHelper#extract_block_content for implementation details.
def content
"This is block number %d" % self.id
end
+ # A footer to be appended to the end of the block. Returns nil.
+ #
+ # Override in your subclasses. You can return the same types supported by
+ # #content.
+ def footer
+ nil
+ end
+
# must return a Hash with URL options poiting to the action that edits
# properties of the block
def editor
@@ -49,12 +59,4 @@ class Block < ActiveRecord::Base
self.class.name.underscore.gsub('_', '-')
end
- # A footer to be appended to the end of the block. Returns an empty string.
- #
- # Override in your subclasses. You can return the same types supported by
- # #content.
- def footer
- ''
- end
-
end
diff --git a/test/unit/block_test.rb b/test/unit/block_test.rb
index 5b4905f..46d977b 100644
--- a/test/unit/block_test.rb
+++ b/test/unit/block_test.rb
@@ -28,8 +28,8 @@ class BlockTest < Test::Unit::TestCase
assert_equal 'something-block', block.css_class_name
end
- should 'provide an empty footer by default' do
- assert_equal '', Block.new.footer
+ should 'provide no footer by default' do
+ assert_nil Block.new.footer
end
end
--
libgit2 0.21.2