]> source.dussan.org Git - redmine.git/commitdiff
Show shared versions when editing issues from different projects with the context...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Jul 2012 13:19:46 +0000 (13:19 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Jul 2012 13:19:46 +0000 (13:19 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9961 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/context_menus_controller.rb
app/views/context_menus/issues.html.erb
test/functional/context_menus_controller_test.rb

index f371b2e042c42f7aef1266a126c2124f37d2be06..329c0d0c13ce0108180b410ec1a384e7d6929922 100644 (file)
@@ -48,6 +48,7 @@ class ContextMenusController < ApplicationController
       @assignables = @projects.map(&:assignable_users).reduce(:&)
       @trackers = @projects.map(&:trackers).reduce(:&)
     end
+    @versions = @projects.map {|p| p.shared_versions.open}.reduce(:&)
 
     @priorities = IssuePriority.active.reverse
     @back = back_url
index f90cbf0e5c6c5f649791c30e120072c2c9d5df90..f029ca408e6dfd134b064165e1f1f8d45b684301 100644 (file)
   </li>
   <% end %>
 
-  <% #TODO: allow editing versions when multiple projects %>
-  <% if @safe_attributes.include?('fixed_version_id') && @project && @project.shared_versions.open.any? -%>
+  <% if @safe_attributes.include?('fixed_version_id') && @versions.any? -%>
   <li class="folder">
     <a href="#" class="submenu"><%= l(:field_fixed_version) %></a>
     <ul>
-    <% @project.shared_versions.open.sort.each do |v| -%>
+    <% @versions.sort.each do |v| -%>
         <li><%= context_menu_link format_version_name(v), {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'fixed_version_id' => v}, :back_url => @back}, :method => :post,
                                   :selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:update] %></li>
     <% end -%>
index d3da4cd4b228a665a9de3936699cea0a3f9730af..1d90ada2544961e2fc7b551e448ca4b02fe639b2 100644 (file)
@@ -223,6 +223,18 @@ class ContextMenusControllerTest < ActionController::TestCase
                                              :class => '' }
   end
 
+  def test_context_menu_should_propose_shared_versions_for_issues_from_different_projects
+    @request.session[:user_id] = 2
+    version = Version.create!(:name => 'Shared', :sharing => 'system', :project_id => 1)
+
+    get :issues, :ids => [1, 4]
+    assert_response :success
+    assert_template 'context_menu'
+
+    assert_include version, assigns(:versions)
+    assert_tag :tag => 'a', :content => 'eCookbook - Shared'
+  end
+
   def test_context_menu_issue_visibility
     get :issues, :ids => [1, 4]
     assert_response :success