50 lines
1.3 KiB
Ruby
50 lines
1.3 KiB
Ruby
require 'test_helper'
|
|
|
|
class ArticlesControllerTest < ActionController::TestCase
|
|
setup do
|
|
@article = articles(:one)
|
|
end
|
|
|
|
test "should get index" do
|
|
get :index
|
|
assert_response :success
|
|
assert_not_nil assigns(:articles)
|
|
end
|
|
|
|
test "should get new" do
|
|
get :new
|
|
assert_response :success
|
|
end
|
|
|
|
test "should create article" do
|
|
assert_difference('Article.count') do
|
|
post :create, article: { active: @article.active, content: @article.content, created_by: @article.created_by, rate: @article.rate, title: @article.title, updated_by: @article.updated_by }
|
|
end
|
|
|
|
assert_redirected_to article_path(assigns(:article))
|
|
end
|
|
|
|
test "should show article" do
|
|
get :show, id: @article
|
|
assert_response :success
|
|
end
|
|
|
|
test "should get edit" do
|
|
get :edit, id: @article
|
|
assert_response :success
|
|
end
|
|
|
|
test "should update article" do
|
|
patch :update, id: @article, article: { active: @article.active, content: @article.content, created_by: @article.created_by, rate: @article.rate, title: @article.title, updated_by: @article.updated_by }
|
|
assert_redirected_to article_path(assigns(:article))
|
|
end
|
|
|
|
test "should destroy article" do
|
|
assert_difference('Article.count', -1) do
|
|
delete :destroy, id: @article
|
|
end
|
|
|
|
assert_redirected_to articles_path
|
|
end
|
|
end
|