From e91068dcdcd10b5f6faabf49aac32f871c50aa3a Mon Sep 17 00:00:00 2001 From: Gabriela Navarro Date: Tue, 2 Dec 2014 10:53:55 +0000 Subject: [PATCH] Add search catalog block --- lib/mpog_software_plugin.rb | 3 ++- lib/search_catalog_block.rb | 30 ++++++++++++++++++++++++++++++ test/unit/search_catalog_block_test.rb | 19 +++++++++++++++++++ views/blocks/search_catalog.html.erb | 12 ++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 lib/search_catalog_block.rb create mode 100644 test/unit/search_catalog_block_test.rb create mode 100644 views/blocks/search_catalog.html.erb diff --git a/lib/mpog_software_plugin.rb b/lib/mpog_software_plugin.rb index 947ac73..2a4e3fd 100644 --- a/lib/mpog_software_plugin.rb +++ b/lib/mpog_software_plugin.rb @@ -127,7 +127,8 @@ class MpogSoftwarePlugin < Noosfero::Plugin DownloadBlock => {:type => [Community]}, RepositoryBlock => {:type => [Community]}, CategoriesAndTagsBlock => {:type => [Community]}, - CategoriesSoftwareBlock => {:type => [Environment]} + CategoriesSoftwareBlock => {:type => [Environment]}, + SearchCatalogBlock => {:type => [Environment]} } end diff --git a/lib/search_catalog_block.rb b/lib/search_catalog_block.rb new file mode 100644 index 0000000..71c28b0 --- /dev/null +++ b/lib/search_catalog_block.rb @@ -0,0 +1,30 @@ +class SearchCatalogBlock < Block + + attr_accessible :show_name + + settings_items :show_name, :type => :boolean, :default => false + + def self.description + _('Search Softwares catalog') + end + + def help + _('This block displays the search categories field ') + + end + + def content(args={}) + block = self + s = show_name + lambda do |object| + render( + :file => 'blocks/search_catalog', + :locals => { :block => block, :show_name => s } + ) + end + end + + def cacheable? + false + end +end diff --git a/test/unit/search_catalog_block_test.rb b/test/unit/search_catalog_block_test.rb new file mode 100644 index 0000000..64376ef --- /dev/null +++ b/test/unit/search_catalog_block_test.rb @@ -0,0 +1,19 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class SearchCatalogBlockTest < ActiveSupport::TestCase + include PluginTestHelper + should 'inherit from Block' do + assert_kind_of Block, SearchCatalogBlock.new + end + + should 'declare its default title' do + SearchCatalogBlock.any_instance.stubs(:profile_count).returns(0) + assert_equal Block.new.default_title, SearchCatalogBlock.new.default_title + end + + should 'describe itself' do + assert_not_equal Block.description, SearchCatalogBlock.description + end + +end diff --git a/views/blocks/search_catalog.html.erb b/views/blocks/search_catalog.html.erb new file mode 100644 index 0000000..f243c43 --- /dev/null +++ b/views/blocks/search_catalog.html.erb @@ -0,0 +1,12 @@ + -- libgit2 0.21.2