2007-11-27 20:09:41 -05:00
|
|
|
require File.dirname(__FILE__) + '/../test_helper'
|
|
|
|
require 'discussions_controller'
|
|
|
|
|
|
|
|
# Re-raise errors caught by the controller.
|
|
|
|
class DiscussionsController; def rescue_action(e) raise e end; end
|
|
|
|
|
|
|
|
class DiscussionsControllerTest < Test::Unit::TestCase
|
|
|
|
fixtures :discussions
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@controller = DiscussionsController.new
|
|
|
|
@request = ActionController::TestRequest.new
|
|
|
|
@response = ActionController::TestResponse.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_get_index
|
|
|
|
get :index
|
|
|
|
assert_response :success
|
2007-11-28 01:17:25 -05:00
|
|
|
assert assigns(:pages)
|
2007-11-27 20:09:41 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_create_discussion
|
|
|
|
old_count = Discussion.count
|
2007-11-28 01:17:25 -05:00
|
|
|
post :create, :discussion => { :page_id => 1 }
|
2007-11-27 20:09:41 -05:00
|
|
|
assert_equal old_count+1, Discussion.count
|
2007-11-28 01:17:25 -05:00
|
|
|
assert_response :success
|
2007-11-27 20:09:41 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_show_discussion
|
|
|
|
get :show, :id => 1
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_update_discussion
|
2007-11-28 01:17:25 -05:00
|
|
|
put :update, :id => 1, :discussion => { :page_id => 1 }
|
|
|
|
assert_response :success
|
2007-11-27 20:09:41 -05:00
|
|
|
end
|
2007-11-28 01:17:25 -05:00
|
|
|
|
2007-11-27 20:09:41 -05:00
|
|
|
def test_should_destroy_discussion
|
|
|
|
old_count = Discussion.count
|
|
|
|
delete :destroy, :id => 1
|
|
|
|
assert_equal old_count-1, Discussion.count
|
2007-11-28 01:17:25 -05:00
|
|
|
assert_response :success
|
2007-11-27 20:09:41 -05:00
|
|
|
end
|
|
|
|
end
|