redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
end
+ def destroy
+ @project.time_entry_activities.each do |time_entry_activity|
+ time_entry_activity.destroy(time_entry_activity.parent)
+ end
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
+ end
+
end
@project = nil
end
- def reset_activities
- @project.time_entry_activities.each do |time_entry_activity|
- time_entry_activity.destroy(time_entry_activity.parent)
- end
- flash[:notice] = l(:notice_successful_update)
- redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
- end
-
private
def find_optional_project
return true unless params[:id]
</table>\r
\r
<div class="contextual">\r
-<%= link_to(l(:button_reset), {:controller => 'projects', :action => 'reset_activities', :id => @project},\r
+<%= link_to(l(:button_reset), {:controller => 'project_enumerations', :action => 'destroy', :id => @project},\r
:method => :delete,\r
:confirm => l(:text_are_you_sure),\r
:class => 'icon icon-del') %>\r
projects.with_options :conditions => {:method => :delete} do |project_actions|
project_actions.conditions 'projects/:id.:format', :action => 'destroy', :format => /xml/
- project_actions.conditions 'projects/:id/reset_activities', :action => 'reset_activities'
+ project_actions.conditions 'projects/:id/reset_activities', :controller => 'project_enumerations', :action => 'destroy'
end
end
map.permission :view_time_entries, :timelog => [:details, :report]
map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member
map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin
- map.permission :manage_project_activities, {:projects => [:reset_activities], :project_enumerations => [:save]}, :require => :member
+ map.permission :manage_project_activities, {:project_enumerations => [:save, :destroy]}, :require => :member
end
map.project_module :news do |map|
# TimeEntries shouldn't have been reassigned on the saved record either
assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size, "Time Entries are not assigned to system activities"
end
+
+ def test_destroy
+ @request.session[:user_id] = 2 # manager
+ project_activity = TimeEntryActivity.new({
+ :name => 'Project Specific',
+ :parent => TimeEntryActivity.find(:first),
+ :project => Project.find(1),
+ :active => true
+ })
+ assert project_activity.save
+ project_activity_two = TimeEntryActivity.new({
+ :name => 'Project Specific Two',
+ :parent => TimeEntryActivity.find(:last),
+ :project => Project.find(1),
+ :active => true
+ })
+ assert project_activity_two.save
+
+ delete :destroy, :id => 1
+ assert_response :redirect
+ assert_redirected_to 'projects/ecookbook/settings/activities'
+
+ assert_nil TimeEntryActivity.find_by_id(project_activity.id)
+ assert_nil TimeEntryActivity.find_by_id(project_activity_two.id)
+ end
+
+ def test_destroy_should_reassign_time_entries_back_to_the_system_activity
+ @request.session[:user_id] = 2 # manager
+ project_activity = TimeEntryActivity.new({
+ :name => 'Project Specific Design',
+ :parent => TimeEntryActivity.find(9),
+ :project => Project.find(1),
+ :active => true
+ })
+ assert project_activity.save
+ assert TimeEntry.update_all("activity_id = '#{project_activity.id}'", ["project_id = ? AND activity_id = ?", 1, 9])
+ assert 3, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size
+
+ delete :destroy, :id => 1
+ assert_response :redirect
+ assert_redirected_to 'projects/ecookbook/settings/activities'
+
+ assert_nil TimeEntryActivity.find_by_id(project_activity.id)
+ assert_equal 0, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size, "TimeEntries still assigned to project specific activity"
+ assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "TimeEntries still assigned to project specific activity"
+ end
+
end
assert_template 'show'
end
- def test_reset_activities
- @request.session[:user_id] = 2 # manager
- project_activity = TimeEntryActivity.new({
- :name => 'Project Specific',
- :parent => TimeEntryActivity.find(:first),
- :project => Project.find(1),
- :active => true
- })
- assert project_activity.save
- project_activity_two = TimeEntryActivity.new({
- :name => 'Project Specific Two',
- :parent => TimeEntryActivity.find(:last),
- :project => Project.find(1),
- :active => true
- })
- assert project_activity_two.save
-
- delete :reset_activities, :id => 1
- assert_response :redirect
- assert_redirected_to 'projects/ecookbook/settings/activities'
-
- assert_nil TimeEntryActivity.find_by_id(project_activity.id)
- assert_nil TimeEntryActivity.find_by_id(project_activity_two.id)
- end
-
- def test_reset_activities_should_reassign_time_entries_back_to_the_system_activity
- @request.session[:user_id] = 2 # manager
- project_activity = TimeEntryActivity.new({
- :name => 'Project Specific Design',
- :parent => TimeEntryActivity.find(9),
- :project => Project.find(1),
- :active => true
- })
- assert project_activity.save
- assert TimeEntry.update_all("activity_id = '#{project_activity.id}'", ["project_id = ? AND activity_id = ?", 1, 9])
- assert 3, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size
-
- delete :reset_activities, :id => 1
- assert_response :redirect
- assert_redirected_to 'projects/ecookbook/settings/activities'
-
- assert_nil TimeEntryActivity.find_by_id(project_activity.id)
- assert_equal 0, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size, "TimeEntries still assigned to project specific activity"
- assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "TimeEntries still assigned to project specific activity"
- end
-
# A hook that is manually registered later
class ProjectBasedTemplate < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context)
should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'edit', :id => '1', :format => 'xml'
should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
- should_route :delete, "/projects/64/reset_activities", :controller => 'projects', :action => 'reset_activities', :id => '64'
+ should_route :delete, "/projects/64/reset_activities", :controller => 'project_enumerations', :action => 'destroy', :id => '64'
end
context "repositories" do