-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added model tests, user.rb so it has many articles.
- Loading branch information
1 parent
bae59b5
commit 19d0e06
Showing
5 changed files
with
57 additions
and
6 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
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
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,44 @@ | ||
require "test_helper" | ||
|
||
class UserTest < ActiveSupport::TestCase | ||
include FactoryBot::Syntax::Methods | ||
setup do | ||
@user = create(:user) | ||
end | ||
|
||
test "should be valid" do | ||
assert @user.valid? | ||
end | ||
|
||
test "name should be present" do | ||
@user.name = "" | ||
assert_not @user.valid? | ||
end | ||
|
||
test "email should be present" do | ||
@user.email = "" | ||
assert_not @user.valid? | ||
end | ||
|
||
test "name should be unique" do | ||
duplicate_user = @user.dup | ||
@user.save | ||
assert_not duplicate_user.valid? | ||
end | ||
|
||
test "email should be unique" do | ||
duplicate_user = @user.dup | ||
duplicate_user.email = @user.email.upcase | ||
@user.save | ||
assert_not duplicate_user.valid? | ||
end | ||
|
||
test "password should be present (nonblank)" do | ||
@user.password = @user.password_confirmation = "" | ||
assert_not @user.valid? | ||
end | ||
|
||
test "should have many articles" do | ||
assert_respond_to @user, :articles | ||
end | ||
end |