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
e7a49cd4
Commit
e7a49cd4
authored
Nov 19, 2019
by
Đường Sỹ Hoàng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed coding styles
parent
070c8332
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
38 additions
and
13 deletions
+38
-13
app/assets/javascripts/account_activations.coffee
+3
-0
app/assets/stylesheets/account_activations.scss
+3
-0
app/controllers/account_activations_controller.rb
+2
-0
app/controllers/users_controller.rb
+4
-3
app/helpers/account_activations_helper.rb
+2
-0
app/views/users/_user.html.erb
+1
-1
app/views/users/index.html.erb
+1
-1
app/views/users/new.html.erb
+3
-3
db/migrate/20191119035913_add_activation_to_users.rb
+7
-0
db/seeds.rb
+3
-3
test/controllers/account_activations_controller_test.rb
+7
-0
test/controllers/users_controller_test.rb
+1
-1
test/integration/users_edit_test.rb
+1
-1
No files found.
app/assets/javascripts/account_activations.coffee
0 → 100644
View file @
e7a49cd4
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
app/assets/stylesheets/account_activations.scss
0 → 100644
View file @
e7a49cd4
// Place all the styles related to the AccountActivations controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
app/controllers/account_activations_controller.rb
0 → 100644
View file @
e7a49cd4
class
AccountActivationsController
<
ApplicationController
end
app/controllers/users_controller.rb
View file @
e7a49cd4
class
UsersController
<
ApplicationController
before_action
:logged_in_user
,
only:
[
:index
,
:edit
,
:update
,
:destroy
]
before_action
:logged_in_user
,
only:
[
:index
,
:edit
,
:update
,
:destroy
]
before_action
:correct_user
,
only:
[
:edit
,
:update
]
before_action
:admin_user
,
only: :destroy
def
index
@users
=
User
.
paginate
(
page:
params
[
:page
])
end
...
...
@@ -52,11 +53,11 @@ class UsersController < ApplicationController
end
def
user_params
params
.
require
(
:user
).
permit
(
:name
,
:email
,
:password
,
:password_confirmation
)
params
.
require
(
:user
).
permit
(
:name
,
:email
,
:password
,
:password_confirmation
)
end
# Before filters
# Confirms a logged-in user.
def
logged_in_user
unless
logged_in?
...
...
app/helpers/account_activations_helper.rb
0 → 100644
View file @
e7a49cd4
module
AccountActivationsHelper
end
app/views/users/_user.html.erb
View file @
e7a49cd4
...
...
@@ -2,6 +2,6 @@
<%=
gravatar_for
user
,
size:
50
%>
<%=
link_to
user
.
name
,
user
%>
<%
if
current_user
.
admin?
&&
!
current_user?
(
user
)
%>
|
<%=
link_to
"delete"
,
user
,
method: :delete
,
data:
{
confirm:
"You sure?"
}
%>
|
<%=
link_to
"delete"
,
user
,
method: :delete
,
data:
{
confirm:
"You sure?"
}
%>
<%
end
%>
</li>
app/views/users/index.html.erb
View file @
e7a49cd4
<%
provide
(
:title
,
'All users'
)
%>
<%
provide
(
:title
,
"All users"
)
%>
<h1>
All users
</h1>
<%=
will_paginate
%>
...
...
app/views/users/new.html.erb
View file @
e7a49cd4
<%
provide
(
:title
,
'Sign up'
)
%>
<%
provide
(
:button_text
,
'Create my account'
)
%>
<%
provide
(
:title
,
"Sign up"
)
%>
<%
provide
(
:button_text
,
"Create my account"
)
%>
<h1>
Sign up
</h1>
<div
class=
"row"
>
<div
class=
"col-md-6 col-md-offset-3"
>
<%=
render
'form'
%>
<%=
render
"form"
%>
</div>
</div>
db/migrate/20191119035913_add_activation_to_users.rb
0 → 100644
View file @
e7a49cd4
class
AddActivationToUsers
<
ActiveRecord
::
Migration
[
5.1
]
def
change
add_column
:users
,
:activation_digest
,
:string
add_column
:users
,
:activated
,
:boolean
,
default:
false
add_column
:users
,
:activated_at
,
:datetime
end
end
db/seeds.rb
View file @
e7a49cd4
User
.
create!
(
name:
"Example User"
,
User
.
create!
(
name:
"Example User"
,
email:
"example@railstutorial.org"
,
password:
"foobar"
,
password_confirmation:
"foobar"
)
99
.
times
do
|
n
|
name
=
Faker
::
Name
.
name
name
=
Faker
::
Name
.
name
email
=
"example-
#{
n
+
1
}
@railstutorial.org"
password
=
"password"
User
.
create!
(
name:
name
,
User
.
create!
(
name:
name
,
email:
email
,
password:
password
,
password_confirmation:
password
)
...
...
test/controllers/account_activations_controller_test.rb
0 → 100644
View file @
e7a49cd4
require
'test_helper'
class
AccountActivationsControllerTest
<
ActionDispatch
::
IntegrationTest
# test "the truth" do
# assert true
# end
end
test/controllers/users_controller_test.rb
View file @
e7a49cd4
...
...
@@ -39,7 +39,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
test
"should not allow the admin attribute to be edited via the web"
do
log_in_as
(
@other_user
)
assert_not
@other_user
.
admin?
patch
user_path
(
@other_user
),
params:
{
user
:
{
password:
@other_user
.
password
,
password_confirmation:
@other_user
.
password
,
admin:
true
}
}
patch
user_path
(
@other_user
),
params:
{
user:
{
password:
@other_user
.
password
,
password_confirmation:
@other_user
.
password
,
admin:
true
}
}
assert_not
@other_user
.
reload
.
admin?
end
end
test/integration/users_edit_test.rb
View file @
e7a49cd4
...
...
@@ -34,7 +34,7 @@ class UsersEditTest < ActionDispatch::IntegrationTest
assert_redirected_to
edit_user_url
(
@user
)
name
=
"Foo Bar"
email
=
"foo@bar.com"
patch
user_path
(
@user
),
params:
{
user:
{
name:
name
,
email:
email
,
password
:""
,
password_confirmation:
""
}
}
patch
user_path
(
@user
),
params:
{
user:
{
name:
name
,
email:
email
,
password:
""
,
password_confirmation:
""
}
}
assert_not
flash
.
empty?
assert_redirected_to
@user
@user
.
reload
...
...
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