diff --git a/lib/download_block.rb b/lib/download_block.rb new file mode 100644 index 0000000..567dd5c --- /dev/null +++ b/lib/download_block.rb @@ -0,0 +1,33 @@ +class DownloadBlock < Block + + attr_accessible :name, :link, :software_description,:show_name, :version_news + + settings_items :name, :type => :string, :default => '' + settings_items :link, :type => :string, :default => '' + settings_items :software_description, :type => :string, :default => '' + settings_items :show_name, :type => :boolean, :default => false + settings_items :version_news, :type => :string, :default => '' + + def self.description + _('Download Stable Version') + end + + def help + _('This block displays the stable version of a software.') + end + + def content(args={}) + block = self + s = show_name + lambda do |object| + render( + :file => 'blocks/download', + :locals => { :block => block, :show_name => s } + ) + end + end + + def cacheable? + false + end +end diff --git a/lib/mpog_software_plugin.rb b/lib/mpog_software_plugin.rb index a7072c2..bd9b567 100644 --- a/lib/mpog_software_plugin.rb +++ b/lib/mpog_software_plugin.rb @@ -128,7 +128,8 @@ class MpogSoftwarePlugin < Noosfero::Plugin { SoftwaresBlock => {:type => [Environment, Person] }, SoftwareInformationBlock => {:type => [Community] }, - InstitutionsBlock => {:type => [Environment, Person]} + InstitutionsBlock => {:type => [Environment, Person]}, + DownloadBlock => {:type => [Community]} } end diff --git a/test/unit/download_block_test.rb b/test/unit/download_block_test.rb new file mode 100644 index 0000000..4a9df35 --- /dev/null +++ b/test/unit/download_block_test.rb @@ -0,0 +1,29 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class DownloadBlockTest < ActiveSupport::TestCase + include PluginTestHelper + should 'inherit from Block' do + assert_kind_of Block, DownloadBlock.new + end + + should 'declare its default title' do + DownloadBlock.any_instance.stubs(:profile_count).returns(0) + assert_equal Block.new.default_title, DownloadBlock.new.default_title + end + + should 'describe itself' do + assert_not_equal Block.description, DownloadBlock.description + end + + should 'have software info to download it' do + + link = "gitlab.com/teste" + name = "Test Software" + + block = DownloadBlock.create(:name => name, :link => link) + + assert_equal block.link, link, "Link should not be empty" + assert_equal block.name, name, "Name should not be empty" + end +end diff --git a/views/blocks/download.html.erb b/views/blocks/download.html.erb new file mode 100644 index 0000000..2fd9a51 --- /dev/null +++ b/views/blocks/download.html.erb @@ -0,0 +1,28 @@ +
+ + <%= link_to _("Minimal Requirements") , block.owner.admin_url, :class => "anchor-link", :target => "_self" %> + + + + <%= link_to(_("Version News"), block.version_news, :class => "anchor-link", :target => "_self") if !block.version_news.blank? %> + + + + <%= _("Licensed by") %> + <%= link_to block.owner.software_info.license_info.version , block.owner.software_info.license_info.link, :target => "_blank" %> + +
+