From 703211c0a6bec8037105d2964f663c6492923f17 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 24 Nov 2011 21:31:21 +0000 Subject: [PATCH] Fixed time entries context menu display according permissions (#9405). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7922 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/context_menus_controller.rb | 5 ++--- app/views/context_menus/time_entries.html.erb | 4 ++-- .../context_menus_controller_test.rb | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/controllers/context_menus_controller.rb b/app/controllers/context_menus_controller.rb index 7e83d35d5..defadb230 100644 --- a/app/controllers/context_menus_controller.rb +++ b/app/controllers/context_menus_controller.rb @@ -51,9 +51,8 @@ class ContextMenusController < ApplicationController @projects = @time_entries.collect(&:project).compact.uniq @project = @projects.first if @projects.size == 1 @activities = TimeEntryActivity.shared.active - @can = {:edit => User.current.allowed_to?(:log_time, @projects), - :update => User.current.allowed_to?(:log_time, @projects), - :delete => User.current.allowed_to?(:log_time, @projects) + @can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects), + :delete => User.current.allowed_to?(:edit_time_entries, @projects) } @back = back_url render :layout => false diff --git a/app/views/context_menus/time_entries.html.erb b/app/views/context_menus/time_entries.html.erb index 633d3b2a2..260e1180e 100644 --- a/app/views/context_menus/time_entries.html.erb +++ b/app/views/context_menus/time_entries.html.erb @@ -15,10 +15,10 @@ <% end %> diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/context_menus_controller_test.rb index 6be9318c5..f19f166c8 100644 --- a/test/functional/context_menus_controller_test.rb +++ b/test/functional/context_menus_controller_test.rb @@ -129,4 +129,23 @@ class ContextMenusControllerTest < ActionController::TestCase assert_template 'context_menu' assert_equal [1], assigns(:issues).collect(&:id) end + + def test_time_entries_context_menu + @request.session[:user_id] = 2 + get :time_entries, :ids => [1, 2] + assert_response :success + assert_template 'time_entries' + assert_tag 'a', :content => 'Edit' + assert_no_tag 'a', :content => 'Edit', :attributes => {:class => /disabled/} + end + + def test_time_entries_context_menu_without_edit_permission + @request.session[:user_id] = 2 + Role.find_by_name('Manager').remove_permission! :edit_time_entries + + get :time_entries, :ids => [1, 2] + assert_response :success + assert_template 'time_entries' + assert_tag 'a', :content => 'Edit', :attributes => {:class => /disabled/} + end end -- 2.39.5