[Git][noosfero/noosfero][master] 2 commits: require_auth_to_comment: fix exception protected method logged_in?

Victor Costa gitlab at mg.gitlab.com
Wed Dec 9 14:50:55 BRST 2015


Victor Costa pushed to branch master at Noosfero / noosfero


Commits:
ec60dac8 by Leandro Nunes dos Santos at 2015-12-09T11:54:59Z
require_auth_to_comment: fix exception protected method logged_in?

- - - - -
dbaa5364 by Victor Costa at 2015-12-09T16:49:46Z
Merge branch 'require_auth_to_comment_fix' into 'master'

require_auth_to_comment_plugin: fix exception protected method calling logged_in?

require_auth_to_comment_plugin: fix exception protected method when calling logged_in? on plugin

See merge request !745
- - - - -


3 changed files:

- plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
- + plugins/require_auth_to_comment/test/functional/comment_controller_test.rb
- + plugins/require_auth_to_comment/test/test_helper.rb


Changes:

=====================================
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
=====================================
--- a/plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
+++ b/plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
@@ -43,7 +43,9 @@ class RequireAuthToCommentPlugin < Noosfero::Plugin
 
   protected
 
-  delegate :logged_in?, :to => :context
+  def logged_in?
+    context.send(:logged_in?)
+  end
 
   def allowed_by_profile
     context.profile && context.profile.allow_unauthenticated_comments


=====================================
plugins/require_auth_to_comment/test/functional/comment_controller_test.rb
=====================================
--- /dev/null
+++ b/plugins/require_auth_to_comment/test/functional/comment_controller_test.rb
@@ -0,0 +1,28 @@
+require_relative '../test_helper'
+
+class CommentControllerTest < ActionController::TestCase
+
+  def setup
+    @environment = Environment.default
+    @environment.enable_plugin(RequireAuthToCommentPlugin)
+    @community = fast_create(Community)
+    @person = create_user.person
+    @article = fast_create(TextArticle, :profile_id => @community.id, :body => "some article")
+  end
+
+  attr_reader :community, :article, :person
+
+  should 'not make comments if not logged in' do
+    assert_no_difference 'Comment.count' do
+      xhr :post, :create, :profile => community.identifier, :id => article.id, :comment => {:body => "Some comment..."}, :confirm => 'true'
+    end
+
+  end
+
+  should 'make comments if logged in' do
+    login_as person.user.login
+    assert_difference 'Comment.count', 1 do
+      xhr :post, :create, :profile => community.identifier, :id => article.id, :comment => {:body => "Some comment..."}, :confirm => 'true'
+    end
+  end
+end


=====================================
plugins/require_auth_to_comment/test/test_helper.rb
=====================================
--- /dev/null
+++ b/plugins/require_auth_to_comment/test/test_helper.rb
@@ -0,0 +1 @@
+require_relative '../../../test/test_helper'



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/9994dedf6a10575daccf8b761db72829bd3623f8...dbaa5364af92428ccbef9302985cf80312ea872d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20151209/ffdd01be/attachment.html>


More information about the Noosfero-dev mailing list