Commit 3d76539d2ff554dc23824e71b3475c1356eea5f1
Committed by
Joenio Costa
1 parent
16d7dc3c
Exists in
staging
and in
42 other branches
Raising 'not found' page while accessing an unexistent topic in a section
(ActionItem1397)
Showing
2 changed files
with
14 additions
and
1 deletions
Show diff stats
app/models/doc_section.rb
@@ -5,7 +5,12 @@ class DocSection < DocItem | @@ -5,7 +5,12 @@ class DocSection < DocItem | ||
5 | end | 5 | end |
6 | 6 | ||
7 | def find(id) | 7 | def find(id) |
8 | - items.find {|item| item.id == id } | 8 | + topic = items.find {|item| item.id == id } |
9 | + if topic | ||
10 | + topic | ||
11 | + else | ||
12 | + raise DocItem::NotFound | ||
13 | + end | ||
9 | end | 14 | end |
10 | 15 | ||
11 | def self.all(language = 'en', force = false) | 16 | def self.all(language = 'en', force = false) |
test/unit/doc_section_test.rb
@@ -97,4 +97,12 @@ class DocSectionTest < ActiveSupport::TestCase | @@ -97,4 +97,12 @@ class DocSectionTest < ActiveSupport::TestCase | ||
97 | end | 97 | end |
98 | end | 98 | end |
99 | 99 | ||
100 | + should 'raise DocTopic::NotFound when trying to find an unexisting topic inside a section' do | ||
101 | + section = DocSection.all.first | ||
102 | + assert_raise DocItem::NotFound do | ||
103 | + section.find('unexisting') | ||
104 | + end | ||
105 | + end | ||
106 | + | ||
107 | + | ||
100 | end | 108 | end |