plugin_hot_spot_test.rb
1.07 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
require_relative "../test_helper"
class PluginHotSpotTest < ActiveSupport::TestCase
class Client
include Noosfero::Plugin::HotSpot
end
def setup
@client = Client.new
@client.stubs(:environment).returns(Environment.new)
end
should 'instantiate only once' do
assert_same @client.plugins, @client.plugins
end
Noosfero::Plugin::HotSpot::CALLBACK_HOTSPOTS.each do |callback|
should "call #{callback} hotspot" do
class CoolPlugin < Noosfero::Plugin
include Noosfero::Plugin::HotSpot
end
CoolPlugin.any_instance.stubs("comment_#{callback}_callback".to_sym).returns(";)")
Noosfero::Plugin.stubs(:all).returns(['PluginHotSpotTest::CoolPlugin'])
Environment.default.enable_plugin(CoolPlugin)
CoolPlugin.any_instance.expects("comment_#{callback}_callback".to_sym)
person = fast_create(Person)
article = fast_create(Article, :profile_id => person.id)
comment = Comment.create!(:author => person, :title => 'test comment', :body => 'body!', :source => article)
comment.destroy
end
end
end