2007-09-27 02:19:14 -04:00
|
|
|
require File.dirname(__FILE__) + '/../test_helper'
|
|
|
|
require 'pages_controller'
|
|
|
|
|
|
|
|
# Re-raise errors caught by the controller.
|
|
|
|
class PagesController; def rescue_action(e) raise e end; end
|
|
|
|
|
|
|
|
class PagesControllerTest < Test::Unit::TestCase
|
|
|
|
fixtures :pages
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@controller = PagesController.new
|
|
|
|
@request = ActionController::TestRequest.new
|
|
|
|
@response = ActionController::TestResponse.new
|
|
|
|
end
|
|
|
|
|
2007-10-03 02:34:21 -04:00
|
|
|
def test_should_get_index
|
|
|
|
get :index
|
|
|
|
assert_response :success
|
|
|
|
assert assigns(:page)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_get_new
|
|
|
|
get :new
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_create_page
|
|
|
|
old_count = Page.count
|
|
|
|
post :create, :page => { :title => 'TestPage' }
|
|
|
|
assert_equal old_count+1, Page.count
|
|
|
|
|
2007-11-11 01:33:08 -05:00
|
|
|
assert_redirected_to page_path(assigns(:page).title_for_url)
|
2007-10-03 02:34:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_show_page
|
|
|
|
get :show, :id => 'HomePage'
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_get_edit
|
|
|
|
get :edit, :id => 'HomePage'
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_update_page
|
|
|
|
put :update, :id => 'HomePage', :page => { :title => 'HomePage' }
|
2007-11-11 01:33:08 -05:00
|
|
|
assert_redirected_to page_path(assigns(:page).title_for_url)
|
2007-10-03 02:34:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_destroy_page
|
|
|
|
old_count = Page.count
|
|
|
|
delete :destroy, :id => 'HomePage'
|
|
|
|
assert_equal old_count-1, Page.count
|
|
|
|
|
|
|
|
assert_redirected_to pages_path
|
2007-09-27 02:19:14 -04:00
|
|
|
end
|
|
|
|
end
|