Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sample_app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Đường Sỹ Hoàng
sample_app
Commits
1607711b
Commit
1607711b
authored
Nov 14, 2019
by
Đường Sỹ Hoàng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed space
parent
df049593
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
app/models/user.rb
+4
-2
test/models/user_test.rb
+2
-2
No files found.
app/models/user.rb
View file @
1607711b
...
...
@@ -11,16 +11,18 @@ class User < ApplicationRecord
has_secure_password
class
<<
self
# Returns the hash digest of the given string.
def
User
.
digest
(
string
)
def
digest
(
string
)
cost
=
ActiveModel
::
SecurePassword
.
min_cost
?
BCrypt
::
Engine
::
MIN_COST
:
BCrypt
::
Engine
.
cost
BCrypt
::
Password
.
create
(
string
,
cost:
cost
)
end
# Returns a random token.
def
User
.
new_token
def
new_token
SecureRandom
.
urlsafe_base64
end
end
# Remembers a user in the database for use in persistent sessions
def
remember
...
...
test/models/user_test.rb
View file @
1607711b
...
...
@@ -15,7 +15,7 @@ class UserTest < ActiveSupport::TestCase
end
test
"email should be present"
do
@user
.
email
=
""
@user
.
email
=
"
"
assert_not
@user
.
valid?
end
...
...
@@ -62,7 +62,7 @@ class UserTest < ActiveSupport::TestCase
end
test
"password should be present (nonblank)"
do
@user
.
password
=
@user
.
password_confirmation
=
""
*
6
@user
.
password
=
@user
.
password_confirmation
=
"
"
*
6
assert_not
@user
.
valid?
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment