Move more routing tests into the routing integration test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3686 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis
2010-04-20 15:42:57 +00:00
parent 657aa624a4
commit 0fc884cf42
6 changed files with 46 additions and 212 deletions
-80
View File
@@ -34,21 +34,6 @@ class UsersControllerTest < ActionController::TestCase
@request.session[:user_id] = 1 # admin
end
def test_index_routing
assert_generates(
'/users',
:controller => 'users', :action => 'index'
)
assert_routing(
{:method => :get, :path => '/users'},
:controller => 'users', :action => 'index'
)
assert_recognizes(
{:controller => 'users', :action => 'index'},
{:method => :get, :path => '/users'}
)
end
def test_index
get :index
assert_response :success
@@ -74,17 +59,6 @@ class UsersControllerTest < ActionController::TestCase
assert_equal 'John', users.first.firstname
end
def test_show_routing
assert_routing(
{:method => :get, :path => '/users/44'},
:controller => 'users', :action => 'show', :id => '44'
)
assert_recognizes(
{:controller => 'users', :action => 'show', :id => '44'},
{:method => :get, :path => '/users/44'}
)
end
def test_show
@request.session[:user_id] = nil
get :show, :id => 2
@@ -123,38 +97,6 @@ class UsersControllerTest < ActionController::TestCase
assert_not_nil assigns(:user)
end
def test_add_routing
assert_routing(
{:method => :get, :path => '/users/new'},
:controller => 'users', :action => 'add'
)
assert_recognizes(
#TODO: remove this and replace with POST to collection, need to modify form
{:controller => 'users', :action => 'add'},
{:method => :post, :path => '/users/new'}
)
assert_recognizes(
{:controller => 'users', :action => 'add'},
{:method => :post, :path => '/users'}
)
end
def test_edit_routing
assert_routing(
{:method => :get, :path => '/users/444/edit'},
:controller => 'users', :action => 'edit', :id => '444'
)
assert_routing(
{:method => :get, :path => '/users/222/edit/membership'},
:controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
)
assert_recognizes(
#TODO: use PUT on user_path, modify form
{:controller => 'users', :action => 'edit', :id => '444'},
{:method => :post, :path => '/users/444/edit'}
)
end
def test_edit
ActionMailer::Base.deliveries.clear
post :edit, :id => 2, :user => {:firstname => 'Changed'}
@@ -192,20 +134,6 @@ class UsersControllerTest < ActionController::TestCase
assert mail.body.include?('newpass')
end
def test_add_membership_routing
assert_routing(
{:method => :post, :path => '/users/123/memberships'},
:controller => 'users', :action => 'edit_membership', :id => '123'
)
end
def test_edit_membership_routing
assert_routing(
{:method => :post, :path => '/users/123/memberships/55'},
:controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
)
end
def test_edit_membership
post :edit_membership, :id => 2, :membership_id => 1,
:membership => { :role_ids => [2]}
@@ -213,14 +141,6 @@ class UsersControllerTest < ActionController::TestCase
assert_equal [2], Member.find(1).role_ids
end
def test_destroy_membership
assert_routing(
#TODO: use DELETE method on user_membership_path, modify form
{:method => :post, :path => '/users/567/memberships/12/destroy'},
:controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
)
end
def test_destroy_membership
post :destroy_membership, :id => 2, :membership_id => 1
assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships'