plugins_controller_test.rb
1.76 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require File.dirname(__FILE__) + '/../test_helper'
require 'plugins_controller'
# Re-raise errors caught by the controller.
class PluginsController; def rescue_action(e) raise e end; end
class PluginsControllerTest < Test::Unit::TestCase
  all_fixtures
  def setup
    @controller = PluginsController.new
    @request    = ActionController::TestRequest.new
    @request.stubs(:ssl?).returns(true)
    @response   = ActionController::TestResponse.new
    @environment = Environment.default
    login_as(create_admin_user(@environment))
  end
  attr_reader :environment
  def test_local_files_reference
    assert_local_files_reference
  end
  def test_valid_xhtml
    assert_valid_xhtml
  end
  should 'list system active plugins' do
    class Plugin1 < Noosfero::Plugin
      class << self
        def plugin_name
        "Plugin1"
        end
        def plugin_description
          "This plugin is from hell!"
        end
      end
    end
    class Plugin2 < Noosfero::Plugin
      class << self
        def plugin_name
        "Plugin2"
        end
        def plugin_description
          "This plugin is from heaven!"
        end
      end
    end
    Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s,Plugin2.to_s])
    get :index
    assert_tag :tag => 'td', :content => /#{Plugin1.plugin_name}/
    assert_tag :tag => 'td', :content => /#{Plugin1.plugin_description}/
    assert_tag :tag => 'td', :content => /#{Plugin2.plugin_name}/
    assert_tag :tag => 'td', :content => /#{Plugin2.plugin_description}/
  end
  should 'enable or disable plugins' do
    assert_not_equal ['Plugin1'], environment.enabled_plugins
    post :update, :environment => { :enabled_plugins => ['Plugin1']}
    environment.reload
    assert_equal ['Plugin1'], environment.enabled_plugins
  end
end