/
articles_controller_test.rb
52 lines (41 loc) · 1.19 KB
/
articles_controller_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'test_helper'
class ArticlesControllerTest < ActionController::TestCase
setup do
@article = articles(:one)
login_as(:brad)
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 => { :title => 'Howdy', :body => 'Some body copy', :author_id => 1 }
end
assert_redirected_to article_path(assigns(:article))
assert_equal 'Article was successfully created.', flash[:notice]
end
test "should show article" do
get :show, id: @article.to_param
assert_response :success
end
test "should get edit" do
get :edit, id: @article.to_param
assert_response :success
end
test "should update article" do
put :update, id: @article.to_param, article: @article.attributes
assert_redirected_to article_path(assigns(:article))
end
test "should destroy article" do
assert_difference('Article.count', -1) do
delete :destroy, id: @article.to_param
end
assert_redirected_to article_path
end
end