Permalink
Browse files

Added numeric ability for text nodes.

  • Loading branch information...
1 parent fd43161 commit 0dad88989d561e95b7982e75606c2de0a5ab540c @bobbytables committed Sep 12, 2011
Showing with 10 additions and 2 deletions.
  1. +3 −1 lib/active_admin/arbre/builder.rb
  2. +7 −1 spec/unit/arbre/html/tag_spec.rb
@@ -102,7 +102,9 @@ def with_current_dom_context(tag)
def insert_text_node_if_string(tag)
if tag.is_a?(String)
current_dom_context << Arbre::HTML::TextNode.from_string(tag)
- end
+ elsif tag.kind_of?(Numeric)
+ current_dom_context << Arbre::HTML::TextNode.from_string(tag.to_s)
+ end
end
end
@@ -16,8 +16,14 @@
it "should set the hash of options to the attributes" do
tag.attributes.should == { :id => "my_id" }
end
+
+ it "should set contents to a string if passed a numeric value" do
+ numeric_tag = Arbre::HTML:Tag.new
+ numeric_tag.build 42, :id => "answer_to_life"
+ numeric_tag.content.should == 42.to_s
+ end
end
-
+
describe "creating a tag 'for' an object" do
let(:model_name){ mock(:singular => "resource_class")}
let(:resource_class){ mock(:model_name => model_name) }

0 comments on commit 0dad889

Please sign in to comment.