Commit b501e2ce38e027ef868d32ca448bc8baf6fef314
1 parent
886d362a
Exists in
master
and in
22 other branches
Fix embed button in boxes helper
Showing
2 changed files
with
19 additions
and
2 deletions
Show diff stats
app/helpers/boxes_helper.rb
| @@ -251,8 +251,8 @@ module BoxesHelper | @@ -251,8 +251,8 @@ module BoxesHelper | ||
| 251 | content_tag('h2', _('Embed block code')) + | 251 | content_tag('h2', _('Embed block code')) + |
| 252 | content_tag('div', _('Below, you''ll see a field containing embed code for the block. Just copy the code and paste it into your website or blogging software.'), :style => 'margin-bottom: 1em;') + | 252 | content_tag('div', _('Below, you''ll see a field containing embed code for the block. Just copy the code and paste it into your website or blogging software.'), :style => 'margin-bottom: 1em;') + |
| 253 | content_tag('textarea', embed_code, :style => 'margin-bottom: 1em; width:100%; height:40%;', :readonly => 'readonly') + | 253 | content_tag('textarea', embed_code, :style => 'margin-bottom: 1em; width:100%; height:40%;', :readonly => 'readonly') + |
| 254 | - thickbox_close_button(_('Close')), :style => 'display: none;', :id => "embed-code-box-#{block.id}") | ||
| 255 | - buttons << thickbox_inline_popup_icon(:embed, _('Embed code'), {}, "embed-code-box-#{block.id}") << html | 254 | + modal_close_button(_('Close')), :style => 'display: none;', :id => "embed-code-box-#{block.id}") |
| 255 | + buttons << modal_inline_icon(:embed, _('Embed code'), {}, "#embed-code-box-#{block.id}") << html | ||
| 256 | end | 256 | end |
| 257 | 257 | ||
| 258 | content_tag('div', buttons.join("\n") + tag('br', :style => 'clear: left'), :class => 'button-bar') | 258 | content_tag('div', buttons.join("\n") + tag('br', :style => 'clear: left'), :class => 'button-bar') |
test/unit/boxes_helper_test.rb
| @@ -3,6 +3,7 @@ require 'boxes_helper' | @@ -3,6 +3,7 @@ require 'boxes_helper' | ||
| 3 | 3 | ||
| 4 | class BoxesHelperTest < ActionView::TestCase | 4 | class BoxesHelperTest < ActionView::TestCase |
| 5 | 5 | ||
| 6 | + include ApplicationHelper | ||
| 6 | include BoxesHelper | 7 | include BoxesHelper |
| 7 | include ActionView::Helpers::TagHelper | 8 | include ActionView::Helpers::TagHelper |
| 8 | 9 | ||
| @@ -181,4 +182,20 @@ class BoxesHelperTest < ActionView::TestCase | @@ -181,4 +182,20 @@ class BoxesHelperTest < ActionView::TestCase | ||
| 181 | display_box_content(box, '') | 182 | display_box_content(box, '') |
| 182 | end | 183 | end |
| 183 | 184 | ||
| 185 | + should 'display embed button when a block is embedable' do | ||
| 186 | + box = create(Box, position: 1, owner: fast_create(Profile)) | ||
| 187 | + block = Block.create!(:box => box) | ||
| 188 | + block.stubs(:embedable?).returns(true) | ||
| 189 | + stubs(:url_for).returns('') | ||
| 190 | + assert_tag_in_string block_edit_buttons(block), :tag => 'a', :attributes => {:class => 'button icon-button icon-embed '} | ||
| 191 | + end | ||
| 192 | + | ||
| 193 | + should 'not display embed button when a block is not embedable' do | ||
| 194 | + box = create(Box, position: 1, owner: fast_create(Profile)) | ||
| 195 | + block = Block.create!(:box => box) | ||
| 196 | + block.stubs(:embedable?).returns(false) | ||
| 197 | + stubs(:url_for).returns('') | ||
| 198 | + assert_no_tag_in_string block_edit_buttons(block), :tag => 'a', :attributes => {:class => 'button icon-button icon-embed '} | ||
| 199 | + end | ||
| 200 | + | ||
| 184 | end | 201 | end |