noosfero | 3 new commits pushed to repository
Bráulio Bhavamitra
gitlab at gitlab.com
Sun Feb 22 20:08:09 BRT 2015
Bráulio Bhavamitra pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>
Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/afbebeee18b5e35e3ae7d8e483b6f59d6d2cc304">afbebeee</a> by Larissa Reis
[tolerance-time-plugin] Change lambda to proc
Part of rails 3 migration
Also removes useless line. The check for enabled plugin is made before
adding the filter. Besides, that proc was never called.
- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/052b0480b3b66187166b3454b76218c0361f8417">052b0480</a> by Larissa Reis
[relevant-content-plugin] Fixes crash when VotePlugin is not found
When vote plugin is not enabled in a noosfero instance, the constant
VotePlugin is not defined, which was causing a crash in relevant
content plugin. So I check if the plugin is enabled using a string and
not a constant.
- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/97489673c6318dbfd4675c8a9b62213a6bc448ff">97489673</a> by Bráulio Bhavamitra
Merge branch 'fixes-plugins' into 'master'
Fixes for ToleranceTimePlugin and RelevantContentPlugin
Fixes blocking crashes when enabling these plugins: NameError exception in RelevantContentPlugin and argument mismatch for ToleranceTimePlugin.
See merge request !450
- - - - -
Changes:
=====================================
plugins/relevant_content/lib/relevant_content_plugin/relevant_content_block.rb
=====================================
--- a/plugins/relevant_content/lib/relevant_content_plugin/relevant_content_block.rb
+++ b/plugins/relevant_content/lib/relevant_content_plugin/relevant_content_block.rb
@@ -4,7 +4,7 @@ class RelevantContentPlugin::RelevantContentBlock < Block
end
def default_title
- _('Relevant content')
+ _('Relevant content')
end
def help
@@ -53,7 +53,7 @@ class RelevantContentPlugin::RelevantContentBlock < Block
env = owner.environment
end
- if env.plugin_enabled?(VotePlugin)
+ if env.plugin_enabled?('VotePlugin')
if self.show_most_liked
docs = Article.more_positive_votes(owner, self.limit)
if !docs.blank?
=====================================
plugins/relevant_content/test/unit/article.rb
=====================================
--- a/plugins/relevant_content/test/unit/article.rb
+++ b/plugins/relevant_content/test/unit/article.rb
@@ -20,10 +20,10 @@ class RelevantContentBlockTest < ActiveSupport::TestCase
def enable_vote_plugin
enabled = false
- environment=Environment.default
+ environment = Environment.default
if Noosfero::Plugin.all.include?('VotePlugin')
- if not environment.enabled_plugins.include?(:vote)
- environment.enable_plugin(Vote)
+ if not environment.enabled_plugins.include?('VotePlugin')
+ environment.enable_plugin(VotePlugin)
environment.save!
end
enabled = true
@@ -145,4 +145,4 @@ class RelevantContentBlockTest < ActiveSupport::TestCase
assert_equal '23 votes for 29 votes against', articles.first.name
assert_equal '2 votes against', articles.last.name
end
-end
\ No newline at end of file
+end
=====================================
plugins/relevant_content/test/unit/relevant_content_block_test.rb
=====================================
--- a/plugins/relevant_content/test/unit/relevant_content_block_test.rb
+++ b/plugins/relevant_content/test/unit/relevant_content_block_test.rb
@@ -44,4 +44,19 @@ class RelevantContentBlockTest < ActiveSupport::TestCase
assert_equal RelevantContentPlugin::RelevantContentBlock.expire_on, {:environment=>[:article], :profile=>[:article]}
end
+ should 'not crash if vote plugin is not found' do
+ box = fast_create(Box, :owner_id => @profile.id, :owner_type => 'Profile')
+ block = RelevantContentPlugin::RelevantContentBlock.new(:box => box)
+
+ Environment.any_instance.stubs(:enabled_plugins).returns(['RelevantContent'])
+ # When the plugin is disabled from noosfero instance, its constant name is
+ # undefined. To test this case, I have to manually undefine the constant
+ # if necessary.
+ Object.send(:remove_const, VotePlugin.to_s) if defined? VotePlugin
+
+ assert_nothing_raised do
+ block.content
+ end
+ end
+
end
=====================================
plugins/tolerance_time/lib/tolerance_time_plugin.rb
=====================================
--- a/plugins/tolerance_time/lib/tolerance_time_plugin.rb
+++ b/plugins/tolerance_time/lib/tolerance_time_plugin.rb
@@ -28,8 +28,7 @@ class ToleranceTimePlugin < Noosfero::Plugin
end
def cms_controller_filters
- p = Proc.new { |context| return if !context.environment.plugin_enabled?(ToleranceTimePlugin) }
- block = lambda do
+ block = proc do
content = Article.find(params[:id])
if ToleranceTimePlugin.expired?(content)
session[:notice] = _("This content can't be edited anymore because it expired the tolerance time")
@@ -43,8 +42,7 @@ class ToleranceTimePlugin < Noosfero::Plugin
end
def content_viewer_controller_filters
- p = Proc.new { |context| return if !context.environment.plugin_enabled?(ToleranceTimePlugin) }
- block = lambda do
+ block = proc do
content = Comment.find(params[:id])
if ToleranceTimePlugin.expired?(content)
session[:notice] = _("This content can't be edited anymore because it expired the tolerance time")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150222/31e48dab/attachment-0001.html>
More information about the Noosfero-dev
mailing list