Commit 33c7f4542be626b205e6f78219d3676eb1282d0a

Authored by Daniela Feitosa
1 parent 5a1f2908

Added missing test and translation markup

(ActionItem2837)
plugins/community_track/lib/community_track_plugin/step.rb
@@ -7,7 +7,7 @@ class CommunityTrackPlugin::Step < Folder @@ -7,7 +7,7 @@ class CommunityTrackPlugin::Step < Folder
7 acts_as_list :scope => :parent 7 acts_as_list :scope => :parent
8 8
9 def belong_to_track 9 def belong_to_track
10 - errors.add(:parent, "Step not allowed at this parent.") if !parent.kind_of?(CommunityTrackPlugin::Track) 10 + errors.add(:parent, _("Step not allowed at this parent.")) unless parent.kind_of?(CommunityTrackPlugin::Track)
11 end 11 end
12 12
13 validate :belong_to_track 13 validate :belong_to_track
plugins/community_track/lib/community_track_plugin/track.rb
@@ -49,8 +49,8 @@ class CommunityTrackPlugin::Track < Folder @@ -49,8 +49,8 @@ class CommunityTrackPlugin::Track < Folder
49 "community-track-plugin-track" 49 "community-track-plugin-track"
50 end 50 end
51 51
52 - #FIXME make this test  
53 def first_paragraph 52 def first_paragraph
  53 + return '' if body.blank?
54 paragraphs = Hpricot(body).search('p') 54 paragraphs = Hpricot(body).search('p')
55 paragraphs.empty? ? '' : paragraphs.first.to_html 55 paragraphs.empty? ? '' : paragraphs.first.to_html
56 end 56 end
plugins/community_track/test/unit/community_track_plugin/track_test.rb
@@ -110,4 +110,18 @@ class TrackTest < ActiveSupport::TestCase @@ -110,4 +110,18 @@ class TrackTest < ActiveSupport::TestCase
110 assert_equal [hidden_step], @track.hidden_steps 110 assert_equal [hidden_step], @track.hidden_steps
111 end 111 end
112 112
  113 + should 'get first paragraph' do
  114 + @track.body = '<p>First</p><p>Second</p>'
  115 + assert_equal '<p>First</p>', @track.first_paragraph
  116 + end
  117 +
  118 + should 'provide first_paragraph even if body was not given' do
  119 + assert_equal '', @track.first_paragraph
  120 + end
  121 +
  122 + should 'provide first_paragraph even if body is nil' do
  123 + @track.body = nil
  124 + assert_equal '', @track.first_paragraph
  125 + end
  126 +
113 end 127 end