Commit ec60dac8845c213eb1fcd12bb9aefff1ef8ab2cb

Authored by Leandro Santos
1 parent 9994dedf

require_auth_to_comment: fix exception protected method logged_in?

plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
... ... @@ -43,7 +43,9 @@ class RequireAuthToCommentPlugin < Noosfero::Plugin
43 43  
44 44 protected
45 45  
46   - delegate :logged_in?, :to => :context
  46 + def logged_in?
  47 + context.send(:logged_in?)
  48 + end
47 49  
48 50 def allowed_by_profile
49 51 context.profile && context.profile.allow_unauthenticated_comments
... ...
plugins/require_auth_to_comment/test/functional/comment_controller_test.rb 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +require_relative '../test_helper'
  2 +
  3 +class CommentControllerTest < ActionController::TestCase
  4 +
  5 + def setup
  6 + @environment = Environment.default
  7 + @environment.enable_plugin(RequireAuthToCommentPlugin)
  8 + @community = fast_create(Community)
  9 + @person = create_user.person
  10 + @article = fast_create(TextArticle, :profile_id => @community.id, :body => "some article")
  11 + end
  12 +
  13 + attr_reader :community, :article, :person
  14 +
  15 + should 'not make comments if not logged in' do
  16 + assert_no_difference 'Comment.count' do
  17 + xhr :post, :create, :profile => community.identifier, :id => article.id, :comment => {:body => "Some comment..."}, :confirm => 'true'
  18 + end
  19 +
  20 + end
  21 +
  22 + should 'make comments if logged in' do
  23 + login_as person.user.login
  24 + assert_difference 'Comment.count', 1 do
  25 + xhr :post, :create, :profile => community.identifier, :id => article.id, :comment => {:body => "Some comment..."}, :confirm => 'true'
  26 + end
  27 + end
  28 +end
... ...
plugins/require_auth_to_comment/test/test_helper.rb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +require_relative '../../../test/test_helper'
... ...