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

app/controllers/context_menus_controller.rb
app/controllers/issues_controller.rb
app/views/issue_moves/new.rhtml
app/views/issues/bulk_edit.rhtml
test/fixtures/enumerations.yml
test/functional/context_menus_controller_test.rb
test/functional/issue_moves_controller_test.rb
test/functional/issues_controller_test.rb

index 4d69f4f04bea0ee9d59c2f4eed23b90fb53a7c01..dd93724dd37fa0be1fd58ebef2828237236d48d2 100644 (file)
@@ -35,7 +35,7 @@ class ContextMenusController < ApplicationController
       @trackers = @projects.map(&:trackers).inject{|memo,t| memo & t}
     end
     
-    @priorities = IssuePriority.all.reverse
+    @priorities = IssuePriority.active.reverse
     @statuses = IssueStatus.find(:all, :order => 'position')
     @back = back_url
     
index 63ee316a301b245fca2c1e3643365c3a259edd31..648848e9b0d500a840d269498c02631809e666d7 100644 (file)
@@ -115,7 +115,7 @@ class IssuesController < ApplicationController
     @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
     @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
     @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
-    @priorities = IssuePriority.all
+    @priorities = IssuePriority.active
     @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
     respond_to do |format|
       format.html { render :template => 'issues/show.rhtml' }
@@ -279,7 +279,7 @@ private
   # TODO: Refactor, not everything in here is needed by #edit
   def update_issue_from_params
     @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
-    @priorities = IssuePriority.all
+    @priorities = IssuePriority.active
     @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
     @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
     @time_entry.attributes = params[:time_entry]
@@ -315,7 +315,7 @@ private
         @issue.watcher_user_ids = params[:issue]['watcher_user_ids']
       end
     end
-    @priorities = IssuePriority.all
+    @priorities = IssuePriority.active
     @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
   end
 
index 24d59aedc527ca6a887773ef0377f4d301260974..a8a053c4ce7ecbe216016749e33effc242b6a07f 100644 (file)
@@ -32,7 +32,7 @@
 
 <p>
   <label><%= l(:field_priority) %></label>
-  <%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(IssuePriority.all, :id, :name)) %>
+  <%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(IssuePriority.active, :id, :name)) %>
 </p>
 
 <p>
index 71b30ddacb289514f7a8f71cba143e86992daeff..eebce21b4a6cdf4bead66dfbcb0d558beebd9d54 100644 (file)
@@ -21,7 +21,7 @@
 <% end %>
 <p>
        <label><%= l(:field_priority) %></label> 
-       <%= select_tag('issue[priority_id]', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(IssuePriority.all, :id, :name)) %>
+       <%= select_tag('issue[priority_id]', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(IssuePriority.active, :id, :name)) %>
 </p>
 <p>
        <label><%= l(:field_assigned_to) %></label> 
index c4a25d954838fde3ecfc5f2a963dce2c7e310205..9d9556607a0610d15ef7d3c268682308a04b54b3 100644 (file)
@@ -81,3 +81,9 @@ enumerations_014:
   type: TimeEntryActivity
   position: 4
   active: false
+enumerations_015:
+  name: Inactive Priority
+  id: 15
+  type: IssuePriority
+  position: 6
+  active: false
index 67e919a9c2d6605411c753a9d4a208f1f8c67267..23b1ca514ad81e72ff40980a14fadbc109729e26 100644 (file)
@@ -17,6 +17,7 @@ class ContextMenusControllerTest < ActionController::TestCase
     assert_tag :tag => 'a', :content => 'Immediate',
                             :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;issue%5Bpriority_id%5D=8',
                                              :class => '' }
+    assert_no_tag :tag => 'a', :content => 'Inactive Priority'
     # Versions
     assert_tag :tag => 'a', :content => '2.0',
                             :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;issue%5Bfixed_version_id%5D=3',
index 6c2cdb7cc3d29228e15430045d0a068e688308ba..2a9caca0fcc9340c0800024a1fbfaf3ee3ea6138 100644 (file)
@@ -7,6 +7,25 @@ class IssueMovesControllerTest < ActionController::TestCase
     User.current = nil
   end
 
+  def test_get_issue_moves_new
+    @request.session[:user_id] = 2
+    get :new, :id => 1
+
+    assert_tag :tag => 'option', :content => 'eCookbook',
+                                 :attributes => { :value => '1', :selected => 'selected' }
+    %w(new_tracker_id status_id priority_id assigned_to_id).each do |field|
+      assert_tag :tag => 'option', :content => '(No change)', :attributes => { :value => '' },
+                                   :parent => {:tag => 'select', :attributes => {:id => field}}
+      assert_no_tag :tag => 'option', :attributes => {:selected => 'selected'},
+                                      :parent => {:tag => 'select', :attributes => {:id => field}}
+    end
+
+    # Be sure we don't include inactive enumerations
+    assert ! IssuePriority.find(15).active?
+    assert_no_tag :option, :attributes => {:value => '15'},
+                           :parent => {:tag => 'select', :attributes => {:id => 'priority_id'} }
+  end
+
   def test_create_one_issue_to_another_project
     @request.session[:user_id] = 2
     post :create, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => ''
index d97043014c0403cdbf19a0d9930908e97a1bea4f..be9ca2f04f2ff74e802b2d8a96158e47edb8420c 100644 (file)
@@ -318,6 +318,16 @@ class IssuesControllerTest < ActionController::TestCase
                                             :content => /Notes/ } }
   end
 
+  def test_update_form_should_not_display_inactive_enumerations
+    @request.session[:user_id] = 2
+    get :show, :id => 1
+    assert_response :success
+
+    assert ! IssuePriority.find(15).active?
+    assert_no_tag :option, :attributes => {:value => '15'},
+                           :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
+  end
+
   def test_show_should_deny_anonymous_access_without_permission
     Role.anonymous.remove_permission!(:view_issues)
     get :show, :id => 1
@@ -419,6 +429,11 @@ class IssuesControllerTest < ActionController::TestCase
 
     assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
                                                  :value => 'Default string' }
+
+    # Be sure we don't display inactive IssuePriorities
+    assert ! IssuePriority.find(15).active?
+    assert_no_tag :option, :attributes => {:value => '15'},
+                           :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
   end
 
   def test_get_new_without_tracker_id
@@ -833,6 +848,11 @@ class IssuesControllerTest < ActionController::TestCase
     assert_template 'edit'
     assert_not_nil assigns(:issue)
     assert_equal Issue.find(1), assigns(:issue)
+
+    # Be sure we don't display inactive IssuePriorities
+    assert ! IssuePriority.find(15).active?
+    assert_no_tag :option, :attributes => {:value => '15'},
+                           :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
   end
 
   def test_get_edit_with_params
@@ -1185,6 +1205,11 @@ class IssuesControllerTest < ActionController::TestCase
     # System wide custom field
     assert CustomField.find(1).is_for_all?
     assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
+
+    # Be sure we don't display inactive IssuePriorities
+    assert ! IssuePriority.find(15).active?
+    assert_no_tag :option, :attributes => {:value => '15'},
+                           :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
   end
 
   def test_get_bulk_edit_on_different_projects