cirandas.net

ref: master

plugins/comment_paragraph/test/functional/comment_paragraph_plugin_myprofile_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
29
30
31
32
33
34
35
require_relative '../test_helper'

class CommentParagraphPluginMyprofileControllerTest < ActionController::TestCase

  def setup
    @environment = Environment.default
    @environment.enable_plugin(CommentParagraphPlugin)
    @profile = fast_create(Profile)
    @user = create_user_with_permission('testuser', 'post_content', @profile)
    login_as(@user.identifier)
    @article = fast_create(TextArticle, :profile_id => profile.id, :author_id => @user.id)
  end

  attr_reader :article, :profile, :user, :environment

  should 'toggle comment paragraph activation' do
    assert !article.comment_paragraph_plugin_activate
    get :toggle_activation, :id => article.id, :profile => profile.identifier
    assert article.reload.comment_paragraph_plugin_activate
    assert_redirected_to article.view_url
  end

  should 'deny access to toggle activation for forbidden users' do
    login_as(create_user('anotheruser').login)
    get :toggle_activation, :id => article.id, :profile => profile.identifier
    assert_response :forbidden
  end

  should 'deny access to toggle activation if plugin is not enabled' do
    environment.disable_plugin(CommentParagraphPlugin)
    get :toggle_activation, :id => article.id, :profile => profile.identifier
    assert_response :forbidden
  end

end