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