diff --git a/plugins/community_block/lib/community_block.rb b/plugins/community_block/lib/community_block.rb new file mode 100644 index 0000000..d611a1c --- /dev/null +++ b/plugins/community_block/lib/community_block.rb @@ -0,0 +1,19 @@ +class CommunityBlock < Block + + def self.description + "Community block" + end + + def help + "Help for Community Description Block." + end + + def content(arg={}) + block = self + + lambda do + render :file => 'community_block', :locals => { :block => block } + end + end + +end diff --git a/plugins/community_block/lib/community_block_plugin.rb b/plugins/community_block/lib/community_block_plugin.rb new file mode 100644 index 0000000..00e5af7 --- /dev/null +++ b/plugins/community_block/lib/community_block_plugin.rb @@ -0,0 +1,27 @@ +require_dependency File.dirname(__FILE__) + '/community_block' + +class CommunityBlockPlugin < Noosfero::Plugin + + def self.plugin_name + "Community Block Plugin" + end + + def self.plugin_description + "A plugin that adds a block to show community description" + end + + def self.extra_blocks + { + CommunityBlock => {:type => Community} + } + end + + def self.has_admin_url? + false + end + + def stylesheet? + true + end + +end diff --git a/plugins/community_block/public/style.css b/plugins/community_block/public/style.css new file mode 100644 index 0000000..9da2b23 --- /dev/null +++ b/plugins/community_block/public/style.css @@ -0,0 +1,43 @@ +#content .box-1 .community-block { + //border: 1px solid #F00; + display: table; + width: 100%; +} + +#content .box-1 .community-block .community-block-logo { + //border: 1px solid #00F; + float: left; + width: 150px; + height: 150px; + padding: 5px; +} + +#content .box-1 .community-block-info { + //border: 1px solid #000; + float: left; + padding: 5px; + width: 360px; + margin-left: 2px; +} + +#content .box-1 .community-block .community-block-title { + //border: 1px solid #00F; + font-variant: small-caps; + color: #555753; + text-align: left; + padding-left: 10px; + margin: 0px; +} + +#content .box-1 .community-block .community-block-description { + //border: 1px solid #0F0; + font-style: italic; + color: black; + padding: 10px; +} + +#content .box-1 .community-block .community-block-buttons { + //border: 1px solid #F00; + text-align: right; +} + diff --git a/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb b/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb new file mode 100644 index 0000000..7f7794b --- /dev/null +++ b/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb @@ -0,0 +1,66 @@ +require File.dirname(__FILE__) + '/../test_helper' + +# Re-raise errors caught by the controller. +class ProfileController + append_view_path File.join(File.dirname(__FILE__) + '/../../views') + def rescue_action(e) + raise e + end +end + +class ProfileControllerTest < ActionController::TestCase + + def setup + @controller = ProfileController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + #user = create_user('testinguser') + #login_as(user.login) + + @community = fast_create(Community, :environment_id => Environment.default) + + @environment = @community.environment + @environment.enabled_plugins = ['CommunityBlock'] + @environment.save! + + CommunityBlock.delete_all + @box1 = Box.create!(:owner => @community) + @community.boxes = [@box1] + + @block = CommunityBlock.new + @block.box = @box1 + @block.save! + + @community.blocks<<@block + @community.save! + end + + attr_accessor :profile, :block, :community + + should 'display community-block-logo class in community block' do + get :index, :profile => community.identifier + assert_tag :div, :attributes => {:class => 'community-block-logo'} + end + + should 'display community-block-info class in community block' do + get :index, :profile => community.identifier + assert_tag :div, :attributes => {:class => 'community-block-info'} + end + + should 'display community-block-title class in community block' do + get :index, :profile => community.identifier + assert_tag :h1, :attributes => {:class => 'community-block-title'} + end + + should 'display community-block-description class in community block' do + get :index, :profile => community.identifier + assert_tag :div, :attributes => {:class => 'community-block-description'} + end + + should 'display community-block-buttons class in community block' do + get :index, :profile => community.identifier + assert_tag :div, :attributes => {:class => 'community-block-buttons'} + end + +end diff --git a/plugins/community_block/test/test_helper.rb b/plugins/community_block/test/test_helper.rb new file mode 100644 index 0000000..cca1fd3 --- /dev/null +++ b/plugins/community_block/test/test_helper.rb @@ -0,0 +1 @@ +require File.dirname(__FILE__) + '/../../../test/test_helper' diff --git a/plugins/community_block/test/unit/commmunity_block_plugin_test.rb b/plugins/community_block/test/unit/commmunity_block_plugin_test.rb new file mode 100644 index 0000000..122bd23 --- /dev/null +++ b/plugins/community_block/test/unit/commmunity_block_plugin_test.rb @@ -0,0 +1,33 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class CommunityBlockPluginTest < ActiveSupport::TestCase + + def setup + @plugin = CommunityBlockPlugin.new + end + + should 'be a noosfero plugin' do + assert_kind_of Noosfero::Plugin, @plugin + end + + should 'have name' do + assert_equal 'Community Block Plugin', CommunityBlockPlugin.plugin_name + end + + should 'have description' do + assert_equal "A plugin that adds a block to show community description", CommunityBlockPlugin.plugin_description + end + + should 'have stylesheet' do + assert @plugin.stylesheet? + end + + should "return CommunityBlock in extra_blocks class method" do + assert CommunityBlockPlugin.extra_blocks.keys.include?(CommunityBlock) + end + + should "return false for class method has_admin_url?" do + assert !CommunityBlockPlugin.has_admin_url? + end + +end diff --git a/plugins/community_block/test/unit/commmunity_block_test.rb b/plugins/community_block/test/unit/commmunity_block_test.rb new file mode 100644 index 0000000..06187ae --- /dev/null +++ b/plugins/community_block/test/unit/commmunity_block_test.rb @@ -0,0 +1,11 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class CommunityBlockTest < ActiveSupport::TestCase + + should "display community block" do + block = CommunityBlock.new + self.expects(:render).with(:file => 'community_block', :locals => { :block => block }) + instance_eval(& block.content) + end + +end diff --git a/plugins/community_block/views/community_block.rhtml b/plugins/community_block/views/community_block.rhtml new file mode 100644 index 0000000..fd4bae6 --- /dev/null +++ b/plugins/community_block/views/community_block.rhtml @@ -0,0 +1,38 @@ +