Skip to content

Commit

Permalink
test: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
al3rez committed Dec 19, 2023
1 parent fce0a4c commit 2a2caad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
class User < ApplicationRecord
include Personable

has_secure_password

include Personable
validates :password, presence: true
validates :password_confirmation, presence: true
end
8 changes: 7 additions & 1 deletion test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ class UserTest < ActiveSupport::TestCase
person = Person.new(email: "example@gmail.com", personable: user)
assert_raises(ActiveRecord::RecordInvalid) { person.save! }
end
j
test "should not save user without password confirmation" do
user = User.new(password: "password")
person = Person.new(email: "example@gmail.com", personable: user)
assert_raises(ActiveRecord::RecordInvalid) { person.save! }
end

test "should save user with password" do
user = User.new(password: "password")
user = User.new(password: "password", password_confirmation: "password")
person = Person.new(email: "exmaple@gmail.com", personable: user)
assert person.save!
end
Expand Down

0 comments on commit 2a2caad

Please sign in to comment.