Permalink
Browse files

image_tag should not raise an error when image is nil or empty string…

… (Lighthouse #1243)
  • Loading branch information...
1 parent 77d0aa5 commit 60446ac98cac21aed2bad71f5b5daa33827d67d1 @jcnetdev jcnetdev committed Mar 19, 2009
Showing with 9 additions and 1 deletion.
  1. +1 −0 merb-assets/lib/merb-assets/assets_mixin.rb
  2. +8 −1 merb-assets/spec/merb-assets_spec.rb
View
1 merb-assets/lib/merb-assets/assets_mixin.rb
@@ -98,6 +98,7 @@ def link_to(name, url='', opts={})
# image_tag('/dynamic/charts')
# # => <img src="/dynamic/charts">
def image_tag(img, opts={})
+ return "" if img.blank?
if img[0].chr == '/'
opts[:src] = img
else
View
9 merb-assets/spec/merb-assets_spec.rb
@@ -58,7 +58,14 @@
result = image_tag('foo.gif', :reload => true)
result.should match(%r{<img src="/images/foo.gif\?\d+" />})
end
-
+
+ it "should not create image tag with nil image" do
+ image_tag(nil).should == ""
+ end
+
+ it "should not create image tag with empty string" do
+ image_tag('').should == ""
+ end
end
describe "JavaScript related functions" do

0 comments on commit 60446ac

Please sign in to comment.