[Git][noosfero/noosfero][master] 3 commits: should add custom css class to block render
Leandro Nunes
gitlab at mg.gitlab.com
Mon May 14 16:55:44 BRT 2018
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
23afe7b3 by Leandro Nunes dos Santos at 2018-05-14T12:53:23Z
should add custom css class to block render
- - - - -
42f7aeb5 by Leandro Nunes dos Santos at 2018-05-14T18:33:39Z
remove nil elements of array
- - - - -
d006b1b0 by Leandro Nunes at 2018-05-14T19:54:22Z
Merge branch 'add-custom-css-class' into 'master'
should add custom css class to block render
See merge request noosfero/noosfero!1486
- - - - -
2 changed files:
- app/helpers/boxes_helper.rb
- test/unit/boxes_helper_test.rb
Changes:
=====================================
app/helpers/boxes_helper.rb
=====================================
--- a/app/helpers/boxes_helper.rb
+++ b/app/helpers/boxes_helper.rb
@@ -128,7 +128,7 @@ module BoxesHelper
end
options = {
- :class => classes = ['block', block_css_classes(block) ].uniq.join(' '),
+ :class => classes = ['block', block.css, block_css_classes(block) ].compact.uniq.join(' '),
:id => "block-#{block.id}"
}
if ( block.respond_to? 'help' )
=====================================
test/unit/boxes_helper_test.rb
=====================================
--- a/test/unit/boxes_helper_test.rb
+++ b/test/unit/boxes_helper_test.rb
@@ -110,6 +110,32 @@ class BoxesHelperTest < ActionView::TestCase
assert block_css_classes(build(Block, :display => 'never')).split.any? { |item| item == 'invisible-block'}
end
+ should 'add custom css class of block content' do
+ out= mock()
+ out.stubs(:output_buffer=).returns('')
+ out.stubs(:assign).returns('')
+ out.stubs(:render).returns('')
+ @controller.stubs(:params).returns('')
+ @controller.stubs(:view_context).returns(out)
+ block = fast_create(MainBlock)
+ block.css = 'custom-css-class'
+ output = display_block_content(block, nil).inspect
+ assert output.match(block.css)
+ end
+
+ should 'not include any csss class if block css parameter is nil' do
+ out= mock()
+ out.stubs(:output_buffer=).returns('')
+ out.stubs(:assign).returns('')
+ out.stubs(:render).returns('')
+ @controller.stubs(:params).returns('')
+ @controller.stubs(:view_context).returns(out)
+ block = fast_create(MainBlock)
+ block.css = nil
+ output = display_block_content(block, nil).inspect
+ assert output.match('block main-block')
+ end
+
should 'fill context with the article, request_path and locale' do
request = mock()
box = create(Box, :owner => fast_create(Profile))
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/3a5209b9747b4e7a623d85b5bceee3861e3c6548...d006b1b08e71a18e15c4b424de98f264a2e12b72
--
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/3a5209b9747b4e7a623d85b5bceee3861e3c6548...d006b1b08e71a18e15c4b424de98f264a2e12b72
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180514/71f0095d/attachment-0001.html>
More information about the Noosfero-dev
mailing list