diff --git a/app/models/doc_section.rb b/app/models/doc_section.rb index 68b8f82..03269d9 100644 --- a/app/models/doc_section.rb +++ b/app/models/doc_section.rb @@ -5,7 +5,12 @@ class DocSection < DocItem end def find(id) - items.find {|item| item.id == id } + topic = items.find {|item| item.id == id } + if topic + topic + else + raise DocItem::NotFound + end end def self.all(language = 'en', force = false) diff --git a/test/unit/doc_section_test.rb b/test/unit/doc_section_test.rb index 8912f31..d9074b4 100644 --- a/test/unit/doc_section_test.rb +++ b/test/unit/doc_section_test.rb @@ -97,4 +97,12 @@ class DocSectionTest < ActiveSupport::TestCase end end + should 'raise DocTopic::NotFound when trying to find an unexisting topic inside a section' do + section = DocSection.all.first + assert_raise DocItem::NotFound do + section.find('unexisting') + end + end + + end -- libgit2 0.21.2