From b501e2ce38e027ef868d32ca448bc8baf6fef314 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Wed, 8 Apr 2015 12:08:02 -0300 Subject: [PATCH] Fix embed button in boxes helper --- app/helpers/boxes_helper.rb | 4 ++-- test/unit/boxes_helper_test.rb | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb index e1fd4a1..09ad592 100644 --- a/app/helpers/boxes_helper.rb +++ b/app/helpers/boxes_helper.rb @@ -251,8 +251,8 @@ module BoxesHelper content_tag('h2', _('Embed block code')) + 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;') + content_tag('textarea', embed_code, :style => 'margin-bottom: 1em; width:100%; height:40%;', :readonly => 'readonly') + - thickbox_close_button(_('Close')), :style => 'display: none;', :id => "embed-code-box-#{block.id}") - buttons << thickbox_inline_popup_icon(:embed, _('Embed code'), {}, "embed-code-box-#{block.id}") << html + modal_close_button(_('Close')), :style => 'display: none;', :id => "embed-code-box-#{block.id}") + buttons << modal_inline_icon(:embed, _('Embed code'), {}, "#embed-code-box-#{block.id}") << html end content_tag('div', buttons.join("\n") + tag('br', :style => 'clear: left'), :class => 'button-bar') diff --git a/test/unit/boxes_helper_test.rb b/test/unit/boxes_helper_test.rb index b7c06fe..a5b2be2 100644 --- a/test/unit/boxes_helper_test.rb +++ b/test/unit/boxes_helper_test.rb @@ -3,6 +3,7 @@ require 'boxes_helper' class BoxesHelperTest < ActionView::TestCase + include ApplicationHelper include BoxesHelper include ActionView::Helpers::TagHelper @@ -181,4 +182,20 @@ class BoxesHelperTest < ActionView::TestCase display_box_content(box, '') end + should 'display embed button when a block is embedable' do + box = create(Box, position: 1, owner: fast_create(Profile)) + block = Block.create!(:box => box) + block.stubs(:embedable?).returns(true) + stubs(:url_for).returns('') + assert_tag_in_string block_edit_buttons(block), :tag => 'a', :attributes => {:class => 'button icon-button icon-embed '} + end + + should 'not display embed button when a block is not embedable' do + box = create(Box, position: 1, owner: fast_create(Profile)) + block = Block.create!(:box => box) + block.stubs(:embedable?).returns(false) + stubs(:url_for).returns('') + assert_no_tag_in_string block_edit_buttons(block), :tag => 'a', :attributes => {:class => 'button icon-button icon-embed '} + end + end -- libgit2 0.21.2