##// END OF EJS Templates
Fixed time entries context menu display according permissions (#9405)....
Jean-Philippe Lang -
r7802:703211c0a6be
parent child
Show More
@@ -51,9 +51,8 class ContextMenusController < ApplicationController
51 @projects = @time_entries.collect(&:project).compact.uniq
51 @projects = @time_entries.collect(&:project).compact.uniq
52 @project = @projects.first if @projects.size == 1
52 @project = @projects.first if @projects.size == 1
53 @activities = TimeEntryActivity.shared.active
53 @activities = TimeEntryActivity.shared.active
54 @can = {:edit => User.current.allowed_to?(:log_time, @projects),
54 @can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects),
55 :update => User.current.allowed_to?(:log_time, @projects),
55 :delete => User.current.allowed_to?(:edit_time_entries, @projects)
56 :delete => User.current.allowed_to?(:log_time, @projects)
57 }
56 }
58 @back = back_url
57 @back = back_url
59 render :layout => false
58 render :layout => false
@@ -15,10 +15,10
15 <ul>
15 <ul>
16 <% @activities.each do |u| -%>
16 <% @activities.each do |u| -%>
17 <li><%= context_menu_link h(u.name), {:controller => 'timelog', :action => 'bulk_edit', :ids => @time_entries.collect(&:id), :time_entry => {'activity_id' => u}, :back_url => @back}, :method => :post,
17 <li><%= context_menu_link h(u.name), {:controller => 'timelog', :action => 'bulk_edit', :ids => @time_entries.collect(&:id), :time_entry => {'activity_id' => u}, :back_url => @back}, :method => :post,
18 :selected => (@time_entry && u == @time_entry.activity), :disabled => !@can[:update] %></li>
18 :selected => (@time_entry && u == @time_entry.activity), :disabled => !@can[:edit] %></li>
19 <% end -%>
19 <% end -%>
20 <li><%= context_menu_link l(:label_none), {:controller => 'timelog', :action => 'bulk_edit', :ids => @time_entries.collect(&:id), :time_entry => {'activity_id' => 'none'}, :back_url => @back}, :method => :post,
20 <li><%= context_menu_link l(:label_none), {:controller => 'timelog', :action => 'bulk_edit', :ids => @time_entries.collect(&:id), :time_entry => {'activity_id' => 'none'}, :back_url => @back}, :method => :post,
21 :selected => (@time_entry && @time_entry.activity.nil?), :disabled => !@can[:update] %></li>
21 :selected => (@time_entry && @time_entry.activity.nil?), :disabled => !@can[:edit] %></li>
22 </ul>
22 </ul>
23 </li>
23 </li>
24 <% end %>
24 <% end %>
@@ -129,4 +129,23 class ContextMenusControllerTest < ActionController::TestCase
129 assert_template 'context_menu'
129 assert_template 'context_menu'
130 assert_equal [1], assigns(:issues).collect(&:id)
130 assert_equal [1], assigns(:issues).collect(&:id)
131 end
131 end
132
133 def test_time_entries_context_menu
134 @request.session[:user_id] = 2
135 get :time_entries, :ids => [1, 2]
136 assert_response :success
137 assert_template 'time_entries'
138 assert_tag 'a', :content => 'Edit'
139 assert_no_tag 'a', :content => 'Edit', :attributes => {:class => /disabled/}
140 end
141
142 def test_time_entries_context_menu_without_edit_permission
143 @request.session[:user_id] = 2
144 Role.find_by_name('Manager').remove_permission! :edit_time_entries
145
146 get :time_entries, :ids => [1, 2]
147 assert_response :success
148 assert_template 'time_entries'
149 assert_tag 'a', :content => 'Edit', :attributes => {:class => /disabled/}
150 end
132 end
151 end
General Comments 0
You need to be logged in to leave comments. Login now