Commit aaca62c7151ef6f317891e6e98f9a9eb25b1c255
Committed by
Daniela Feitosa
1 parent
d40d7e7d
Exists in
master
and in
22 other branches
Hotspots tests
Signed-off-by: Daniela Soares Feitosa <danielafeitosa@colivre.coop.br>
Showing
5 changed files
with
125 additions
and
2 deletions
Show diff stats
app/views/layouts/application-ng.rhtml
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | <%= stylesheet_link_tag theme_stylesheet_path %> |
| 15 | 15 | <%= stylesheet_link_tag jquery_ui_theme_stylesheet_path %> |
| 16 | 16 | <% @plugins.enabled_plugins.each do |plugin| %> |
| 17 | - <% if plugin.stylesheet? %> | |
| 17 | + <% if plugin.stylesheets? %> | |
| 18 | 18 | <%= stylesheet_tag plugin.class.public_path('style.css'), {} %> |
| 19 | 19 | <% end %> |
| 20 | 20 | <% end %> | ... | ... |
lib/noosfero/plugin.rb
test/functional/application_controller_test.rb
| ... | ... | @@ -441,6 +441,89 @@ class ApplicationControllerTest < Test::Unit::TestCase |
| 441 | 441 | assert_tag :html, :attributes => { :lang => 'es' } |
| 442 | 442 | end |
| 443 | 443 | |
| 444 | + should 'include stylesheets supplied by plugins' do | |
| 445 | + plugin1 = mock() | |
| 446 | + plugin1.stubs(:stylesheets?).returns(true) | |
| 447 | + plugin1.stubs(:js_files).returns([]) | |
| 448 | + plugin1_class = mock() | |
| 449 | + plugin1_path = '/plugin1/style.css' | |
| 450 | + plugin1_class.stubs(:public_path).with('style.css').returns(plugin1_path) | |
| 451 | + plugin1.stubs(:class).returns(plugin1_class) | |
| 452 | + | |
| 453 | + plugin2 = mock() | |
| 454 | + plugin2.stubs(:stylesheets?).returns(true) | |
| 455 | + plugin2.stubs(:js_files).returns([]) | |
| 456 | + plugin2_class = mock() | |
| 457 | + plugin2_path = '/plugin2/style.css' | |
| 458 | + plugin2_class.stubs(:public_path).with('style.css').returns(plugin2_path) | |
| 459 | + plugin2.stubs(:class).returns(plugin2_class) | |
| 460 | + | |
| 461 | + enabled_plugins = [plugin1, plugin2] | |
| 462 | + | |
| 463 | + plugins = mock() | |
| 464 | + plugins.stubs(:map).with(:body_beginning).returns([]) | |
| 465 | + plugins.stubs(:enabled_plugins).returns(enabled_plugins) | |
| 466 | + Noosfero::Plugin::Manager.stubs(:new).returns(plugins) | |
| 467 | + | |
| 468 | + get :index | |
| 469 | + | |
| 470 | + assert_tag :tag => 'link', :attributes => {:href => /#{plugin1_path}/, :type => 'text/css', :rel => 'stylesheet'} | |
| 471 | + assert_tag :tag => 'link', :attributes => {:href => /#{plugin2_path}/, :type => 'text/css', :rel => 'stylesheet'} | |
| 472 | + end | |
| 473 | + | |
| 474 | + should 'include javascripts supplied by plugins' do | |
| 475 | + js1 = 'js1.js' | |
| 476 | + plugin1 = mock() | |
| 477 | + plugin1.stubs(:stylesheets?).returns(false) | |
| 478 | + plugin1.stubs(:js_files).returns([js1]) | |
| 479 | + plugin1_class = mock() | |
| 480 | + plugin1_path = '/plugin1/'+js1 | |
| 481 | + plugin1_class.stubs(:public_path).with(js1).returns(plugin1_path) | |
| 482 | + plugin1.stubs(:class).returns(plugin1_class) | |
| 483 | + | |
| 484 | + js2 = 'js2.js' | |
| 485 | + js3 = 'js3.js' | |
| 486 | + plugin2 = mock() | |
| 487 | + plugin2.stubs(:stylesheets?).returns(false) | |
| 488 | + plugin2.stubs(:js_files).returns([js2, js3]) | |
| 489 | + plugin2_class = mock() | |
| 490 | + plugin2_path2 = '/plugin2/'+js2 | |
| 491 | + plugin2_path3 = '/plugin2/'+js3 | |
| 492 | + plugin2_class.stubs(:public_path).with(js2).returns(plugin2_path2) | |
| 493 | + plugin2_class.stubs(:public_path).with(js3).returns(plugin2_path3) | |
| 494 | + plugin2.stubs(:class).returns(plugin2_class) | |
| 495 | + | |
| 496 | + enabled_plugins = [plugin1, plugin2] | |
| 497 | + | |
| 498 | + plugins = mock() | |
| 499 | + plugins.stubs(:map).with(:body_beginning).returns([]) | |
| 500 | + plugins.stubs(:enabled_plugins).returns(enabled_plugins) | |
| 501 | + Noosfero::Plugin::Manager.stubs(:new).returns(plugins) | |
| 502 | + | |
| 503 | + get :index | |
| 504 | + | |
| 505 | + assert_tag :tag => 'script', :attributes => {:src => /#{plugin1_path}/, :type => 'text/javascript'} | |
| 506 | + assert_tag :tag => 'script', :attributes => {:src => /#{plugin2_path2}/, :type => 'text/javascript'} | |
| 507 | + assert_tag :tag => 'script', :attributes => {:src => /#{plugin2_path3}/, :type => 'text/javascript'} | |
| 508 | + end | |
| 509 | + | |
| 510 | + should 'include content in the beginning of body supplied by plugins regardless it is a block or html code' do | |
| 511 | + plugin1_local_variable = "Plugin1" | |
| 512 | + plugin1_content = lambda {"<span id='plugin1'>This is #{plugin1_local_variable} speaking!</span>"} | |
| 513 | + plugin2_content = "<span id='plugin2'>This is Plugin2 speaking!</span>" | |
| 514 | + contents = [plugin1_content, plugin2_content] | |
| 515 | + | |
| 516 | + plugins = mock() | |
| 517 | + plugins.stubs(:enabled_plugins).returns([]) | |
| 518 | + plugins.stubs(:map).with(:body_beginning).returns(contents) | |
| 519 | + Noosfero::Plugin::Manager.stubs(:new).returns(plugins) | |
| 520 | + | |
| 521 | + get :index | |
| 522 | + | |
| 523 | + assert_tag :tag => 'span', :content => 'This is ' + plugin1_local_variable + ' speaking!', :attributes => {:id => 'plugin1'} | |
| 524 | + assert_tag :tag => 'span', :content => 'This is Plugin2 speaking!', :attributes => {:id => 'plugin2'} | |
| 525 | + end | |
| 526 | + | |
| 444 | 527 | if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' |
| 445 | 528 | |
| 446 | 529 | should 'change postgresql schema' do | ... | ... |
test/functional/catalog_controller_test.rb
| ... | ... | @@ -93,4 +93,24 @@ class CatalogControllerTest < Test::Unit::TestCase |
| 93 | 93 | end |
| 94 | 94 | end |
| 95 | 95 | |
| 96 | + should 'include extra content supplied by plugins on catalog item extras' do | |
| 97 | + product = fast_create(Product, :enterprise_id => @enterprise.id) | |
| 98 | + plugin1_local_variable = "Plugin1" | |
| 99 | + plugin1_content = lambda {"<span id='plugin1'>This is #{plugin1_local_variable} speaking!</span>"} | |
| 100 | + plugin2_local_variable = "Plugin2" | |
| 101 | + plugin2_content = lambda {"<span id='plugin2'>This is #{plugin2_local_variable} speaking!</span>"} | |
| 102 | + contents = [plugin1_content, plugin2_content] | |
| 103 | + | |
| 104 | + plugins = mock() | |
| 105 | + plugins.stubs(:enabled_plugins).returns([]) | |
| 106 | + plugins.stubs(:map).with(:body_beginning).returns([]) | |
| 107 | + plugins.stubs(:map).with(:catalog_item_extras, product).returns(contents) | |
| 108 | + Noosfero::Plugin::Manager.stubs(:new).returns(plugins) | |
| 109 | + | |
| 110 | + get :index, :profile => @enterprise.identifier | |
| 111 | + | |
| 112 | + assert_tag :tag => 'span', :content => 'This is ' + plugin1_local_variable + ' speaking!', :attributes => {:id => 'plugin1'} | |
| 113 | + assert_tag :tag => 'span', :content => 'This is ' + plugin2_local_variable + ' speaking!', :attributes => {:id => 'plugin2'} | |
| 114 | + end | |
| 115 | + | |
| 96 | 116 | end | ... | ... |
test/functional/manage_products_controller_test.rb
| ... | ... | @@ -421,6 +421,26 @@ class ManageProductsControllerTest < Test::Unit::TestCase |
| 421 | 421 | assert_tag :tag => 'div', :attributes => { :id => "product-#{product.id}-tabs" }, :descendant => {:tag => 'a', :attributes => {:href => '#product-inputs'}, :content => 'Inputs and raw material'} |
| 422 | 422 | end |
| 423 | 423 | |
| 424 | + should 'include extra content supplied by plugins on products info extras' do | |
| 425 | + product = fast_create(Product, :enterprise_id => @enterprise.id) | |
| 426 | + plugin1_local_variable = "Plugin1" | |
| 427 | + plugin1_content = lambda {"<span id='plugin1'>This is #{plugin1_local_variable} speaking!</span>"} | |
| 428 | + plugin2_local_variable = "Plugin2" | |
| 429 | + plugin2_content = lambda {"<span id='plugin2'>This is #{plugin2_local_variable} speaking!</span>"} | |
| 430 | + contents = [plugin1_content, plugin2_content] | |
| 431 | + | |
| 432 | + plugins = mock() | |
| 433 | + plugins.stubs(:enabled_plugins).returns([]) | |
| 434 | + plugins.stubs(:map).with(:body_beginning).returns([]) | |
| 435 | + plugins.stubs(:map).with(:product_info_extras, product).returns(contents) | |
| 436 | + Noosfero::Plugin::Manager.stubs(:new).returns(plugins) | |
| 437 | + | |
| 438 | + get :show, :id => product.id, :profile => @enterprise.identifier | |
| 439 | + | |
| 440 | + assert_tag :tag => 'span', :content => 'This is ' + plugin1_local_variable + ' speaking!', :attributes => {:id => 'plugin1'} | |
| 441 | + assert_tag :tag => 'span', :content => 'This is ' + plugin2_local_variable + ' speaking!', :attributes => {:id => 'plugin2'} | |
| 442 | + end | |
| 443 | + | |
| 424 | 444 | should 'remove price detail of a product' do |
| 425 | 445 | product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) |
| 426 | 446 | cost = fast_create(ProductionCost, :owner_id => Environment.default.id, :owner_type => 'Environment') | ... | ... |