BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3adf125a
Commit
3adf125a
authored
Jun 03, 2016
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for errors while creating/revoking personal access tokens.
parent
1a416720
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
2 deletions
+31
-2
personal_access_tokens_spec.rb
spec/features/profiles/personal_access_tokens_spec.rb
+31
-2
No files found.
spec/features/profiles/personal_access_tokens_spec.rb
View file @
3adf125a
...
@@ -15,6 +15,12 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do
...
@@ -15,6 +15,12 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do
find
(
".created-personal-access-token pre"
)
find
(
".created-personal-access-token pre"
)
end
end
def
disallow_personal_access_token_saves!
allow_any_instance_of
(
PersonalAccessToken
).
to
receive
(
:save
).
and_return
(
false
)
errors
=
ActiveModel
::
Errors
.
new
(
PersonalAccessToken
.
new
).
tap
{
|
e
|
e
.
add
(
:name
,
"cannot be nil"
)
}
allow_any_instance_of
(
PersonalAccessToken
).
to
receive
(
:errors
).
and_return
(
errors
)
end
before
do
before
do
login_as
(
user
)
login_as
(
user
)
end
end
...
@@ -43,11 +49,23 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do
...
@@ -43,11 +49,23 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do
expect
(
active_personal_access_tokens
).
to
have_text
(
PersonalAccessToken
.
last
.
name
)
expect
(
active_personal_access_tokens
).
to
have_text
(
PersonalAccessToken
.
last
.
name
)
expect
(
active_personal_access_tokens
).
to
have_text
(
Date
.
today
.
next_month
.
at_beginning_of_month
.
to_s
(
:medium
))
expect
(
active_personal_access_tokens
).
to
have_text
(
Date
.
today
.
next_month
.
at_beginning_of_month
.
to_s
(
:medium
))
end
end
context
"when creation fails"
do
it
"displays an error message"
do
disallow_personal_access_token_saves!
visit
profile_personal_access_tokens_path
fill_in
"Name"
,
with:
FFaker
::
Product
.
brand
expect
{
click_on
"Add Personal Access Token"
}.
not_to
change
{
PersonalAccessToken
.
count
}
expect
(
page
).
to
have_content
(
"Name cannot be nil"
)
end
end
end
end
describe
"inactive tokens"
do
describe
"inactive tokens"
do
let!
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
)
}
it
"allows revocation of an active token"
do
it
"allows revocation of an active token"
do
personal_access_token
=
create
(
:personal_access_token
,
user:
user
)
visit
profile_personal_access_tokens_path
visit
profile_personal_access_tokens_path
click_on
"Revoke"
click_on
"Revoke"
...
@@ -55,10 +73,21 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do
...
@@ -55,10 +73,21 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do
end
end
it
"moves expired tokens to the 'inactive' section"
do
it
"moves expired tokens to the 'inactive' section"
do
personal_access_token
=
create
(
:personal_access_token
,
expires_at:
5
.
days
.
ago
,
user:
user
)
personal_access_token
.
update
(
expires_at:
5
.
days
.
ago
)
visit
profile_personal_access_tokens_path
visit
profile_personal_access_tokens_path
expect
(
inactive_personal_access_tokens
).
to
have_text
(
personal_access_token
.
name
)
expect
(
inactive_personal_access_tokens
).
to
have_text
(
personal_access_token
.
name
)
end
end
context
"when revocation fails"
do
it
"displays an error message"
do
disallow_personal_access_token_saves!
visit
profile_personal_access_tokens_path
expect
{
click_on
"Revoke"
}.
not_to
change
{
PersonalAccessToken
.
inactive
.
count
}
expect
(
active_personal_access_tokens
).
to
have_text
(
personal_access_token
.
name
)
expect
(
page
).
to
have_content
(
"Could not revoke"
)
end
end
end
end
end
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