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
d62fc6cd
Commit
d62fc6cd
authored
Nov 19, 2019
by
Đường Sỹ Hoàng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated files
parent
9495aaca
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
test/fixtures/users.yml
+1
-0
test/integration/users_index_test.rb
+19
-4
No files found.
test/fixtures/users.yml
View file @
d62fc6cd
...
...
@@ -2,6 +2,7 @@ michael:
name
:
Michael Example
email
:
michael@example.com
password_digest
:
<%= User.digest("password") %>
admin
:
true
archer
:
name
:
Sterling Archer
...
...
test/integration/users_index_test.rb
View file @
d62fc6cd
require
"test_helper"
class
UsersIndexTest
<
ActionDispatch
::
IntegrationTest
def
setup
@user
=
users
(
:michael
)
@admin
=
users
(
:michael
)
@non_admin
=
users
(
:archer
)
end
test
"index
including pagination
"
do
log_in_as
(
@
user
)
test
"index
as admin including pagination and delete links
"
do
log_in_as
(
@
admin
)
get
users_path
assert_template
"users/index"
assert_select
"div.pagination"
User
.
paginate
(
page:
1
).
each
do
|
user
|
first_page_of_users
=
User
.
paginate
(
page:
1
)
first_page_of_users
.
each
do
|
user
|
assert_select
"a[href=?]"
,
user_path
(
user
),
text:
user
.
name
unless
user
==
@admin
assert_select
"a[href=?]"
,
user_path
(
user
),
text:
"delete"
end
end
assert_difference
"User.count"
,
-
1
do
delete
user_path
(
@non_admin
)
end
end
test
"index as non-admin"
do
log_in_as
(
@non_admin
)
get
users_path
assert_select
"a"
,
text:
"delete"
,
count:
0
end
end
\ No newline at end of file
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