Commit bee579711e627b8d5e6f39bf1e537bb525a3e052

Authored by Victor Costa
1 parent fb92dd6e

community_track: added plugin contents as enabled tools

plugins/community_track/lib/community_track_plugin/step.rb
@@ -60,8 +60,12 @@ class CommunityTrackPlugin::Step < Folder @@ -60,8 +60,12 @@ class CommunityTrackPlugin::Step < Folder
60 accept_comments 60 accept_comments
61 end 61 end
62 62
63 - def self.enabled_tools  
64 - [TinyMceArticle, Forum, CommunityHubPlugin::Hub] 63 + def enabled_tools
  64 + tools = [TinyMceArticle, Forum]
  65 + tools << CommunityHubPlugin::Hub if environment.plugin_enabled?('CommunityHubPlugin')
  66 + tools << ProposalsDiscussionPlugin::Discussion if environment.plugin_enabled?('ProposalsDiscussionPlugin')
  67 + tools << PairwisePlugin::PairwiseContent if environment.plugin_enabled?('PairwisePlugin')
  68 + tools
65 end 69 end
66 70
67 def to_html(options = {}) 71 def to_html(options = {})
plugins/community_track/test/unit/community_track_plugin/step_test.rb
1 require File.dirname(__FILE__) + '/../../test_helper' 1 require File.dirname(__FILE__) + '/../../test_helper'
2 2
  3 +module CommunityHubPlugin; class Hub < Article; end; end
  4 +
3 class StepTest < ActiveSupport::TestCase 5 class StepTest < ActiveSupport::TestCase
4 6
5 def setup 7 def setup
@@ -235,8 +237,14 @@ class StepTest &lt; ActiveSupport::TestCase @@ -235,8 +237,14 @@ class StepTest &lt; ActiveSupport::TestCase
235 end 237 end
236 238
237 should 'return enabled tools for a step' do 239 should 'return enabled tools for a step' do
238 - assert_includes CommunityTrackPlugin::Step.enabled_tools, TinyMceArticle  
239 - assert_includes CommunityTrackPlugin::Step.enabled_tools, Forum 240 + assert_includes @step.enabled_tools, TinyMceArticle
  241 + assert_includes @step.enabled_tools, Forum
  242 + end
  243 +
  244 + should 'return hub as an enabled tool if the plugin is enabled' do
  245 + @step.environment.expects(:plugin_enabled?).with(anything).returns(false).at_least_once
  246 + @step.environment.expects(:plugin_enabled?).with('CommunityHubPlugin').returns(true)
  247 + assert_includes @step.enabled_tools, CommunityHubPlugin::Hub
240 end 248 end
241 249
242 should 'return class for selected tool' do 250 should 'return class for selected tool' do
plugins/community_track/views/cms/community_track_plugin/_step.html.erb
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 { :size => 14 }) 12 { :size => 14 })
13 )) %> 13 )) %>
14 14
15 - <%= labelled_form_field(_('Tool type'), select(:article, :tool_type, CommunityTrackPlugin::Step.enabled_tools.map {|t| [t.short_description, t.name]} )) %> 15 + <%= labelled_form_field(_('Tool type'), select(:article, :tool_type, @article.enabled_tools.map {|t| [t.short_description, t.name]} )) %>
16 <%= hidden_field_tag('success_back_to', url_for(@article.parent.view_url)) %> 16 <%= hidden_field_tag('success_back_to', url_for(@article.parent.view_url)) %>
17 </div> 17 </div>
18 18