Commit 628002e31d386a6ce6f91e7ed9d61c3683d3d127
1 parent
0cd4c377
Exists in
master
and in
22 other branches
Testing documentation ordering
(ActionItem1487)
Showing
2 changed files
with
14 additions
and
3 deletions
Show diff stats
app/models/doc_topic.rb
@@ -22,8 +22,11 @@ class DocTopic < DocItem | @@ -22,8 +22,11 @@ class DocTopic < DocItem | ||
22 | end | 22 | end |
23 | 23 | ||
24 | def self.order(line) | 24 | def self.order(line) |
25 | - line =~ /<h1 class="order-(.*)">.*<\/h1>/ | ||
26 | - $1 | 25 | + if line =~ /<h1 class="order-(.*)">.*<\/h1>/ |
26 | + $1.to_i | ||
27 | + else | ||
28 | + 0 | ||
29 | + end | ||
27 | end | 30 | end |
28 | 31 | ||
29 | end | 32 | end |
test/unit/doc_topic_test.rb
1 | -require 'test_helper' | 1 | +require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | ||
3 | class DocTopicTest < ActiveSupport::TestCase | 3 | class DocTopicTest < ActiveSupport::TestCase |
4 | should 'be a DocItem' do | 4 | should 'be a DocItem' do |
@@ -25,4 +25,12 @@ class DocTopicTest < ActiveSupport::TestCase | @@ -25,4 +25,12 @@ class DocTopicTest < ActiveSupport::TestCase | ||
25 | end | 25 | end |
26 | end | 26 | end |
27 | 27 | ||
28 | + should 'read order from HTML' do | ||
29 | + assert_equal 1, DocTopic.order('<h1 class="order-1">Some topic</h1>') | ||
30 | + end | ||
31 | + | ||
32 | + should 'use 0 as order by default' do | ||
33 | + assert_equal 0, DocTopic.order('<h1>Some topic</h1>') | ||
34 | + end | ||
35 | + | ||
28 | end | 36 | end |