ref: master
plugins/require_auth_to_comment/test/functional/comment_controller_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 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 |