summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-10-12 15:55:21 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-10-12 15:55:21 +0000
commit718816c5d4b0c45ce1def155c9f517fb5ac91e35 (patch)
treee93a1b1140dabe388d1988feabbc133443d15d08 /test
parent71dd4b8a7db0208be22175a69fb71909933f4c57 (diff)
downloadredmine-718816c5d4b0c45ce1def155c9f517fb5ac91e35.tar.gz
redmine-718816c5d4b0c45ce1def155c9f517fb5ac91e35.zip
Refactor: convert timelogs to a REST resource (:time_entries)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4250 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/timelog_controller_test.rb6
-rw-r--r--test/integration/routing_test.rb51
2 files changed, 45 insertions, 12 deletions
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 28ca93531..d35b98c71 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -56,7 +56,7 @@ class TimelogControllerTest < ActionController::TestCase
assert_response :success
assert_template 'edit'
# Default activity selected
- assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/timelog/update/2' }
+ assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/time_entries/2' }
end
def test_get_edit_with_an_existing_time_entry_with_inactive_activity
@@ -114,7 +114,7 @@ class TimelogControllerTest < ActionController::TestCase
def test_destroy
@request.session[:user_id] = 2
- post :destroy, :id => 1
+ delete :destroy, :id => 1
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal I18n.t(:notice_successful_delete), flash[:notice]
assert_nil TimeEntry.find_by_id(1)
@@ -128,7 +128,7 @@ class TimelogControllerTest < ActionController::TestCase
end
@request.session[:user_id] = 2
- post :destroy, :id => 1
+ delete :destroy, :id => 1
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
assert_not_nil TimeEntry.find_by_id(1)
diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb
index 401ce960f..25755dc36 100644
--- a/test/integration/routing_test.rb
+++ b/test/integration/routing_test.rb
@@ -221,27 +221,60 @@ class RoutingTest < ActionController::IntegrationTest
should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
end
- context "timelogs" do
+ context "timelogs (global)" do
should_route :get, "/time_entries", :controller => 'timelog', :action => 'index'
should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv'
should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom'
+ should_route :get, "/time_entries/new", :controller => 'timelog', :action => 'new'
+ should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22'
+
+ should_route :post, "/time_entries", :controller => 'timelog', :action => 'create'
+
+ should_route :put, "/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22'
+
+ should_route :delete, "/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55'
+ end
+
+ context "timelogs (scoped under project)" do
should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567'
should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv'
should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom'
+ should_route :get, "/projects/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => '567'
+ should_route :get, "/projects/567/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :project_id => '567'
+
+ should_route :post, "/projects/567/time_entries", :controller => 'timelog', :action => 'create', :project_id => '567'
+
+ should_route :put, "/projects/567/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :project_id => '567'
+
+ should_route :delete, "/projects/567/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :project_id => '567'
+ end
+
+ context "timelogs (scoped under issues)" do
should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234'
should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv'
should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom'
- should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :issue_id => '123'
+ should_route :get, "/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234'
+ should_route :get, "/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234'
- should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '567'
- should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => 'ecookbook'
- should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => 'ecookbook', :issue_id => '567'
- should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22'
+ should_route :post, "/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234'
- should_route :post, "/projects/ecookbook/timelog/edit", :controller => 'timelog', :action => 'create', :project_id => 'ecookbook'
- should_route :post, "/time_entries/55/destroy", :controller => 'timelog', :action => 'destroy', :id => '55'
+ should_route :put, "/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234'
- should_route :put, "/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22'
+ should_route :delete, "/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234'
+ end
+
+ context "timelogs (scoped under project and issues)" do
+ should_route :get, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook'
+ should_route :get, "/projects/ecookbook/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'csv'
+ should_route :get, "/projects/ecookbook/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'atom'
+ should_route :get, "/projects/ecookbook/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234', :project_id => 'ecookbook'
+ should_route :get, "/projects/ecookbook/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
+
+ should_route :post, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234', :project_id => 'ecookbook'
+
+ should_route :put, "/projects/ecookbook/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
+
+ should_route :delete, "/projects/ecookbook/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234', :project_id => 'ecookbook'
end
context "time_entry_reports" do