Permalink
Browse files

fix filter_reference admin helper for filter names that have spaces i…

…n them
  • Loading branch information...
1 parent fcbb5e9 commit 94fa8ed31b2778f9a4d8a69481a064ad4b082bda @mislav mislav committed Aug 31, 2008
Showing with 15 additions and 4 deletions.
  1. +1 −1 app/helpers/admin/page_helper.rb
  2. +14 −3 spec/helpers/admin/page_helper_spec.rb
@@ -16,7 +16,7 @@ def tag_reference(class_name)
def filter_reference(filter_name)
unless filter_name.blank?
- filter_class = (filter_name + "Filter").constantize
+ filter_class = (filter_name.gsub(" ", "") + "Filter").constantize
filter_class.description.blank? ? "There is no documentation on this filter." : filter_class.description
else
"There is no filter on the current page part."
@@ -1,5 +1,9 @@
require File.dirname(__FILE__) + "/../../spec_helper"
+class MarkdownPlusFilter
+ # dummy filter class
+end
+
describe Admin::PageHelper do
scenario :users_and_pages
@@ -25,9 +29,16 @@
tag_reference("Page").should =~ /Tag Reference/
end
- it "should render the filter reference" do
- filter_reference("Textile").should == TextileFilter.description
- filter_reference("").should == "There is no filter on the current page part."
+ describe "#filter_reference" do
+ it "should render the filter reference" do
+ filter_reference("Textile").should == TextileFilter.description
+ filter_reference("").should == "There is no filter on the current page part."
+ end
+
+ it "should render the filter reference for complex filter names" do
+ MarkdownPlusFilter.stub!(:description).and_return("Markdown rocks!")
+ filter_reference("Markdown Plus").should == "Markdown rocks!"
+ end
end
it "should have a default filter name" do

0 comments on commit 94fa8ed

Please sign in to comment.