Commit 1c48e726ee3f71273daf7fca70fd84ad98006e03

Authored by Leandro Santos
1 parent fec92470

fixing unit tests

plugins/community_track/lib/community_track_plugin/step.rb
@@ -60,9 +60,14 @@ class CommunityTrackPlugin::Step < Folder @@ -60,9 +60,14 @@ class CommunityTrackPlugin::Step < Folder
60 accept_comments 60 accept_comments
61 end 61 end
62 62
63 - def self.enabled_tools  
64 - [TinyMceArticle, Forum]  
65 - end 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
  69 + end
  70 +
66 71
67 def to_html(options = {}) 72 def to_html(options = {})
68 step = self 73 step = self
plugins/community_track/test/unit/community_track_plugin/track_test.rb
@@ -5,7 +5,7 @@ class TrackTest &lt; ActiveSupport::TestCase @@ -5,7 +5,7 @@ class TrackTest &lt; ActiveSupport::TestCase
5 def setup 5 def setup
6 @profile = create(Community) 6 @profile = create(Community)
7 @track = create_track('track', @profile) 7 @track = create_track('track', @profile)
8 - @step = CommunityTrackPlugin::Step.create!(:parent => @track, :start_date => Date.today, :end_date => Date.today, :name => 'step', :profile => @profile) 8 + @step = CommunityTrackPlugin::Step.create!(:parent => @track, :start_date => DateTime.now, :end_date => DateTime.now, :name => 'step', :profile => @profile)
9 @track.children << @step 9 @track.children << @step
10 @tool = fast_create(Article, :parent_id => @step.id, :profile_id => @profile.id) 10 @tool = fast_create(Article, :parent_id => @step.id, :profile_id => @profile.id)
11 @step.children << @tool 11 @step.children << @tool
@@ -30,14 +30,14 @@ class TrackTest &lt; ActiveSupport::TestCase @@ -30,14 +30,14 @@ class TrackTest &lt; ActiveSupport::TestCase
30 @track.children << @step 30 @track.children << @step
31 @step.children << article 31 @step.children << article
32 comment = create(Comment, :source => article, :author_id => owner.id) 32 comment = create(Comment, :source => article, :author_id => owner.id)
33 - @step2 = CommunityTrackPlugin::Step.create!(:parent => @track, :start_date => Date.today, :end_date => Date.today, :name => 'step2', :profile => @profile) 33 + @step2 = CommunityTrackPlugin::Step.create!(:parent => @track, :start_date => DateTime.now, :end_date => DateTime.now, :name => 'step2', :profile => @profile)
34 @step2.tool_type = 'Forum' 34 @step2.tool_type = 'Forum'
35 forum = fast_create(Forum, :parent_id => @step2.id) 35 forum = fast_create(Forum, :parent_id => @step2.id)
36 article_forum = create(Article, :name => 'article_forum', :parent_id => forum.id, :profile_id => owner.id) 36 article_forum = create(Article, :name => 'article_forum', :parent_id => forum.id, :profile_id => owner.id)
37 forum.children << article_forum 37 forum.children << article_forum
38 forum_comment = create(Comment, :source => article_forum, :author_id => owner.id) 38 forum_comment = create(Comment, :source => article_forum, :author_id => owner.id)
39 - @track.stubs(:children).returns([@step, @step2])  
40 - #@track.children = [@step, @step2] 39 + @track.children = [@step, @step2]
  40 + @track = Article.find(@track.id)
41 assert_equal 2, @track.comments_count 41 assert_equal 2, @track.comments_count
42 end 42 end
43 43
@@ -47,6 +47,7 @@ class TrackTest &lt; ActiveSupport::TestCase @@ -47,6 +47,7 @@ class TrackTest &lt; ActiveSupport::TestCase
47 47
48 should 'do not return other articles type at steps' do 48 should 'do not return other articles type at steps' do
49 article = fast_create(Article, :parent_id => @track.id, :profile_id => @track.profile.id) 49 article = fast_create(Article, :parent_id => @track.id, :profile_id => @track.profile.id)
  50 + @track = Article.find(@track.id)
50 assert_includes @track.children, article 51 assert_includes @track.children, article
51 assert_equal [@step], @track.steps_unsorted 52 assert_equal [@step], @track.steps_unsorted
52 end 53 end