]> source.dussan.org Git - redmine.git/commitdiff
Merged r4054 from trunk.
authorEric Davis <edavis@littlestreamsoftware.com>
Mon, 20 Sep 2010 03:58:20 +0000 (03:58 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Mon, 20 Sep 2010 03:58:20 +0000 (03:58 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.0-stable@4124 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/project_enumerations_controller.rb
app/controllers/projects_controller.rb
app/views/projects/settings/_activities.rhtml
config/routes.rb
lib/redmine.rb
test/functional/project_enumerations_controller_test.rb
test/functional/projects_controller_test.rb
test/integration/routing_test.rb

index c4b48e476868961be436d1a8a5c2d45b1ec9e34e..d63e2364168024676754a29005fdc8d380037929 100644 (file)
@@ -15,4 +15,12 @@ class ProjectEnumerationsController < ApplicationController
     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
index 0670cb1ec8662cf9fb7e948569884203cad731bd..90eddd7b297fe638c6e932a2ca3fad32742d0930 100644 (file)
@@ -238,14 +238,6 @@ class ProjectsController < ApplicationController
     @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]
index e39bf9b914d77f2e7499334bb57f1cd3b873c5ac..5909ac64ccc007cde3e38485265c61d862e99cc3 100644 (file)
@@ -32,7 +32,7 @@
 </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
index 4df212167efb06d9af636f736e61c63c8d6b2115..9974e21f0a652551da22086f7645f252164a6f3f 100644 (file)
@@ -227,7 +227,7 @@ ActionController::Routing::Routes.draw do |map|
 
     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
   
index a30ea54054225c187e396f4c8323b5a16c80a033..7f631ad5d47fdd90d515d4f83c2bf17857f92939 100644 (file)
@@ -87,7 +87,7 @@ Redmine::AccessControl.map do |map|
     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|
index 23da423782f88756cd721ccf21da6566eeb98c48..c03be04fb7d42702217a1261cc60c703567550ad 100644 (file)
@@ -139,4 +139,51 @@ class ProjectEnumerationsControllerTest < ActionController::TestCase
     # 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
index 152d0837b1c3c38101cb4991093b6f7cf17c3f13..4decb060fe26a6e16d7ad0bf24cceaf61c36d938 100644 (file)
@@ -381,52 +381,6 @@ class ProjectsControllerTest < ActionController::TestCase
     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)
index 0f67da68c51b046377c1a6df58c8c451cfdf8783..b8c99ca7ffd627a95809d9636b0cf4c1c4b62795 100644 (file)
@@ -190,7 +190,7 @@ class RoutingTest < ActionController::IntegrationTest
     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