Commit 3d76539d2ff554dc23824e71b3475c1356eea5f1

Authored by Rodrigo Souto
Committed by Joenio Costa
1 parent 16d7dc3c

Raising 'not found' page while accessing an unexistent topic in a section

(ActionItem1397)
app/models/doc_section.rb
... ... @@ -5,7 +5,12 @@ class DocSection < DocItem
5 5 end
6 6  
7 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 14 end
10 15  
11 16 def self.all(language = 'en', force = false)
... ...
test/unit/doc_section_test.rb
... ... @@ -97,4 +97,12 @@ class DocSectionTest < ActiveSupport::TestCase
97 97 end
98 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 108 end
... ...