Commit 54cb54e7c2531e2992ce84a66ca95a192dd794f6
1 parent
e0543b02
Exists in
master
and in
29 other branches
Find available plugins looking in the plugins directory
(ActionItem3070)
Showing
22 changed files
with
78 additions
and
23 deletions
Show diff stats
lib/noosfero/plugin.rb
... | ... | @@ -16,14 +16,7 @@ class Noosfero::Plugin |
16 | 16 | end |
17 | 17 | |
18 | 18 | def init_system |
19 | - enabled_plugins = Dir.glob(File.join(Rails.root, 'config', 'plugins', '*')) | |
20 | - if Rails.env.test? && !enabled_plugins.include?(File.join(Rails.root, 'config', 'plugins', 'foo')) | |
21 | - enabled_plugins << File.join(Rails.root, 'plugins', 'foo') | |
22 | - end | |
23 | - | |
24 | - enabled_plugins.select do |entry| | |
25 | - File.directory?(entry) | |
26 | - end.each do |dir| | |
19 | + available_plugins.each do |dir| | |
27 | 20 | load_plugin dir |
28 | 21 | end |
29 | 22 | end |
... | ... | @@ -76,12 +69,19 @@ class Noosfero::Plugin |
76 | 69 | klass(plugin_name) |
77 | 70 | end |
78 | 71 | |
79 | - def all | |
80 | - @all ||= [] | |
72 | + def available_plugins | |
73 | + unless @available_plugins | |
74 | + path = File.join(Rails.root, 'config', 'plugins', '*') | |
75 | + @available_plugins = Dir.glob(path).select{ |i| File.directory?(i) } | |
76 | + if Rails.env.test? && !@available_plugins.include?(File.join(Rails.root, 'config', 'plugins', 'foo')) | |
77 | + @available_plugins << File.join(Rails.root, 'plugins', 'foo') | |
78 | + end | |
79 | + end | |
80 | + @available_plugins | |
81 | 81 | end |
82 | 82 | |
83 | - def inherited(subclass) | |
84 | - all << subclass.to_s unless all.include?(subclass.to_s) | |
83 | + def all | |
84 | + @all ||= available_plugins.map{ |dir| (File.basename(dir) + "_plugin").camelize } | |
85 | 85 | end |
86 | 86 | |
87 | 87 | def public_name | ... | ... |
test/functional/account_controller_test.rb
... | ... | @@ -689,6 +689,7 @@ class AccountControllerTest < ActionController::TestCase |
689 | 689 | {:test => 5} |
690 | 690 | end |
691 | 691 | end |
692 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
692 | 693 | |
693 | 694 | e = User.find_by_login('ze').environment |
694 | 695 | e.enable_plugin(Plugin1.name) |
... | ... | @@ -779,6 +780,7 @@ class AccountControllerTest < ActionController::TestCase |
779 | 780 | lambda {"<strong>Plugin2 text</strong>"} |
780 | 781 | end |
781 | 782 | end |
783 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
782 | 784 | |
783 | 785 | Environment.default.enable_plugin(Plugin1.name) |
784 | 786 | Environment.default.enable_plugin(Plugin2.name) |
... | ... | @@ -795,6 +797,7 @@ class AccountControllerTest < ActionController::TestCase |
795 | 797 | User.new(:login => 'testuser') |
796 | 798 | end |
797 | 799 | end |
800 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name]) | |
798 | 801 | Environment.default.enable_plugin(Plugin1.name) |
799 | 802 | |
800 | 803 | post :login, :user => {:login => "testuser"} |
... | ... | @@ -809,6 +812,7 @@ class AccountControllerTest < ActionController::TestCase |
809 | 812 | nil |
810 | 813 | end |
811 | 814 | end |
815 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name]) | |
812 | 816 | Environment.default.enable_plugin(Plugin1.name) |
813 | 817 | post :login, :user => {:login => 'johndoe', :password => 'test'} |
814 | 818 | assert session[:user] |
... | ... | @@ -822,6 +826,7 @@ class AccountControllerTest < ActionController::TestCase |
822 | 826 | false |
823 | 827 | end |
824 | 828 | end |
829 | + Noosfero::Plugin.stubs(:all).returns([TestRegistrationPlugin.name]) | |
825 | 830 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestRegistrationPlugin.new]) |
826 | 831 | |
827 | 832 | post :signup, :user => { :login => 'testuser', :password => '123456', :password_confirmation => '123456', :email => 'testuser@example.com' } |
... | ... | @@ -840,6 +845,7 @@ class AccountControllerTest < ActionController::TestCase |
840 | 845 | true |
841 | 846 | end |
842 | 847 | end |
848 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
843 | 849 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([Plugin1.new, Plugin2.new]) |
844 | 850 | |
845 | 851 | get :login |
... | ... | @@ -853,6 +859,7 @@ class AccountControllerTest < ActionController::TestCase |
853 | 859 | false |
854 | 860 | end |
855 | 861 | end |
862 | + Noosfero::Plugin.stubs(:all).returns([TestRegistrationPlugin.name]) | |
856 | 863 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestRegistrationPlugin.new]) |
857 | 864 | |
858 | 865 | #Redirect on get action |
... | ... | @@ -876,6 +883,7 @@ class AccountControllerTest < ActionController::TestCase |
876 | 883 | true |
877 | 884 | end |
878 | 885 | end |
886 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.new, Plugin2.new]) | |
879 | 887 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([Plugin1.new, Plugin2.new]) |
880 | 888 | |
881 | 889 | get :login |
... | ... | @@ -894,6 +902,7 @@ class AccountControllerTest < ActionController::TestCase |
894 | 902 | lambda {"<strong>Plugin2 text</strong>"} |
895 | 903 | end |
896 | 904 | end |
905 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
897 | 906 | |
898 | 907 | Environment.default.enable_plugin(Plugin1.name) |
899 | 908 | Environment.default.enable_plugin(Plugin2.name) | ... | ... |
test/functional/application_controller_test.rb
... | ... | @@ -374,6 +374,8 @@ class ApplicationControllerTest < ActionController::TestCase |
374 | 374 | end |
375 | 375 | plugin2_path = '/plugin2/style.css' |
376 | 376 | |
377 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
378 | + | |
377 | 379 | environment = Environment.default |
378 | 380 | environment.enable_plugin(Plugin1.name) |
379 | 381 | environment.enable_plugin(Plugin2.name) |
... | ... | @@ -405,6 +407,8 @@ class ApplicationControllerTest < ActionController::TestCase |
405 | 407 | plugin2_path2 = '/plugin2/'+js2 |
406 | 408 | plugin2_path3 = '/plugin2/'+js3 |
407 | 409 | |
410 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
411 | + | |
408 | 412 | environment = Environment.default |
409 | 413 | environment.enable_plugin(Plugin1.name) |
410 | 414 | environment.enable_plugin(Plugin2.name) |
... | ... | @@ -431,6 +435,8 @@ class ApplicationControllerTest < ActionController::TestCase |
431 | 435 | end |
432 | 436 | end |
433 | 437 | |
438 | + Noosfero::Plugin.stubs(:all).returns([TestBodyBeginning1Plugin.name, TestBodyBeginning2Plugin.name]) | |
439 | + | |
434 | 440 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestBodyBeginning1Plugin.new, TestBodyBeginning2Plugin.new]) |
435 | 441 | |
436 | 442 | get :index |
... | ... | @@ -455,6 +461,8 @@ class ApplicationControllerTest < ActionController::TestCase |
455 | 461 | end |
456 | 462 | end |
457 | 463 | |
464 | + Noosfero::Plugin.stubs(:all).returns([TestHeadEnding1Plugin.name, TestHeadEnding2Plugin.name]) | |
465 | + | |
458 | 466 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestHeadEnding1Plugin.new, TestHeadEnding2Plugin.new]) |
459 | 467 | |
460 | 468 | get :index |
... | ... | @@ -519,6 +527,7 @@ class ApplicationControllerTest < ActionController::TestCase |
519 | 527 | :block => lambda {} } |
520 | 528 | end |
521 | 529 | end |
530 | + Noosfero::Plugin.stubs(:all).returns([FilterPlugin.name]) | |
522 | 531 | |
523 | 532 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([FilterPlugin.new]) |
524 | 533 | |
... | ... | @@ -537,6 +546,7 @@ class ApplicationControllerTest < ActionController::TestCase |
537 | 546 | :block => lambda {'plugin block called'} } |
538 | 547 | end |
539 | 548 | end |
549 | + Noosfero::Plugin.stubs(:all).returns([OtherFilterPlugin.name]) | |
540 | 550 | |
541 | 551 | environment1 = fast_create(Environment, :name => 'test environment') |
542 | 552 | environment1.enable_plugin(OtherFilterPlugin.name) | ... | ... |
test/functional/catalog_controller_test.rb
... | ... | @@ -91,6 +91,7 @@ class CatalogControllerTest < ActionController::TestCase |
91 | 91 | lambda {"<span id='plugin2'>This is Plugin2 speaking!</span>"} |
92 | 92 | end |
93 | 93 | end |
94 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
94 | 95 | |
95 | 96 | product = fast_create(Product, :profile_id => @enterprise.id) |
96 | 97 | environment = Environment.default | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -1199,6 +1199,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
1199 | 1199 | class Plugin2 < Noosfero::Plugin |
1200 | 1200 | def content_remove_edit(content); false; end |
1201 | 1201 | end |
1202 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
1202 | 1203 | |
1203 | 1204 | environment.enable_plugin(Plugin1.name) |
1204 | 1205 | environment.enable_plugin(Plugin2.name) |
... | ... | @@ -1215,6 +1216,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
1215 | 1216 | class Plugin2 < Noosfero::Plugin |
1216 | 1217 | def content_expire_edit(content); nil; end |
1217 | 1218 | end |
1219 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
1218 | 1220 | |
1219 | 1221 | environment.enable_plugin(Plugin1.name) |
1220 | 1222 | environment.enable_plugin(Plugin2.name) |
... | ... | @@ -1260,6 +1262,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
1260 | 1262 | } |
1261 | 1263 | end |
1262 | 1264 | end |
1265 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
1263 | 1266 | |
1264 | 1267 | Environment.default.enable_plugin(Plugin1.name) |
1265 | 1268 | Environment.default.enable_plugin(Plugin2.name) |
... | ... | @@ -1284,6 +1287,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
1284 | 1287 | scope.where(:referrer => 'kernel.org') |
1285 | 1288 | end |
1286 | 1289 | end |
1290 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
1287 | 1291 | |
1288 | 1292 | Environment.default.enable_plugin(Plugin1) |
1289 | 1293 | Environment.default.enable_plugin(Plugin2) |
... | ... | @@ -1341,6 +1345,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
1341 | 1345 | } |
1342 | 1346 | end |
1343 | 1347 | end |
1348 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
1344 | 1349 | |
1345 | 1350 | Environment.default.enable_plugin(Plugin1.name) |
1346 | 1351 | Environment.default.enable_plugin(Plugin2.name) | ... | ... |
test/functional/enterprise_registration_controller_test.rb
... | ... | @@ -193,6 +193,7 @@ class EnterpriseRegistrationControllerTest < ActionController::TestCase |
193 | 193 | {'plugin2' => 'Plugin 2'} |
194 | 194 | end |
195 | 195 | end |
196 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
196 | 197 | |
197 | 198 | environment = Environment.default |
198 | 199 | environment.enable_plugin(Plugin1.name) | ... | ... |
test/functional/friends_controller_test.rb
test/functional/home_controller_test.rb
... | ... | @@ -107,6 +107,7 @@ class HomeControllerTest < ActionController::TestCase |
107 | 107 | lambda {"<a href='plugin2'>Plugin2 link</a>"} |
108 | 108 | end |
109 | 109 | end |
110 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
110 | 111 | |
111 | 112 | Environment.default.enable_plugin(Plugin1) |
112 | 113 | Environment.default.enable_plugin(Plugin2) |
... | ... | @@ -129,6 +130,7 @@ class HomeControllerTest < ActionController::TestCase |
129 | 130 | true |
130 | 131 | end |
131 | 132 | end |
133 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
132 | 134 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([Plugin1.new, Plugin2.new]) |
133 | 135 | |
134 | 136 | get :index | ... | ... |
test/functional/memberships_controller_test.rb
... | ... | @@ -234,6 +234,7 @@ class MembershipsControllerTest < ActionController::TestCase |
234 | 234 | {'plugin2' => 'Plugin 2'} |
235 | 235 | end |
236 | 236 | end |
237 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
237 | 238 | |
238 | 239 | environment = Environment.default |
239 | 240 | environment.enable_plugin(Plugin1.name) | ... | ... |
test/functional/plugins_controller_test.rb
test/functional/profile_controller_test.rb
... | ... | @@ -1255,6 +1255,7 @@ class ProfileControllerTest < ActionController::TestCase |
1255 | 1255 | {:title => 'Plugin2 tab', :id => 'plugin2_tab', :content => lambda { 'Content from plugin2.' }} |
1256 | 1256 | end |
1257 | 1257 | end |
1258 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s]) | |
1258 | 1259 | |
1259 | 1260 | e = profile.environment |
1260 | 1261 | e.enable_plugin(Plugin1.name) | ... | ... |
test/functional/profile_editor_controller_test.rb
... | ... | @@ -868,6 +868,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
868 | 868 | {:title => "Plugin2 button", :icon => 'plugin2_icon', :url => 'plugin2_url'} |
869 | 869 | end |
870 | 870 | end |
871 | + Noosfero::Plugin.stubs(:all).returns([TestControlPanelButtons1.to_s, TestControlPanelButtons2.to_s]) | |
871 | 872 | |
872 | 873 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestControlPanelButtons1.new, TestControlPanelButtons2.new]) |
873 | 874 | |
... | ... | @@ -883,6 +884,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
883 | 884 | "<input id='field_added_by_plugin' value='value_of_field_added_by_plugin'/>" |
884 | 885 | end |
885 | 886 | end |
887 | + Noosfero::Plugin.stubs(:all).returns([TestProfileEditPlugin.to_s]) | |
886 | 888 | |
887 | 889 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestProfileEditPlugin.new]) |
888 | 890 | |
... | ... | @@ -911,6 +913,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
911 | 913 | lambda {"<strong>Plugin2 text</strong>"} |
912 | 914 | end |
913 | 915 | end |
916 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s]) | |
914 | 917 | |
915 | 918 | Environment.default.enable_plugin(Plugin1) |
916 | 919 | Environment.default.enable_plugin(Plugin2) |
... | ... | @@ -932,6 +935,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
932 | 935 | lambda {"<strong>Plugin2 text</strong>"} |
933 | 936 | end |
934 | 937 | end |
938 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s]) | |
935 | 939 | |
936 | 940 | Environment.default.enable_plugin(Plugin1) |
937 | 941 | Environment.default.enable_plugin(Plugin2) | ... | ... |
test/functional/search_controller_test.rb
... | ... | @@ -163,6 +163,7 @@ class SearchControllerTest < ActionController::TestCase |
163 | 163 | lambda {"<span id='plugin2'>This is Plugin2 speaking!</span>"} |
164 | 164 | end |
165 | 165 | end |
166 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s]) | |
166 | 167 | |
167 | 168 | enterprise = fast_create(Enterprise) |
168 | 169 | prod_cat = fast_create(ProductCategory) |
... | ... | @@ -189,6 +190,7 @@ class SearchControllerTest < ActionController::TestCase |
189 | 190 | return { :name => _('Property2'), :content => lambda { link_to(product.name, '/plugin2') } } |
190 | 191 | end |
191 | 192 | end |
193 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s]) | |
192 | 194 | enterprise = fast_create(Enterprise) |
193 | 195 | prod_cat = fast_create(ProductCategory) |
194 | 196 | product = fast_create(Product, {:profile_id => enterprise.id, :name => "produto1", :product_category_id => prod_cat.id}, :search => true) | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -676,6 +676,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
676 | 676 | should 'parse macros' do |
677 | 677 | class Plugin1 < Noosfero::Plugin |
678 | 678 | end |
679 | + Noosfero::Plugin.stubs(:all).returns(['ApplicationHelperTest::Plugin1']) | |
679 | 680 | |
680 | 681 | class Plugin1::Macro1 < Noosfero::Plugin::Macro |
681 | 682 | def parse(params, inner_html, source) | ... | ... |
test/unit/comment_test.rb
... | ... | @@ -468,8 +468,8 @@ class CommentTest < ActiveSupport::TestCase |
468 | 468 | end |
469 | 469 | end |
470 | 470 | |
471 | - | |
472 | 471 | should 'delegate spam detection to plugins' do |
472 | + Noosfero::Plugin.stubs(:all).returns(['CommentTest::EverythingIsSpam']) | |
473 | 473 | Environment.default.enable_plugin(EverythingIsSpam) |
474 | 474 | |
475 | 475 | c1 = create_comment |
... | ... | @@ -495,6 +495,7 @@ class CommentTest < ActiveSupport::TestCase |
495 | 495 | end |
496 | 496 | |
497 | 497 | should 'notify plugins of comments being marked as spam' do |
498 | + Noosfero::Plugin.stubs(:all).returns(['CommentTest::SpamNotification']) | |
498 | 499 | Environment.default.enable_plugin(SpamNotification) |
499 | 500 | |
500 | 501 | c = create_comment |
... | ... | @@ -506,6 +507,7 @@ class CommentTest < ActiveSupport::TestCase |
506 | 507 | end |
507 | 508 | |
508 | 509 | should 'notify plugins of comments being marked as ham' do |
510 | + Noosfero::Plugin.stubs(:all).returns(['CommentTest::SpamNotification']) | |
509 | 511 | Environment.default.enable_plugin(SpamNotification) |
510 | 512 | |
511 | 513 | c = create_comment | ... | ... |
test/unit/forgot_password_helper_test.rb
... | ... | @@ -22,6 +22,7 @@ class ForgotPasswordHelperTest < ActionView::TestCase |
22 | 22 | {:field => 'f3', :name => 'F3', :model => 'person'}] |
23 | 23 | end |
24 | 24 | end |
25 | + Noosfero::Plugin.stubs(:all).returns(['ForgotPasswordHelperTest::Plugin1', 'ForgotPasswordHelperTest::Plugin2']) | |
25 | 26 | |
26 | 27 | environment.enable_plugin(Plugin1) |
27 | 28 | environment.enable_plugin(Plugin2) |
... | ... | @@ -43,6 +44,7 @@ class ForgotPasswordHelperTest < ActionView::TestCase |
43 | 44 | {:field => 'f3', :name => 'F3', :model => 'person'}] |
44 | 45 | end |
45 | 46 | end |
47 | + Noosfero::Plugin.stubs(:all).returns(['ForgotPasswordHelperTest::Plugin1', 'ForgotPasswordHelperTest::Plugin2']) | |
46 | 48 | |
47 | 49 | environment.enable_plugin(Plugin1) |
48 | 50 | environment.enable_plugin(Plugin2) |
... | ... | @@ -64,6 +66,7 @@ class ForgotPasswordHelperTest < ActionView::TestCase |
64 | 66 | {:field => 'f3', :name => 'F3', :model => 'user'}] |
65 | 67 | end |
66 | 68 | end |
69 | + Noosfero::Plugin.stubs(:all).returns(['ForgotPasswordHelperTest::Plugin1', 'ForgotPasswordHelperTest::Plugin2']) | |
67 | 70 | |
68 | 71 | environment.enable_plugin(Plugin1) |
69 | 72 | environment.enable_plugin(Plugin2) |
... | ... | @@ -85,6 +88,7 @@ class ForgotPasswordHelperTest < ActionView::TestCase |
85 | 88 | {:field => 'f3', :name => 'F3', :model => 'user'}] |
86 | 89 | end |
87 | 90 | end |
91 | + Noosfero::Plugin.stubs(:all).returns(['ForgotPasswordHelperTest::Plugin1', 'ForgotPasswordHelperTest::Plugin2']) | |
88 | 92 | |
89 | 93 | environment.enable_plugin(Plugin1) |
90 | 94 | environment.enable_plugin(Plugin2) | ... | ... |
test/unit/macros_helper_test.rb
... | ... | @@ -28,6 +28,7 @@ class MacrosHelperTest < ActiveSupport::TestCase |
28 | 28 | end |
29 | 29 | |
30 | 30 | def setup |
31 | + Noosfero::Plugin.stubs(:all).returns(['MacrosHelperTest::Plugin1']) | |
31 | 32 | @environment = Environment.default |
32 | 33 | @environment.enable_plugin(Plugin1) |
33 | 34 | @plugins = Noosfero::Plugin::Manager.new(@environment, self) | ... | ... |
test/unit/person_test.rb
... | ... | @@ -1255,6 +1255,7 @@ class PersonTest < ActiveSupport::TestCase |
1255 | 1255 | false |
1256 | 1256 | end |
1257 | 1257 | end |
1258 | + Noosfero::Plugin.stubs(:all).returns(['PersonTest::Plugin1', 'PersonTest::Plugin2']) | |
1258 | 1259 | |
1259 | 1260 | e = Environment.default |
1260 | 1261 | e.enable_plugin(Plugin1.name) |
... | ... | @@ -1424,6 +1425,7 @@ class PersonTest < ActiveSupport::TestCase |
1424 | 1425 | Profile.memberships_of(Person.find_by_identifier('person2')) |
1425 | 1426 | end |
1426 | 1427 | end |
1428 | + Noosfero::Plugin.stubs(:all).returns(['PersonTest::Plugin1', 'PersonTest::Plugin2']) | |
1427 | 1429 | |
1428 | 1430 | Environment.default.enable_plugin(Plugin1) |
1429 | 1431 | Environment.default.enable_plugin(Plugin2) | ... | ... |
test/unit/plugin_manager_test.rb
... | ... | @@ -26,6 +26,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
26 | 26 | class Plugin2 < Noosfero::Plugin; end; |
27 | 27 | class Plugin3 < Noosfero::Plugin; end; |
28 | 28 | class Plugin4 < Noosfero::Plugin; end; |
29 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2', 'PluginManagerTest::Plugin3', 'PluginManagerTest::Plugin4']) | |
29 | 30 | environment.stubs(:enabled_plugins).returns([Plugin1.to_s, Plugin2.to_s, Plugin4.to_s]) |
30 | 31 | Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin3.to_s, Plugin4.to_s]) |
31 | 32 | results = plugins.enabled_plugins.map { |instance| instance.class.to_s } |
... | ... | @@ -51,6 +52,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
51 | 52 | 'Plugin 2 action.' |
52 | 53 | end |
53 | 54 | end |
55 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2']) | |
54 | 56 | |
55 | 57 | environment.stubs(:enabled_plugins).returns([Plugin1.to_s, Plugin2.to_s]) |
56 | 58 | |
... | ... | @@ -83,6 +85,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
83 | 85 | 'Plugin 3 action.' |
84 | 86 | end |
85 | 87 | end |
88 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2', 'PluginManagerTest::Plugin3']) | |
86 | 89 | |
87 | 90 | environment.stubs(:enabled_plugins).returns([Plugin1.to_s, Plugin2.to_s, Plugin3.to_s]) |
88 | 91 | p1 = Plugin1.new |
... | ... | @@ -107,6 +110,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
107 | 110 | 'Plugin3' |
108 | 111 | end |
109 | 112 | end |
113 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2', 'PluginManagerTest::Plugin3']) | |
110 | 114 | |
111 | 115 | environment.enable_plugin(Plugin1.name) |
112 | 116 | environment.enable_plugin(Plugin2.name) |
... | ... | @@ -134,6 +138,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
134 | 138 | true |
135 | 139 | end |
136 | 140 | end |
141 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2', 'PluginManagerTest::Plugin3']) | |
137 | 142 | |
138 | 143 | environment.enable_plugin(Plugin1.name) |
139 | 144 | environment.enable_plugin(Plugin2.name) |
... | ... | @@ -162,6 +167,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
162 | 167 | true |
163 | 168 | end |
164 | 169 | end |
170 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2', 'PluginManagerTest::Plugin3']) | |
165 | 171 | |
166 | 172 | environment.enable_plugin(Plugin1.name) |
167 | 173 | environment.enable_plugin(Plugin2.name) |
... | ... | @@ -178,6 +184,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
178 | 184 | [Macro1, Macro2] |
179 | 185 | end |
180 | 186 | end |
187 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1']) | |
181 | 188 | |
182 | 189 | class Plugin1::Macro1 < Noosfero::Plugin::Macro |
183 | 190 | def convert(macro, source) |
... | ... | @@ -212,6 +219,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
212 | 219 | [v1 * v, v2 * v] |
213 | 220 | end |
214 | 221 | end |
222 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2']) | |
215 | 223 | |
216 | 224 | environment.enable_plugin(Plugin1) |
217 | 225 | environment.enable_plugin(Plugin2) |
... | ... | @@ -231,6 +239,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
231 | 239 | value * 5 |
232 | 240 | end |
233 | 241 | end |
242 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2']) | |
234 | 243 | |
235 | 244 | environment.enable_plugin(Plugin1) |
236 | 245 | environment.enable_plugin(Plugin2) |
... | ... | @@ -252,6 +261,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
252 | 261 | [v1 * v, v2 * v, 666] |
253 | 262 | end |
254 | 263 | end |
264 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2']) | |
255 | 265 | |
256 | 266 | environment.enable_plugin(Plugin1) |
257 | 267 | environment.enable_plugin(Plugin2) |
... | ... | @@ -273,6 +283,7 @@ class PluginManagerTest < ActiveSupport::TestCase |
273 | 283 | numbers.reject {|n| n<=5} |
274 | 284 | end |
275 | 285 | end |
286 | + Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2']) | |
276 | 287 | |
277 | 288 | environment.enable_plugin(Plugin1) |
278 | 289 | environment.enable_plugin(Plugin2) | ... | ... |
test/unit/plugin_test.rb
... | ... | @@ -9,15 +9,9 @@ class PluginTest < ActiveSupport::TestCase |
9 | 9 | |
10 | 10 | include Noosfero::Plugin::HotSpot |
11 | 11 | |
12 | - should 'keep the list of all loaded subclasses' do | |
13 | - class Plugin1 < Noosfero::Plugin | |
14 | - end | |
15 | - | |
16 | - class Plugin2 < Noosfero::Plugin | |
17 | - end | |
18 | - | |
19 | - assert_includes Noosfero::Plugin.all, Plugin1.to_s | |
20 | - assert_includes Noosfero::Plugin.all, Plugin2.to_s | |
12 | + should 'keep the list of all available plugins' do | |
13 | + assert File.directory?(File.join(Rails.root, 'plugins', 'foo')) | |
14 | + assert_includes Noosfero::Plugin.all, 'FooPlugin' | |
21 | 15 | end |
22 | 16 | |
23 | 17 | should 'returns url to plugin management if plugin has admin_controller' do | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -1812,6 +1812,7 @@ class ProfileTest < ActiveSupport::TestCase |
1812 | 1812 | Person.members_of(Community.find_by_identifier('community2')) |
1813 | 1813 | end |
1814 | 1814 | end |
1815 | + Noosfero::Plugin.stubs(:all).returns(['ProfileTest::Plugin1', 'ProfileTest::Plugin2']) | |
1815 | 1816 | Environment.default.enable_plugin(Plugin1) |
1816 | 1817 | Environment.default.enable_plugin(Plugin2) |
1817 | 1818 | |
... | ... | @@ -1969,6 +1970,7 @@ class ProfileTest < ActiveSupport::TestCase |
1969 | 1970 | end |
1970 | 1971 | |
1971 | 1972 | environment = Environment.default |
1973 | + Noosfero::Plugin.stubs(:all).returns(['ProfileTest::Plugin1']) | |
1972 | 1974 | environment.enable_plugin(Plugin1) |
1973 | 1975 | plugins = Noosfero::Plugin::Manager.new(environment, self) |
1974 | 1976 | p = fast_create(Profile) | ... | ... |
test/unit/suggest_article_test.rb
... | ... | @@ -7,6 +7,7 @@ class SuggestArticleTest < ActiveSupport::TestCase |
7 | 7 | ActionMailer::Base.perform_deliveries = true |
8 | 8 | ActionMailer::Base.deliveries = [] |
9 | 9 | @profile = create_user('test_user').person |
10 | + Noosfero::Plugin.stubs(:all).returns(['SuggestArticleTest::EverythingIsSpam', 'SuggestArticleTest::SpamNotification']) | |
10 | 11 | end |
11 | 12 | attr_reader :profile |
12 | 13 | ... | ... |