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
2232576e
Commit
2232576e
authored
Nov 19, 2019
by
Đường Sỹ Hoàng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed coding styles
parent
260d8e87
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
12 additions
and
22 deletions
+12
-22
app/controllers/sessions_controller.rb
+1
-1
app/controllers/users_controller.rb
+0
-1
app/mailers/user_mailer.rb
+0
-1
app/models/user.rb
+0
-1
config/environments/development.rb
+1
-3
config/routes.rb
+7
-7
db/schema.rb
+0
-2
db/seeds.rb
+1
-1
test/controllers/account_activations_controller_test.rb
+1
-4
test/integration/users_signup_test.rb
+1
-1
No files found.
app/controllers/sessions_controller.rb
View file @
2232576e
...
@@ -8,7 +8,7 @@ class SessionsController < ApplicationController
...
@@ -8,7 +8,7 @@ class SessionsController < ApplicationController
if
@user
&&
@user
.
authenticate
(
params
[
:session
][
:password
])
if
@user
&&
@user
.
authenticate
(
params
[
:session
][
:password
])
if
@user
.
activated?
if
@user
.
activated?
log_in
@user
log_in
@user
params
[
:session
][
:remember_me
]
==
'1'
?
remember
(
@user
)
:
forget
(
@user
)
params
[
:session
][
:remember_me
]
==
"1"
?
remember
(
@user
)
:
forget
(
@user
)
redirect_back_or
@user
redirect_back_or
@user
else
else
message
=
"Account not activated. "
message
=
"Account not activated. "
...
...
app/controllers/users_controller.rb
View file @
2232576e
...
@@ -5,7 +5,6 @@ class UsersController < ApplicationController
...
@@ -5,7 +5,6 @@ class UsersController < ApplicationController
def
index
def
index
@users
=
User
.
where
(
activated:
true
).
paginate
(
page:
params
[
:page
])
@users
=
User
.
where
(
activated:
true
).
paginate
(
page:
params
[
:page
])
end
end
def
show
def
show
...
...
app/mailers/user_mailer.rb
View file @
2232576e
class
UserMailer
<
ApplicationMailer
class
UserMailer
<
ApplicationMailer
def
account_activation
(
user
)
def
account_activation
(
user
)
@user
=
user
@user
=
user
mail
to:
user
.
email
,
subject:
"Account activation"
mail
to:
user
.
email
,
subject:
"Account activation"
...
...
app/models/user.rb
View file @
2232576e
...
@@ -73,4 +73,3 @@ class User < ApplicationRecord
...
@@ -73,4 +73,3 @@ class User < ApplicationRecord
self
.
activation_digest
=
User
.
digest
(
activation_token
)
self
.
activation_digest
=
User
.
digest
(
activation_token
)
end
end
end
end
config/environments/development.rb
View file @
2232576e
...
@@ -24,9 +24,7 @@ Rails.application.configure do
...
@@ -24,9 +24,7 @@ Rails.application.configure do
if
Rails
.
root
.
join
(
"tmp/caching-dev.txt"
).
exist?
if
Rails
.
root
.
join
(
"tmp/caching-dev.txt"
).
exist?
config
.
action_controller
.
perform_caching
=
true
config
.
action_controller
.
perform_caching
=
true
config
.
cache_store
=
:memory_store
config
.
cache_store
=
:memory_store
config
.
public_file_server
.
headers
=
{
config
.
public_file_server
.
headers
=
{
"Cache-Control"
=>
"public, max-age=
#{
2
.
days
.
seconds
.
to_i
}
"
}
"Cache-Control"
=>
"public, max-age=
#{
2
.
days
.
seconds
.
to_i
}
"
}
else
else
config
.
action_controller
.
perform_caching
=
false
config
.
action_controller
.
perform_caching
=
false
config
.
cache_store
=
:null_store
config
.
cache_store
=
:null_store
...
...
config/routes.rb
View file @
2232576e
Rails
.
application
.
routes
.
draw
do
Rails
.
application
.
routes
.
draw
do
root
"static_pages#home"
root
"static_pages#home"
get
"/help"
,
to:
"static_pages#help"
get
"/help"
,
to:
"static_pages#help"
get
"/about"
,
to:
"static_pages#about"
get
"/about"
,
to:
"static_pages#about"
get
"/contact"
,
to:
"static_pages#contact"
get
"/contact"
,
to:
"static_pages#contact"
get
"/signup"
,
to:
"users#new"
get
"/signup"
,
to:
"users#new"
get
"/login"
,
to:
"sessions#new"
get
"/login"
,
to:
"sessions#new"
post
"/login"
,
to:
"sessions#create"
post
"/login"
,
to:
"sessions#create"
delete
"/logout"
,
to:
"sessions#destroy"
delete
"/logout"
,
to:
"sessions#destroy"
resources
:users
resources
:users
resources
:account_activations
,
only:
[
:edit
]
resources
:account_activations
,
only:
[
:edit
]
end
end
db/schema.rb
View file @
2232576e
...
@@ -11,7 +11,6 @@
...
@@ -11,7 +11,6 @@
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20191119063621
)
do
ActiveRecord
::
Schema
.
define
(
version:
20191119063621
)
do
create_table
"users"
,
force: :cascade
do
|
t
|
create_table
"users"
,
force: :cascade
do
|
t
|
t
.
string
"name"
t
.
string
"name"
t
.
string
"email"
t
.
string
"email"
...
@@ -25,5 +24,4 @@ ActiveRecord::Schema.define(version: 20191119063621) do
...
@@ -25,5 +24,4 @@ ActiveRecord::Schema.define(version: 20191119063621) do
t
.
datetime
"activated_at"
t
.
datetime
"activated_at"
t
.
index
[
"email"
],
name:
"index_users_on_email"
,
unique:
true
t
.
index
[
"email"
],
name:
"index_users_on_email"
,
unique:
true
end
end
end
end
db/seeds.rb
View file @
2232576e
...
@@ -2,7 +2,7 @@ User.create!(name: "Example User",
...
@@ -2,7 +2,7 @@ User.create!(name: "Example User",
email:
"example@railstutorial.org"
,
email:
"example@railstutorial.org"
,
password:
"foobar"
,
password:
"foobar"
,
password_confirmation:
"foobar"
,
password_confirmation:
"foobar"
,
admin:
true
,
admin:
true
,
activated:
true
,
activated:
true
,
activated_at:
Time
.
zone
.
now
)
activated_at:
Time
.
zone
.
now
)
...
...
test/controllers/account_activations_controller_test.rb
View file @
2232576e
require
'test_helper'
require
"test_helper"
class
AccountActivationsControllerTest
<
ActionDispatch
::
IntegrationTest
class
AccountActivationsControllerTest
<
ActionDispatch
::
IntegrationTest
# test "the truth" do
# assert true
# end
end
end
test/integration/users_signup_test.rb
View file @
2232576e
...
@@ -8,7 +8,7 @@ class UsersSignupTest < ActionDispatch::IntegrationTest
...
@@ -8,7 +8,7 @@ class UsersSignupTest < ActionDispatch::IntegrationTest
test
"invalid signup information"
do
test
"invalid signup information"
do
get
signup_path
get
signup_path
assert_no_difference
"User.count"
do
assert_no_difference
"User.count"
do
post
users_path
,
params:
{
user:
{
name:
""
,
email:
"user@invalid"
,
password:
"foo"
,
password_confirmation:
"bar"
}}
post
users_path
,
params:
{
user:
{
name:
""
,
email:
"user@invalid"
,
password:
"foo"
,
password_confirmation:
"bar"
}}
end
end
assert_template
"users/new"
assert_template
"users/new"
assert_select
"div#error_explanation"
assert_select
"div#error_explanation"
...
...
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