Skip to content

Commit

Permalink
Ensure all HTML accessor methods return HTML safe strings.
Browse files Browse the repository at this point in the history
This is required to ensure HTML is not escaped when outputted in views.
  • Loading branch information
jasoncodes committed Apr 28, 2011
1 parent 94b93f1 commit 2d34999
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/models/posts_spec.rb
Expand Up @@ -24,8 +24,10 @@ def test_post(name)
its(:content) { should =~ /\ALorem ipsum/ }
its(:content_html) { should =~ /^<p>Lorem ipsum/ }
its(:content_html) { should =~ /^<p>Duis aute irure dolor/ }
its(:content_html) { should be_html_safe }
its(:summary_html) { should =~ /^<p>Lorem ipsum/ }
its(:summary_html) { should_not =~ /^<p>Duis aute irure dolor/ }
its(:summary_html) { should be_html_safe }
end

context "with custom title post" do
Expand All @@ -39,10 +41,12 @@ def test_post(name)
context "with image post" do
subject { test_post '2011-04-28-image' }
its(:summary_html) { should =~ /^<p>Image description/ }
its(:summary_html) { should be_html_safe }
end

context "with custom summary post" do
subject { test_post '2011-04-28-summary' }
its(:summary_html) { should == '<p>This is a custom &amp; test summary.</p>' }
its(:summary_html) { should be_html_safe }
end
end

0 comments on commit 2d34999

Please sign in to comment.