MorningPeak/test/controllers/comments_controller_test.rb
Arthur Poulet 7646e982d3 fix comment, implementation
- creator polymorphic instead of user
- implementation
2015-07-25 22:30:19 +02:00

50 lines
1.3 KiB
Ruby

require 'test_helper'
class CommentsControllerTest < ActionController::TestCase
setup do
@comment = comments(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:comments)
end
test "should get new" do
get :new
assert_response :success
end
test "should create comment" do
assert_difference('Comment.count') do
post :create, comment: { comment: @comment.comment, commentable_id: @comment.commentable_id, commentable_type: @comment.commentable_type, role: @comment.role, title: @comment.title, user_id: @comment.user_id }
end
assert_redirected_to comment_path(assigns(:comment))
end
test "should show comment" do
get :show, id: @comment
assert_response :success
end
test "should get edit" do
get :edit, id: @comment
assert_response :success
end
test "should update comment" do
patch :update, id: @comment, comment: { comment: @comment.comment, commentable_id: @comment.commentable_id, commentable_type: @comment.commentable_type, role: @comment.role, title: @comment.title, user_id: @comment.user_id }
assert_redirected_to comment_path(assigns(:comment))
end
test "should destroy comment" do
assert_difference('Comment.count', -1) do
delete :destroy, id: @comment
end
assert_redirected_to comments_path
end
end