Permalink
Browse files

Require truncate_html only in helper because that's currently the onl…

…y place where it's used. Add specs for Refinery::HtmlTruncationHelper.
  • Loading branch information...
1 parent ca4d8da commit 65f34ffcc0ae17da19980e0f3fcc61644af67e38 @ugisozols ugisozols committed Jan 23, 2012
Showing with 24 additions and 1 deletion.
  1. +0 −1 core/lib/refinery/core.rb
  2. +24 −0 core/spec/helpers/refinery/html_truncation_helper_spec.rb
View
1 core/lib/refinery/core.rb
@@ -1,7 +1,6 @@
require 'rails/all'
require 'rbconfig'
require 'acts_as_indexed'
-require 'truncate_html'
require 'will_paginate'
module Refinery
View
24 core/spec/helpers/refinery/html_truncation_helper_spec.rb
@@ -0,0 +1,24 @@
+require "spec_helper"
+
+module Refinery
+ describe HtmlTruncationHelper do
+
+ it "returns nil if text is not present" do
+ helper.truncate("").should be_nil
+ end
+
+ context "when preserve_html_tags option is present" do
+ it "preserve html tags when truncating text" do
+ helper.truncate("<p>Turducken frankfurter ham hock bacon</p>",
+ :preserve_html_tags => true).should eq("<p>Turducken frankfurter ham...</p>")
+ end
+ end
+
+ context "when preserve_html_tags option is not present" do
+ it "falls back to original truncate method" do
+ helper.truncate("<p>Turducken frankfurter ham hock bacon</p>").should eq("<p>Turducken frankfurter ha...")
+ end
+ end
+
+ end
+end

0 comments on commit 65f34ff

Please sign in to comment.