Permalink
Browse files

Bug fix & more robust testing to tag combinations

  • Loading branch information...
1 parent 6f48eb0 commit fac86bd2acdb054705f4f60cc0e020966258a990 @jstirk committed Sep 17, 2009
Showing with 20 additions and 4 deletions.
  1. +4 −4 lib/simple_product_manager_tag.rb
  2. +16 −0 spec/lib/simple_product_manager_spec.rb
View
8 lib/simple_product_manager_tag.rb
@@ -146,7 +146,7 @@ module SimpleProductManagerTag
end
result = []
- Category.find(:conditions => where, :order => order).each do |category|
+ Category.find_all_top_level(:conditions => where, :order => order).each do |category|
tag.locals.category = category
result << tag.expand
end
@@ -178,7 +178,7 @@ module SimpleProductManagerTag
html_escape category.description
end
- desc "Renders the requested field from the category loaded by <r:category:find> or <r:category:each>. Requires 'name' is provided."
+ desc "Renders the requested field from the category loaded by <r:category:find> or <r:categories:each>. Requires 'name' is provided."
tag 'category:field' do |tag|
attr = tag.attr.symbolize_keys
category = tag.locals.category
@@ -223,13 +223,13 @@ module SimpleProductManagerTag
tag 'subcategory:link' do |tag|
end
- desc "Renders the HTML-escaped title of the current subcategory loaded by <r:subcategory> or <r:categories:each>"
+ desc "Renders the HTML-escaped title of the current subcategory loaded by <r:subcategory> or <r:subcategories:each>"
tag 'subcategory:title' do |tag|
subcategory = tag.locals.subcategory
html_escape subcategory.title
end
- desc "Renders the HTML-escaped description of the current subcategory loaded by <r:subcategory> or <r:categories:each>"
+ desc "Renders the HTML-escaped description of the current subcategory loaded by <r:subcategory> or <r:subcategories:each>"
tag 'subcategory:description' do |tag|
subcategory = tag.locals.subcategory
html_escape subcategory.description
View
16 spec/lib/simple_product_manager_spec.rb
@@ -237,5 +237,21 @@
it "should fetch existing data OK"
it "should return nothing on missing data"
end
+
+ describe "complex test" do
+ it "should handle a simple list of categories" do
+ source='<r:categories:each order="title ASC"><r:category:title />:<r:subcategories:each order="title ASC"><r:subcategory:title />,</r:subcategories:each>|</r:categories:each>'
+ results=''
+ Category.find_all_top_level(:order => "title ASC").each do |cat|
+ results << "#{cat.title}:"
+ cat.subcategories.find(:all, :order => 'title ASC').each do |subcat|
+ results << "#{subcat.title},"
+ end
+ results << "|"
+ end
+
+ pages(:home).should render(source).as(results)
+ end
+ end
end

0 comments on commit fac86bd

Please sign in to comment.