Commit 417935cc972d1e6b3947441d67845ed980693251
1 parent
03101c7a
Exists in
master
and in
22 other branches
Add a Raw HTML block
(ActionItem1652)
Showing
4 changed files
with
40 additions
and
1 deletions
Show diff stats
app/controllers/admin/environment_design_controller.rb
| ... | ... | @@ -3,7 +3,7 @@ class EnvironmentDesignController < BoxOrganizerController |
| 3 | 3 | protect 'edit_environment_design', :environment |
| 4 | 4 | |
| 5 | 5 | def available_blocks |
| 6 | - @available_blocks ||= [ ArticleBlock, LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, PeopleBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock ] | |
| 6 | + @available_blocks ||= [ ArticleBlock, LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, PeopleBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock, RawHTMLBlock ] | |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 9 | end | ... | ... |
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<%= labelled_form_field(_('HTML code'), text_area(:block, :html, :style => 'width: 100%', :rows => 15)) %> | ... | ... |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +require File.dirname(__FILE__) + '/../test_helper' | |
| 2 | + | |
| 3 | +class RawHTMLBlockTest < ActiveSupport::TestCase | |
| 4 | + | |
| 5 | + should 'describe itself' do | |
| 6 | + assert_not_equal Block.description, RawHTMLBlock.description | |
| 7 | + end | |
| 8 | + | |
| 9 | + should 'store HTML' do | |
| 10 | + block = RawHTMLBlock.new(:html => '<strong>HTML!</strong>') | |
| 11 | + assert_equal '<strong>HTML!</strong>', block.html | |
| 12 | + end | |
| 13 | + | |
| 14 | + should 'not filter HTML' do | |
| 15 | + html = '<script type="text/javascript">alert("Hello, world")</script>"' | |
| 16 | + block = RawHTMLBlock.new(:html => html) | |
| 17 | + assert_equal html, block.html | |
| 18 | + end | |
| 19 | + | |
| 20 | + should 'return html as content' do | |
| 21 | + block = RawHTMLBlock.new(:html => "HTML") | |
| 22 | + assert_match(/HTML$/, block.content) | |
| 23 | + end | |
| 24 | + | |
| 25 | +end | ... | ... |