]> source.dussan.org Git - redmine.git/commitdiff
Do not show inactive document categories where not necessary (#8573).
authorJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>
Mon, 13 Jun 2011 20:33:06 +0000 (20:33 +0000)
committerJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>
Mon, 13 Jun 2011 20:33:06 +0000 (20:33 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6071 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/documents_controller.rb
app/views/documents/_form.rhtml
test/fixtures/enumerations.yml
test/functional/documents_controller_test.rb

index 118a7d99e95acabf90308d867cb72be99bb5f9aa..92a958f6c6c8c0331840a5de00fa79047b4f2a89 100644 (file)
@@ -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
index b118ebdcf76275f4dccfaf77b419a4872cd109bd..3e805c19875fd5e613d3c368849f6c3a10ded541 100644 (file)
@@ -2,7 +2,7 @@
 <div class="box">
 <!--[form:document]-->
 <p><label for="document_category_id"><%=l(:field_category)%></label>
-<%= select('document', 'category_id', DocumentCategory.all.collect {|c| [c.name, c.id]}) %></p>
+<%= select('document', 'category_id', DocumentCategory.active.collect {|c| [c.name, c.id]}) %></p>
 
 <p><label for="document_title"><%=l(:field_title)%> <span class="required">*</span></label>
 <%= text_field 'document', 'title', :size => 60 %></p>
index 9d9556607a0610d15ef7d3c268682308a04b54b3..93e7182c96c97dbb8d821a913e296e74e3b4acd9 100644 (file)
@@ -87,3 +87,8 @@ enumerations_015:
   type: IssuePriority
   position: 6
   active: false
+enumerations_016:
+  name: Inactive Document Category
+  id: 16
+  type: DocumentCategory
+  active: false
index cdbbb399f7856c4985d2b332eaada70129122396..423faf6c97bc03ca78d8c5e11bcb33af26f68e01 100644 (file)
@@ -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