Commit 33c7f4542be626b205e6f78219d3676eb1282d0a
1 parent
5a1f2908
Exists in
master
and in
29 other branches
Added missing test and translation markup
(ActionItem2837)
Showing
3 changed files
with
16 additions
and
2 deletions
Show diff stats
plugins/community_track/lib/community_track_plugin/step.rb
... | ... | @@ -7,7 +7,7 @@ class CommunityTrackPlugin::Step < Folder |
7 | 7 | acts_as_list :scope => :parent |
8 | 8 | |
9 | 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 | 11 | end |
12 | 12 | |
13 | 13 | validate :belong_to_track | ... | ... |
plugins/community_track/lib/community_track_plugin/track.rb
... | ... | @@ -49,8 +49,8 @@ class CommunityTrackPlugin::Track < Folder |
49 | 49 | "community-track-plugin-track" |
50 | 50 | end |
51 | 51 | |
52 | - #FIXME make this test | |
53 | 52 | def first_paragraph |
53 | + return '' if body.blank? | |
54 | 54 | paragraphs = Hpricot(body).search('p') |
55 | 55 | paragraphs.empty? ? '' : paragraphs.first.to_html |
56 | 56 | end | ... | ... |
plugins/community_track/test/unit/community_track_plugin/track_test.rb
... | ... | @@ -110,4 +110,18 @@ class TrackTest < ActiveSupport::TestCase |
110 | 110 | assert_equal [hidden_step], @track.hidden_steps |
111 | 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 | 127 | end | ... | ... |