Use #find_issues as before filter for issues context menu.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11961 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7371077fa2
commit
60d2a5e322
|
@ -19,17 +19,15 @@ class ContextMenusController < ApplicationController
|
||||||
helper :watchers
|
helper :watchers
|
||||||
helper :issues
|
helper :issues
|
||||||
|
|
||||||
|
before_filter :find_issues, :only => :issues
|
||||||
|
|
||||||
def issues
|
def issues
|
||||||
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
|
|
||||||
(render_404; return) unless @issues.present?
|
|
||||||
if (@issues.size == 1)
|
if (@issues.size == 1)
|
||||||
@issue = @issues.first
|
@issue = @issues.first
|
||||||
end
|
end
|
||||||
@issue_ids = @issues.map(&:id).sort
|
@issue_ids = @issues.map(&:id).sort
|
||||||
|
|
||||||
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
||||||
@projects = @issues.collect(&:project).compact.uniq
|
|
||||||
@project = @projects.first if @projects.size == 1
|
|
||||||
|
|
||||||
@can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
|
@can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
|
||||||
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
||||||
|
|
|
@ -219,11 +219,9 @@ class ContextMenusControllerTest < ActionController::TestCase
|
||||||
assert_select 'a', :text => 'eCookbook - Shared'
|
assert_select 'a', :text => 'eCookbook - Shared'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_context_menu_issue_visibility
|
def test_context_menu_with_issue_that_is_not_visible_should_fail
|
||||||
get :issues, :ids => [1, 4]
|
get :issues, :ids => [1, 4] # issue 4 is not visible
|
||||||
assert_response :success
|
assert_response 302
|
||||||
assert_template 'context_menu'
|
|
||||||
assert_equal [1], assigns(:issues).collect(&:id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_respond_with_404_without_ids
|
def test_should_respond_with_404_without_ids
|
||||||
|
|
Loading…
Reference in New Issue