Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ef18b18d
Commit
ef18b18d
authored
Aug 05, 2020
by
Robert Hunt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial review feedback
Removed unnecessary render methods and updated to use let_it_be rather than let
parent
efc6600b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
55 deletions
+20
-55
ee/spec/views/shared/credentials_inventory/_expiry_date.html.haml_spec.rb
...ared/credentials_inventory/_expiry_date.html.haml_spec.rb
+4
-20
ee/spec/views/shared/credentials_inventory/personal_access_tokens/_personal_access_token.html.haml_spec.rb
...al_access_tokens/_personal_access_token.html.haml_spec.rb
+10
-21
ee/spec/views/shared/credentials_inventory/ssh_keys/_ssh_key.html.haml_spec.rb
...credentials_inventory/ssh_keys/_ssh_key.html.haml_spec.rb
+6
-14
No files found.
ee/spec/views/shared/credentials_inventory/_expiry_date.html.haml_spec.rb
View file @
ef18b18d
...
...
@@ -5,13 +5,13 @@ require 'spec_helper'
RSpec
.
describe
(
'shared/credentials_inventory/_expiry_date.html.haml'
)
do
let_it_be
(
:user
)
{
create
(
:user
)
}
context
'when a non-expirable credential is used'
do
let_it_be
(
:credential
)
{
create
(
:deploy_key
,
user:
user
)}
before
do
render
'shared/credentials_inventory/expiry_date'
,
credential:
credential
end
context
'when a non-expirable credential is used'
do
let_it_be
(
:credential
)
{
create
(
:deploy_key
,
user:
user
)}
it
'shows "Never" if expires? method does not exist'
do
expect
(
rendered
).
to
have_text
(
'Never'
)
end
...
...
@@ -20,10 +20,6 @@ RSpec.describe('shared/credentials_inventory/_expiry_date.html.haml') do
context
'when an expirable credential is used'
do
let_it_be
(
:credential
)
{
create
(
:personal_access_token
,
user:
user
,
expires_at:
nil
)}
before
do
render
'shared/credentials_inventory/expiry_date'
,
credential:
credential
end
it
'shows "Never" when not expirable'
do
expect
(
rendered
).
to
have_text
(
'Never'
)
end
...
...
@@ -32,10 +28,6 @@ RSpec.describe('shared/credentials_inventory/_expiry_date.html.haml') do
let_it_be
(
:expiry_date
)
{
20
.
days
.
since
.
to_date
.
to_s
}
let_it_be
(
:credential
)
{
create
(
:personal_key
,
user:
user
,
expires_at:
expiry_date
)}
before
do
render
'shared/credentials_inventory/expiry_date'
,
credential:
credential
end
it
'shows the correct date'
do
expect
(
rendered
).
to
have_text
(
expiry_date
)
end
...
...
@@ -49,10 +41,6 @@ RSpec.describe('shared/credentials_inventory/_expiry_date.html.haml') do
let_it_be
(
:expiry_date
)
{
1
.
day
.
since
.
to_date
.
to_s
}
let_it_be
(
:credential
)
{
create
(
:personal_access_token
,
user:
user
,
expires_at:
expiry_date
)}
before
do
render
'shared/credentials_inventory/expiry_date'
,
credential:
credential
end
it
'shows the correct date'
do
expect
(
rendered
).
to
have_text
(
expiry_date
)
end
...
...
@@ -66,10 +54,6 @@ RSpec.describe('shared/credentials_inventory/_expiry_date.html.haml') do
let_it_be
(
:expiry_date
)
{
2
.
days
.
ago
.
to_date
.
to_s
}
let_it_be
(
:credential
)
{
create
(
:personal_access_token
,
user:
user
,
expires_at:
expiry_date
)}
before
do
render
'shared/credentials_inventory/expiry_date'
,
credential:
credential
end
it
'shows the correct date'
do
expect
(
rendered
).
to
have_text
(
expiry_date
)
end
...
...
ee/spec/views/shared/credentials_inventory/personal_access_tokens/_personal_access_token.html.haml_spec.rb
View file @
ef18b18d
...
...
@@ -3,9 +3,9 @@
require
'spec_helper'
RSpec
.
describe
(
'shared/credentials_inventory/personal_access_tokens/_personal_access_token.html.haml'
)
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:expiry_date
)
{
20
.
days
.
since
}
let
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
,
expires_at:
expiry_date
)}
let
_it_be
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:expiry_date
)
{
20
.
days
.
since
}
let
_it_be
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
,
expires_at:
expiry_date
)}
before
do
allow
(
view
).
to
receive
(
:user_detail_path
).
and_return
(
'abcd'
)
...
...
@@ -25,14 +25,10 @@ RSpec.describe('shared/credentials_inventory/personal_access_tokens/_personal_ac
end
context
'revoked date'
do
let
(
:updated_at_date
)
{
10
.
days
.
ago
}
let
_it_be
(
:updated_at_date
)
{
10
.
days
.
ago
}
context
'when set'
do
let
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
,
updated_at:
updated_at_date
,
revoked:
true
)}
before
do
render
'shared/credentials_inventory/personal_access_tokens/personal_access_token'
,
personal_access_token:
personal_access_token
end
let_it_be
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
,
updated_at:
updated_at_date
,
revoked:
true
)}
it
'shows the last accessed on date'
do
expect
(
rendered
).
to
have_text
(
personal_access_token
.
updated_at
.
to_date
.
to_s
)
...
...
@@ -40,25 +36,18 @@ RSpec.describe('shared/credentials_inventory/personal_access_tokens/_personal_ac
end
context
'when not set'
do
let
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
,
updated_at:
updated_at_date
)}
before
do
render
'shared/credentials_inventory/personal_access_tokens/personal_access_token'
,
personal_access_token:
personal_access_token
end
let_it_be
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
,
updated_at:
updated_at_date
)}
it
'shows "Never" for the last accessed on date'
do
expect
(
rendered
).
not_to
have_text
(
updated_at_date
.
to_date
.
to_s
)
end
end
end
context
'scopes'
do
context
'when set'
do
let
(
:scopes
)
{
%w(api read_user read_api)
}
let
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
,
scopes:
scopes
)}
before
do
render
'shared/credentials_inventory/personal_access_tokens/personal_access_token'
,
personal_access_token:
personal_access_token
end
let_it_be
(
:scopes
)
{
%w(api read_user read_api)
}
let_it_be
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
,
scopes:
scopes
)}
it
'shows the scopes'
do
expect
(
rendered
).
to
have_text
(
personal_access_token
.
scopes
.
join
(
', '
))
...
...
@@ -66,7 +55,7 @@ RSpec.describe('shared/credentials_inventory/personal_access_tokens/_personal_ac
end
context
'when not set'
do
let
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
)}
let
_it_be
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
)}
before
do
# Turns out on creation of a PersonalAccessToken we set some default scopes and you can't pass `nil`
...
...
ee/spec/views/shared/credentials_inventory/ssh_keys/_ssh_key.html.haml_spec.rb
View file @
ef18b18d
...
...
@@ -3,9 +3,9 @@
require
'spec_helper'
RSpec
.
describe
(
'shared/credentials_inventory/ssh_keys/_ssh_key.html.haml'
)
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:expiry_date
)
{
20
.
days
.
since
}
let
(
:ssh_key
)
{
create
(
:personal_key
,
user:
user
,
expires_at:
expiry_date
)}
let
_it_be
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:expiry_date
)
{
20
.
days
.
since
}
let
_it_be
(
:ssh_key
)
{
create
(
:personal_key
,
user:
user
,
expires_at:
expiry_date
)}
before
do
allow
(
view
).
to
receive
(
:user_detail_path
).
and_return
(
'abcd'
)
...
...
@@ -26,12 +26,8 @@ RSpec.describe('shared/credentials_inventory/ssh_keys/_ssh_key.html.haml') do
context
'last accessed date'
do
context
'when set'
do
let
(
:last_used_date
)
{
10
.
days
.
ago
}
let
(
:ssh_key
)
{
create
(
:personal_key
,
user:
user
,
last_used_at:
last_used_date
)}
before
do
render
'shared/credentials_inventory/ssh_keys/ssh_key'
,
ssh_key:
ssh_key
end
let_it_be
(
:last_used_date
)
{
10
.
days
.
ago
}
let_it_be
(
:ssh_key
)
{
create
(
:personal_key
,
user:
user
,
last_used_at:
last_used_date
)}
it
'shows the last accessed on date'
do
expect
(
rendered
).
to
have_text
(
ssh_key
.
last_used_at
.
to_date
.
to_s
)
...
...
@@ -39,11 +35,7 @@ RSpec.describe('shared/credentials_inventory/ssh_keys/_ssh_key.html.haml') do
end
context
'when not set'
do
let
(
:ssh_key
)
{
create
(
:personal_key
,
user:
user
)}
before
do
render
'shared/credentials_inventory/ssh_keys/ssh_key'
,
ssh_key:
ssh_key
end
let_it_be
(
:ssh_key
)
{
create
(
:personal_key
,
user:
user
)}
it
'shows "Never" for the last accessed on date'
do
expect
(
rendered
).
to
have_text
(
'Last Accessed On Never'
)
...
...
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