diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 118a7d99e..92a958f6c 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -57,7 +57,7 @@ class DocumentsController < ApplicationController end def edit - @categories = DocumentCategory.all + @categories = DocumentCategory.active #TODO: use it in the views if request.post? and @document.update_attributes(params[:document]) flash[:notice] = l(:notice_successful_update) redirect_to :action => 'show', :id => @document diff --git a/app/views/documents/_form.rhtml b/app/views/documents/_form.rhtml index b118ebdcf..3e805c198 100644 --- a/app/views/documents/_form.rhtml +++ b/app/views/documents/_form.rhtml @@ -2,7 +2,7 @@
-<%= select('document', 'category_id', DocumentCategory.all.collect {|c| [c.name, c.id]}) %>
+<%= select('document', 'category_id', DocumentCategory.active.collect {|c| [c.name, c.id]}) %><%= text_field 'document', 'title', :size => 60 %>
diff --git a/test/fixtures/enumerations.yml b/test/fixtures/enumerations.yml index 9d9556607..93e7182c9 100644 --- a/test/fixtures/enumerations.yml +++ b/test/fixtures/enumerations.yml @@ -87,3 +87,8 @@ enumerations_015: type: IssuePriority position: 6 active: false +enumerations_016: + name: Inactive Document Category + id: 16 + type: DocumentCategory + active: false diff --git a/test/functional/documents_controller_test.rb b/test/functional/documents_controller_test.rb index cdbbb399f..423faf6c9 100644 --- a/test/functional/documents_controller_test.rb +++ b/test/functional/documents_controller_test.rb @@ -45,6 +45,10 @@ class DocumentsControllerTest < ActionController::TestCase assert_tag :select, :attributes => {:name => 'document[category_id]'}, :child => {:tag => 'option', :attributes => {:selected => 'selected'}, :content => 'Technical documentation'} + + assert ! DocumentCategory.find(16).active? + assert_no_tag :option, :attributes => {:value => '16'}, + :parent => {:tag => 'select', :attributes => {:id => 'document_category_id'} } end def test_index_with_long_description