Skip to content

Commit

Permalink
Require truncate_html only in helper because that's currently the onl…
Browse files Browse the repository at this point in the history
…y place where it's used. Add specs for Refinery::HtmlTruncationHelper.
  • Loading branch information
ugisozols committed Jan 23, 2012
1 parent ca4d8da commit 65f34ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion 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
Expand Down
24 changes: 24 additions & 0 deletions 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.