Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'test_helper' | ||
|
||
class ArticleTest < ActiveSupport::TestCase | ||
|
||
def setup | ||
@article = articles(:one) | ||
end | ||
|
||
test "create article without requirements" do | ||
article = Article.new | ||
assert !article.save, "Saved an article without any validations" | ||
end | ||
|
||
# test "validations" do | ||
# assert(@article.valid?) | ||
# | ||
# @article.title = nil | ||
# assert(!@article.valid?) | ||
# | ||
# @article.title = "A title much longer than 140 character!! A title much longer than 140 character!! A title much longer than 140 character!! A title much longer than 140 character!!" | ||
# assert(!@article.valid?) | ||
# | ||
# @article.author_id = nil | ||
# assert(!@article.valid?) | ||
# | ||
# @article.body = nil | ||
# assert(!@article.valid?) | ||
# end | ||
|
||
end |